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