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