separate out TagGrid and do all the lovely autocomplete stuff
[potlatch2.git] / net / systemeD / potlatch2 / TagViewer.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2 <mx:VBox
3         xmlns:mx="http://www.adobe.com/2006/mxml"
4         xmlns:flexlib="flexlib.containers.*"
5         xmlns:controls="net.systemeD.controls.*"
6         xmlns:potlatch2="net.systemeD.potlatch2.*"
7         horizontalScrollPolicy="off"
8     backgroundColor="white"
9     initialize="loadFeatures()">
10
11 <mx:ViewStack id="sidebar" width="100%" height="100%" creationPolicy="all">
12   <mx:VBox id="dndPanel" width="100%" height="100%" horizontalScrollPolicy="off" styleName="dndPanelVbox">
13     <mx:Text id="dndPanelText" text="{dndPrompt}" width="100%" styleName="helpInfo" />
14         <mx:Repeater id="dndRep" dataProvider="{MapFeatures.getInstance().getCategoriesForType('point')}">
15                 <mx:HBox width="100%"><mx:Label text="{dndRep.currentItem.name}:" styleName="dndPanelCategoryLabel"/></mx:HBox>
16
17                 <mx:TileList dataProvider="{dndRep.currentItem.getFeaturesForType('point')}" width="100%" height="1"
18                                      rowHeight="32" columnWidth="32" updateComplete="resizePOIGrid(event)" styleName="dndPanelTileList">
19                         <mx:itemRenderer>
20                                 <mx:Component>
21                                         <mx:VBox toolTip="{data.name}">
22                                                 <mx:Script><![CDATA[
23                                                         import mx.events.DragEvent;
24                                                         import mx.managers.DragManager;
25                                                         import mx.core.DragSource;
26
27                                                         private function dragPOI(event:MouseEvent, tags:Array):void {
28                                                                 // Get the drag initiator component from the event object.
29                                                                 var dragInitiator:Image = event.currentTarget as Image;
30                                                                 var dragSource:DragSource = new DragSource();
31                                                                 dragSource.addData(tags, 'tags');
32                                                                 dragSource.addData(event.target.parent.parent.parent.parent, 'container');
33
34                                                                 var dragProxy:Image = new Image();
35                                                                 dragProxy.source = dragInitiator.source;
36                                                                 dragProxy.width = dragInitiator.width;   // must set width and height explicitly
37                                                                 dragProxy.height = dragInitiator.height; // for non-embedded images
38                                                                 DragManager.doDrag(dragInitiator, dragSource, event, dragProxy);
39                                                         }
40                                                 ]]></mx:Script>
41                                                 <mx:Image id="foo" source="{data.image}" height="24" width="24" mouseMove="dragPOI(event, data.tags)" toolTip="{data.name}" />
42                                         </mx:VBox>
43                                 </mx:Component>
44                         </mx:itemRenderer>
45                 </mx:TileList>
46         </mx:Repeater>
47   </mx:VBox>
48   
49   <mx:VBox id="tagsPanel" width="100%" height="100%" creationPolicy="auto">
50     <mx:ViewStack id="stack" width="100%" height="100%">
51       <mx:VBox width="100%" height="100%" label="Simple" id="editorContainer" creationComplete="initEditorStackUIs()">
52         <mx:HBox width="100%" id="iconContainer" styleName="featureSelector">
53             <mx:Image id="iconImage"/>
54             <mx:VBox width="100%" verticalGap="1">
55               <mx:PopUpButton id="popupChange" creationComplete="initFeatureBox()" openAlways="true" width="100%"/>
56               <mx:Text condenseWhite="true" width="100%" id="iconText"/>
57             </mx:VBox>
58             <mx:LinkButton label="?" click="openDescription()" id="helpLabel" styleName="helpInfo"/>
59         </mx:HBox>
60       </mx:VBox>
61       <mx:VBox width="100%" height="100%" label="Advanced" id="advancedContainer" initialize="checkAdvanced()" verticalGap="1">
62         <mx:Label id="advancedID" click="openEntityPage()">
63           <mx:htmlText><![CDATA[<i>No Selection</i>]]></mx:htmlText>
64         </mx:Label>
65
66                 <potlatch2:TagGrid id="advancedTagGrid" width="100%" height="75%" />
67
68         <mx:HBox horizontalAlign="right" width="100%">
69           <mx:LinkButton label="Delete" click="advancedTagGrid.removeTag()" enabled="{advancedTagGrid.selectedItem != null? true : false}"/>
70           <mx:LinkButton label="Add" click="advancedTagGrid.addNewTag()"/>
71         </mx:HBox>
72         
73         <mx:DataGrid editable="true" width="100%" height="25%" id="relationsGrid"
74             doubleClickEnabled="true"
75             itemDoubleClick="editRelation(relationsGrid.selectedItem.id)"
76             doubleClick="if (event.target.parent==relationsGrid) { addToRelation(); }">
77             <mx:columns>
78                 <mx:DataGridColumn editable="false" dataField="description" headerText="Relation"/>
79                 <mx:DataGridColumn editable="false" dataField="id_idx" headerText="ID"/>
80                 <mx:DataGridColumn editable="true" dataField="role" headerText="Role"/>
81             </mx:columns>
82         </mx:DataGrid>
83
84         <mx:HBox horizontalAlign="right" width="100%">
85           <mx:LinkButton label="Remove from" click="removeFromRelation(relationsGrid.selectedItem.id, relationsGrid.selectedItem.index)" 
86                           enabled="{relationsGrid.selectedItem != null? true : false}"/>
87           <mx:LinkButton label="Add to" click="addToRelation()"/>
88         </mx:HBox>
89
90       </mx:VBox>
91
92       <mx:VBox width="100%" height="100%" label="Members" id="membersVBox" initialize="checkMembers()" verticalGap="1">
93         <mx:Label id="membersText" text="Relation Members"/>
94         <mx:DataGrid editable="true" width="100%" height="100%" id="membersGrid"
95                       dragEnabled="true" dragMoveEnabled="true" dropEnabled="true">
96           <mx:columns>
97             <mx:DataGridColumn editable="false" dataField="type" headerText="Type"/>
98             <mx:DataGridColumn editable="false" dataField="id" headerText="ID"/>
99             <mx:DataGridColumn editable="true" dataField="role" headerText="Role"/>
100           </mx:columns>
101         </mx:DataGrid>
102       </mx:VBox>
103       
104       </mx:ViewStack>
105
106           <mx:HBox width="100%">
107                 <mx:LinkBar dataProvider="{stack}"/>
108                 <mx:Spacer width="100%"/>
109                 <mx:LinkButton 
110                         icon="@Embed('../../../embedded/view_tabbed.png')"
111                         disabledIcon="@Embed('../../../embedded/view_tabbed_disabled.png')"
112                         click="setEditorStackUI(true)" id="tabNavigatorLabel" paddingTop="6" 
113                         toolTip="Show in tabs"
114                         enabled="{editorStack is Accordion &amp;&amp; stack.selectedIndex==0}" />
115                 <mx:LinkButton
116                         icon="@Embed('../../../embedded/view_accordion.png')" 
117                         disabledIcon="@Embed('../../../embedded/view_accordion_disabled.png')"
118                         click="setEditorStackUI(false)" id="accordionLabel" paddingTop="6"
119                         toolTip="Show in sliding windows"
120                         enabled="{editorStack is SuperTabNavigator &amp;&amp; stack.selectedIndex==0}" />
121           </mx:HBox>
122   </mx:VBox>
123 </mx:ViewStack>
124
125   <mx:Script><![CDATA[
126       import net.systemeD.halcyon.connection.*;
127       import net.systemeD.potlatch2.mapfeatures.*;
128
129       import mx.collections.*;
130       import mx.containers.*;
131       import mx.events.*;
132       import mx.core.*;
133       import mx.managers.PopUpManager;
134       import flash.geom.Point;
135       import flash.net.*;
136       import mx.events.DragEvent;
137       import mx.managers.DragManager;
138       import mx.core.DragSource;
139       import flexlib.containers.SuperTabNavigator;
140
141       private static const dndPrompt:String="Add new points by dragging them onto the map";
142
143       private var editorStackTabNavigator:SuperTabNavigator;
144       private var editorStackAccordion:Accordion;
145       [Bindable] private var editorStack:Container;
146
147       public var mapFeatures:MapFeatures;
148       private var selectedEntity:Entity;
149       private var tagDataProvider:ArrayCollection;
150       private var tw:CategorySelector = null;
151       private var feature:Feature = null;
152
153       public function setEntity(entity:Entity):void {
154           UIComponent.suspendBackgroundProcessing();
155           if ( selectedEntity != entity ) {
156               if ( selectedEntity != null )
157                   selectedEntity.removeEventListener(Connection.TAG_CHANGED, tagChanged);
158               selectedEntity = entity;
159               if ( selectedEntity != null )
160                   selectedEntity.addEventListener(Connection.TAG_CHANGED, tagChanged);
161           }
162
163           if ( advancedID != null )
164               setupAdvanced(entity);
165           if (entity is Relation) {
166               stack.addChild(membersVBox);
167           }
168           refreshFeatureIcon(); 
169           if (selectedEntity == null) {
170             sidebar.selectedChild = dndPanel;
171           } else {
172             initialiseEditors();
173             sidebar.selectedChild = tagsPanel;
174           }
175           UIComponent.resumeBackgroundProcessing();
176       }
177
178       private function refreshFeatureIcon():void {
179           var oldFeature:Feature = feature;
180           feature = selectedEntity == null ? null : mapFeatures.findMatchingFeature(selectedEntity);
181           if ( feature != oldFeature ) {
182               if ( oldFeature != null )
183                   oldFeature.removeEventListener("imageChanged", featureImageChanged);
184               if ( feature != null )
185                   feature.addEventListener("imageChanged", featureImageChanged);
186           }
187
188           if ( feature != null && feature.name != null ) {
189               setFeatureIcon(selectedEntity, feature);
190           } else {
191               blankFeatureIcon(selectedEntity);
192           }
193       }
194
195       private function featureImageChanged(event:Event):void {
196           setFeatureIcon(selectedEntity, feature);
197       }
198       
199       private function setFeatureIcon(entity:Entity, feature:Feature):void {
200           //blankFeatureIcon(entity);
201           
202           iconImage.source = feature.image;
203
204           var txt:String = feature.htmlDetails(entity);
205           iconText.htmlText = txt;
206           popupChange.label = feature.name;
207           setLimitTypes(entity);
208           tw.setSelectedFeature(feature);
209           helpLabel.visible = feature.hasHelpURL();
210       }
211       
212       private function setLimitTypes(entity:Entity):void {
213           var type:String = null;
214           if ( entity is Node )
215               type = "point";
216           else if ( entity is Way )
217               type = Way(entity).isArea() ? "area" : "line";
218           else if ( entity is Relation )
219               type = "relation";
220           tw.setLimitTypes(type);
221       }
222
223       private function blankFeatureIcon(entity:Entity):void {
224           iconImage.source = null;
225           popupChange.label = "unknown";
226           setLimitTypes(entity);
227                   if (entity == null) { 
228                         iconText.htmlText = "<i>Nothing selected</i>";
229             tw.setNoSelectedFeature();
230                   } else if (entity.hasTags()) {
231                         iconText.htmlText = "<b>Not recognised</b><br/>Try looking at the tags under the advanced properties";
232             tw.setSelectedFeature(null);
233                   } else {
234                         iconText.htmlText = "<b>No tags set</b><br/>Use the menu above to say what this "+entity.getType()+" is";
235             tw.setSelectedFeature(null);
236           }
237           helpLabel.visible = false;
238       }
239
240       private var tabComponents:Object = {};
241       
242       private function initialiseEditors():void {
243           editorStack.removeAllChildren();
244           if ( selectedEntity == null || feature == null )
245               return;
246           
247           var editorBox:VBox = createEditorBox();
248           editorBox.label = "Basic";
249           editorStack.addChild(editorBox);
250           
251           var tabs:Object = {};
252           tabComponents = {};
253           
254           for each (var factory:EditorFactory in feature.editors) {
255               if ( factory.presence.isEditorPresent(factory, selectedEntity, null) ) {
256                   var editor:DisplayObject = factory.createEditorInstance(selectedEntity);
257                   if ( editor != null )
258                       editorBox.addChild(editor);
259               }
260               var category:String = factory.category;
261               if (category!='') {
262                       var tab:VBox = tabs[category];
263                       if ( tab == null) {
264                           tab = createEditorBox();
265                           tab.label = category;
266                           editorStack.addChild(tab);
267                           tabs[category] = tab;
268                           tabComponents[tab] = [];
269                       }
270                       var catEditor:DisplayObject = factory.createEditorInstance(selectedEntity);
271                       if ( catEditor != null )
272                           tabComponents[tab].push(catEditor);
273                       //    tab.addChild(catEditor);
274               }
275           }
276       }
277       
278       private function createEditorBox():VBox {
279           var box:VBox = new VBox();
280           box.percentWidth = 100;
281           box.percentHeight = 100;
282           box.styleName = "editorContainer";
283           return box;
284       }
285
286       private function ensureEditorsPopulated(tab:VBox):void {
287           var components:Array = tabComponents[tab];
288           if ( components == null || tab == null || tab.numChildren >= components.length )
289               return;
290           for each (var component:DisplayObject in components ) {
291               tab.addChild(component);
292           }
293       }
294       
295         private function initEditorStackUIs():void {
296                 editorStackTabNavigator = new SuperTabNavigator();
297                 editorStackTabNavigator.allowTabSqueezing=false;
298                 editorStackTabNavigator.minTabWidth=10;
299                 editorStackTabNavigator.closePolicy="close_never";
300                 editorStackTabNavigator.scrollSpeed=20;
301                 editorStackTabNavigator.creationPolicy="auto";
302                 editorStackTabNavigator.percentWidth=100;
303                 editorStackTabNavigator.percentHeight=100;
304
305                 editorStackAccordion = new Accordion();
306                 editorStackAccordion.percentWidth=100;
307                 editorStackAccordion.percentHeight=100;
308                 editorStackAccordion.creationPolicy="auto";
309
310                 setEditorStackUI(true);
311         }
312
313         private function setEditorStackUI(isTabbed:Boolean):void {
314                 var children:Array=[]; var i:uint;
315
316                 if (editorStack) {
317                         // blank existing component
318                         editorStack.removeEventListener("change",editorStackUIChange);
319                         editorStack.removeEventListener("updateComplete",editorStackUIUpdate);
320                         editorStack.removeAllChildren();
321                         editorContainer.removeChildAt(1);
322                 }
323
324                 // replace with new component
325                 editorStack = (isTabbed ? editorStackTabNavigator : editorStackAccordion) as Container;
326                 editorContainer.addChild(editorStack);
327
328                 // re-add children and listeners
329                 initialiseEditors();
330                 editorStack.addEventListener("change",editorStackUIChange);
331                 editorStack.addEventListener("updateComplete",editorStackUIUpdate);
332         }
333         
334         private function editorStackUIChange(event:Event):void {
335                 ensureEditorsPopulated(IndexChangedEvent(event).relatedObject as VBox);
336         }
337
338         private function editorStackUIUpdate(event:Event):void {
339                 if (editorStack is SuperTabNavigator) {
340                         var e:SuperTabNavigator = editorStack as SuperTabNavigator;
341                         if (e.selectedIndex<0) { return; }
342                         for (var i:uint=0; i<e.numChildren; i++) {
343                                 e.getTabAt(i).selected=(i==e.selectedIndex);
344                         }
345                 }
346         }
347
348
349         public function togglePanel():void {
350                 if (stack.selectedChild==editorContainer && selectedEntity!=null) {
351                         stack.selectedChild=advancedContainer;
352                 } else if (stack.selectedChild!=editorContainer) {
353                         stack.selectedChild=editorContainer;
354                 }
355         }
356
357       private function checkAdvanced():void {
358           if ( selectedEntity != null )
359              setupAdvanced(selectedEntity);
360       }
361
362       private var listeningToRelations:Array = [];
363       
364       private function setupAdvanced(entity:Entity):void {
365                 advancedTagGrid.init(entity);
366
367                 if ( entity == null ) {
368                         advancedID.htmlText = "";
369                 } else {
370                         var entityText:String = "xx";
371                         if      ( entity is Node     ) entityText = "Node";
372                         else if ( entity is Way      ) entityText = "Way";
373                         else if ( entity is Relation ) entityText = "Relation";
374                         advancedID.htmlText = entityText+": <b>"+entity.id+"</b>";
375                 }
376
377                 removeRelationListeners();
378                 if ( selectedEntity != null ) {
379                         selectedEntity.removeEventListener(Connection.ADDED_TO_RELATION, addedToRelation);
380                         selectedEntity.removeEventListener(Connection.REMOVED_FROM_RELATION, removedFromRelation);
381                 }
382
383                 if ( entity == null ) {
384                         relationsGrid.dataProvider = null;
385                 } else {
386                         resetRelationsGrid(entity);
387                         entity.addEventListener(Connection.ADDED_TO_RELATION, addedToRelation);
388                         entity.addEventListener(Connection.REMOVED_FROM_RELATION, removedFromRelation);
389                 }
390       }
391
392           public function addNewTag():void {
393                 if (stack.selectedChild!=advancedContainer) { return; }
394                 advancedTagGrid.addNewTag();
395           }
396       
397       private function addedToRelation(event:RelationMemberEvent):void {
398          resetRelationsGrid(selectedEntity);
399       }
400
401       private function removedFromRelation(event:RelationMemberEvent):void {
402          resetRelationsGrid(selectedEntity);
403       }
404
405       private function removeRelationListeners():void {
406           for each( var rel:Relation in listeningToRelations ) {
407               rel.removeEventListener(Connection.TAG_CHANGED, relationTagChanged);
408               rel.removeEventListener(Connection.RELATION_MEMBER_ADDED, entityRelationMemberChanged);
409               rel.removeEventListener(Connection.RELATION_MEMBER_REMOVED, entityRelationMemberChanged);
410           }
411           listeningToRelations = [];
412           relationsGrid.removeEventListener(DataGridEvent.ITEM_EDIT_END, relationRoleChanged);
413       }
414             
415       private function resetRelationsGrid(entity:Entity):void {
416           removeRelationListeners();
417           var relations:Array = [];
418           for each( var rel:Relation in entity.parentRelations ) {
419               for each( var memberIndex:int in rel.findEntityMemberIndexes(entity)) {
420                   var props:Object = {};
421                   props["relation"] = rel;
422                   props["id"] = rel.id;
423                   props["index"] = memberIndex;
424                   props["role"] = rel.getMember(memberIndex).role;
425                   props["description"] = rel.getDescription();
426                   props["id_idx"] = rel.id + "/"+memberIndex;
427
428                   relations.push(props);
429               }
430               
431               rel.addEventListener(Connection.TAG_CHANGED, relationTagChanged);
432               rel.addEventListener(Connection.RELATION_MEMBER_ADDED, entityRelationMemberChanged);
433               rel.addEventListener(Connection.RELATION_MEMBER_REMOVED, entityRelationMemberChanged);
434               listeningToRelations.push(rel);
435           }
436           relationsGrid.dataProvider = relations;
437           relationsGrid.addEventListener(DataGridEvent.ITEM_EDIT_END, relationRoleChanged, false, -100);
438       }
439       
440       private function relationRoleChanged(event:DataGridEvent):void {
441                 if (event.dataField != 'role') { return; }      // shouldn't really happen
442
443                 var relations:Array=event.currentTarget.dataProvider.toArray();
444                 var props:Object=relations[event.rowIndex];
445
446                 var relation:Relation=props['relation'];
447                 var index:uint=props['index'];
448                 var newRole:String=event.itemRenderer.data['role'];
449
450                 relation.setMember(index, new RelationMember(selectedEntity,newRole));
451       }
452
453       private function relationTagChanged(event:TagEvent):void {
454           resetRelationsGrid(selectedEntity);
455       }
456
457       private function entityRelationMemberChanged(event:RelationMemberEvent):void {
458           resetRelationsGrid(selectedEntity);
459       }
460       
461       private function checkMembers():void {
462           if (selectedEntity is Relation) {
463             setupMembers(selectedEntity as Relation);
464           }
465       }
466       
467       private function setupMembers(rel:Relation):void {
468           var members:Array = [];
469           for (var i:int=0 ; i<rel.length; i++) {
470             var props:Object = {};
471             var member:RelationMember = rel.getMember(i);
472             props["id"] = member.entity.id;
473             props["type"] = member.entity.getType();
474             props["role"] = member.role;
475             
476             members.push(props);
477           }
478           membersGrid.dataProvider = members;
479           membersGrid.dataProvider.addEventListener('collectionChange', membersChange); 
480       }
481       
482       private function membersChange(event:Event):void {
483           // Dropping all the members and re-adding them isn't exactly optimal
484           // but is at least robust for any kind of change.
485           // Figuring out a better way is someone else's FIXME
486           
487           var conn:Connection = Connection.getConnectionInstance();
488           var rel:Relation = selectedEntity as Relation
489           
490           // drop members
491           for (var i:int=rel.length-1 ; i>=0; i--) {
492             rel.removeMemberByIndex(i);
493           }
494           
495           // add members in new order
496           for each(var memberObject:Object in membersGrid.dataProvider) {
497             var e:Entity;
498             var id:Number = memberObject.id;
499             if(memberObject.type == 'node') {
500               e = conn.getNode(id);
501             } else if (memberObject.type == 'way') {
502               e = conn.getWay(id);
503             } else if (memberObject.type == 'relation') {
504               e = conn.getRelation(id);
505             }
506             rel.appendMember(new RelationMember(e, memberObject.role));
507           }
508       }
509       
510       private function editRelation(id:Number):void {
511           var panel:RelationEditorPanel = RelationEditorPanel(
512               PopUpManager.createPopUp(Application(Application.application), RelationEditorPanel, true));
513           panel.setRelation(Connection.getConnectionInstance().getRelation(id));
514           PopUpManager.centerPopUp(panel);
515       }
516       
517       private function tagChanged(event:TagEvent):void {
518           refreshFeatureIcon();
519           
520           if ( tagDataProvider != null ) {
521               // check to see if the key is already in our list
522               var exists:Boolean = false;
523               var tag:Tag = null;
524               var i:uint;
525               for ( i = 0; i < tagDataProvider.length && !exists; i++ ) {
526                   tag = Tag(tagDataProvider.getItemAt(i));
527                   exists = tag.key == event.key;
528               }
529               if ( !exists ) {
530                   tag = new Tag(selectedEntity, event.key, event.newValue);
531                   tagDataProvider.addItem(tag);
532                   tagDataProvider.refresh();
533               } else {
534                   if ( event.newValue == null ) {
535                       tagDataProvider.removeItemAt(i-1);
536                       tagDataProvider.refresh();
537                   } else {
538                       tagDataProvider.itemUpdated(tag, "value");
539                   }
540               }
541           }
542       }
543
544       public function loadFeatures():void {
545           mapFeatures = MapFeatures.getInstance();
546           stack.removeChild(membersVBox); // remove by default, will be added if relation
547       }
548
549       public function openDescription():void {
550           if ( feature != null && feature.hasHelpURL() )
551               navigateToURL(new URLRequest(feature.helpURL), "potlatch_help");
552       }
553
554       public function openEntityPage():void {
555           if (selectedEntity != null && selectedEntity.id >= 0) {
556               // This is slightly hard-coded, but not drastically. The ../s could be changed for string manipulation of the apiBase
557               var urlBase:String = Connection.getConnectionInstance().apiBase + '../../browse/'
558               navigateToURL(new URLRequest(urlBase+selectedEntity.getType()+'/'+selectedEntity.id), "potlatch_browse");
559           }
560       }
561
562       public function addToRelation():void {
563           new RelationSelectPanel().init(selectedEntity,new Object());
564       }
565       
566       public function removeFromRelation(id:Number, index:int):void {
567           Connection.getConnectionInstance().getRelation(id).removeMemberByIndex(index);
568       }
569       
570       public function initFeatureBox():void {
571           tw = new CategorySelector();
572           tw.addEventListener("selectedType", changeFeatureType);
573           popupChange.popUp = tw;
574       }
575       
576       public function changeFeatureType(event:Event):void {
577           if ( selectedEntity == null )
578               return;
579
580           UIComponent.suspendBackgroundProcessing();
581           var newFeature:Feature = tw.selectedType;
582           var undoStack:Function = MainUndoStack.getGlobalStack().addAction;
583           var action:CompositeUndoableAction = new CompositeUndoableAction(
584                   "Set "+selectedEntity.getType()+" "+selectedEntity.id+" to "+newFeature.name);
585                   selectedEntity.suspend();
586
587           // remove tags from the current feature
588           if ( feature != null ) {
589               for each( var oldtag:Object in feature.tags ) {
590                   selectedEntity.setTag(oldtag["k"], null, action.push);
591               }
592           }
593           
594           // set tags for new feature
595           if ( newFeature != null ) {
596               for each( var newtag:Object in newFeature.tags ) {
597                   selectedEntity.setTag(newtag["k"], newtag["v"], action.push);
598               }
599           }
600           
601                   selectedEntity.resume();
602           undoStack(action);
603           popupChange.close();
604           initialiseEditors();
605           UIComponent.resumeBackgroundProcessing();
606       }
607       
608         private function resizePOIGrid(event:Event):void {
609                 var rows:Number=event.target.dataProvider.length/event.target.columnCount;
610                 if (rows!=Math.floor(rows)) { rows=Math.floor(rows+1); }
611                 event.target.height=rows*(event.target.rowHeight+1);
612         }
613   ]]></mx:Script>
614 </mx:VBox>
615