872f83cdc255443c104d428de81f959cd8f35b1a
[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}" 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 borderStyle="inset" verticalAlign="middle" width="100%" paddingLeft="3" id="iconContainer">
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"/>
57         </mx:HBox>
58       </mx:VBox>
59       <mx:VBox width="100%" height="100%" label="Advanced" 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           return box;
285       }
286
287       private function ensureEditorsPopulated(tab:VBox):void {
288           var components:Array = tabComponents[tab];
289           if ( components == null || tab == null || tab.numChildren >= components.length )
290               return;
291           for each (var component:DisplayObject in components ) {
292               tab.addChild(component);
293           }
294       }
295       
296         private function initEditorStackUIs():void {
297                 editorStackTabNavigator = new SuperTabNavigator();
298                 editorStackTabNavigator.allowTabSqueezing=false;
299                 editorStackTabNavigator.minTabWidth=10;
300                 editorStackTabNavigator.closePolicy="close_never";
301                 editorStackTabNavigator.scrollSpeed=20;
302                 editorStackTabNavigator.creationPolicy="auto";
303                 editorStackTabNavigator.percentWidth=100;
304                 editorStackTabNavigator.percentHeight=100;
305
306                 editorStackAccordion = new Accordion();
307                 editorStackAccordion.percentWidth=100;
308                 editorStackAccordion.percentHeight=100;
309                 editorStackAccordion.creationPolicy="auto";
310
311                 setEditorStackUI(true);
312         }
313
314         private function setEditorStackUI(isTabbed:Boolean):void {
315                 var children:Array=[]; var i:uint;
316
317                 if (editorStack) {
318                         // blank existing component
319                         editorStack.removeEventListener("change",editorStackUIChange);
320                         editorStack.removeEventListener("updateComplete",editorStackUIUpdate);
321                         editorStack.removeAllChildren();
322                         editorContainer.removeChildAt(1);
323                 }
324
325                 // replace with new component
326                 editorStack = (isTabbed ? editorStackTabNavigator : editorStackAccordion) as Container;
327                 editorContainer.addChild(editorStack);
328
329                 // re-add children and listeners
330                 initialiseEditors();
331                 editorStack.addEventListener("change",editorStackUIChange);
332                 editorStack.addEventListener("updateComplete",editorStackUIUpdate);
333         }
334         
335         private function editorStackUIChange(event:Event):void {
336                 ensureEditorsPopulated(IndexChangedEvent(event).relatedObject as VBox);
337         }
338
339         private function editorStackUIUpdate(event:Event):void {
340                 if (editorStack is SuperTabNavigator) {
341                         var e:SuperTabNavigator = editorStack as SuperTabNavigator;
342                         if (e.selectedIndex<0) { return; }
343                         for (var i:uint=0; i<e.numChildren; i++) {
344                                 e.getTabAt(i).selected=(i==e.selectedIndex);
345                         }
346                 }
347         }
348
349
350       private function checkAdvanced():void {
351           if ( selectedEntity != null )
352              setupAdvanced(selectedEntity);
353       }
354
355       private var listeningToRelations:Array = [];
356       
357       private function setupAdvanced(entity:Entity):void {
358           if ( tagDataProvider == null ) {
359               tagDataProvider = new ArrayCollection();
360               advancedTagGrid.dataProvider = tagDataProvider;
361           }
362
363           tagDataProvider.removeAll();
364           
365           if ( entity == null ) {
366               advancedID.htmlText = "";
367           } else {
368               var entityText:String = "xx";
369               if ( entity is Node ) entityText = "Node";
370               else if ( entity is Way ) entityText = "Way";
371               else if ( entity is Relation ) entityText = "Relation";
372               advancedID.htmlText = entityText+": <b>"+entity.id+"</b>";
373
374               var tags:Array = entity.getTagArray();
375               tags.sortOn("key");
376               for each(var tag:Tag in tags)
377                   tagDataProvider.addItem(tag);
378           }
379                     
380           removeRelationListeners();
381           if ( selectedEntity != null ) {
382               selectedEntity.removeEventListener(Connection.ADDED_TO_RELATION, addedToRelation);
383               selectedEntity.removeEventListener(Connection.REMOVED_FROM_RELATION, removedFromRelation);
384           }
385           
386           if ( entity == null ) {
387               relationsGrid.dataProvider = null;
388           } else {
389               resetRelationsGrid(entity);
390               entity.addEventListener(Connection.ADDED_TO_RELATION, addedToRelation);
391               entity.addEventListener(Connection.REMOVED_FROM_RELATION, removedFromRelation);
392           }
393       }
394       
395       private function addedToRelation(event:RelationMemberEvent):void {
396          resetRelationsGrid(selectedEntity);
397       }
398
399       private function removedFromRelation(event:RelationMemberEvent):void {
400          resetRelationsGrid(selectedEntity);
401       }
402
403       private function removeRelationListeners():void {
404           for each( var rel:Relation in listeningToRelations ) {
405               rel.removeEventListener(Connection.TAG_CHANGED, relationTagChanged);
406               rel.removeEventListener(Connection.RELATION_MEMBER_ADDED, entityRelationMemberChanged);
407               rel.removeEventListener(Connection.RELATION_MEMBER_REMOVED, entityRelationMemberChanged);
408           }
409           listeningToRelations = [];
410           relationsGrid.removeEventListener(DataGridEvent.ITEM_EDIT_END, relationRoleChanged);
411       }
412             
413       private function resetRelationsGrid(entity:Entity):void {
414           removeRelationListeners();
415           var relations:Array = [];
416           for each( var rel:Relation in entity.parentRelations ) {
417               for each( var memberIndex:int in rel.findEntityMemberIndexes(entity)) {
418                   var props:Object = {};
419                   props["relation"] = rel;
420                   props["id"] = rel.id;
421                   props["index"] = memberIndex;
422                   props["role"] = rel.getMember(memberIndex).role;
423                   props["description"] = rel.getDescription();
424                   props["id_idx"] = rel.id + "/"+memberIndex;
425
426                   relations.push(props);
427               }
428               
429               rel.addEventListener(Connection.TAG_CHANGED, relationTagChanged);
430               rel.addEventListener(Connection.RELATION_MEMBER_ADDED, entityRelationMemberChanged);
431               rel.addEventListener(Connection.RELATION_MEMBER_REMOVED, entityRelationMemberChanged);
432               listeningToRelations.push(rel);
433           }
434           relationsGrid.dataProvider = relations;
435           relationsGrid.addEventListener(DataGridEvent.ITEM_EDIT_END, relationRoleChanged, false, -100);
436       }
437       
438       private function relationRoleChanged(event:DataGridEvent):void {
439                 if (event.dataField != 'role') { return; }      // shouldn't really happen
440
441                 var relations:Array=event.currentTarget.dataProvider.toArray();
442                 var props:Object=relations[event.rowIndex];
443
444                 var relation:Relation=props['relation'];
445                 var index:uint=props['index'];
446                 var newRole:String=event.itemRenderer.data['role'];
447
448                 relation.setMember(index, new RelationMember(selectedEntity,newRole));
449       }
450
451       private function relationTagChanged(event:TagEvent):void {
452           resetRelationsGrid(selectedEntity);
453       }
454
455       private function entityRelationMemberChanged(event:RelationMemberEvent):void {
456           resetRelationsGrid(selectedEntity);
457       }
458       
459       private function checkMembers():void {
460           if (selectedEntity is Relation) {
461             setupMembers(selectedEntity as Relation);
462           }
463       }
464       
465       private function setupMembers(rel:Relation):void {
466           var members:Array = [];
467           for (var i:int=0 ; i<rel.length; i++) {
468             var props:Object = {};
469             var member:RelationMember = rel.getMember(i);
470             props["id"] = member.entity.id;
471             props["type"] = member.entity.getType();
472             props["role"] = member.role;
473             
474             members.push(props);
475           }
476           membersGrid.dataProvider = members;
477           membersGrid.dataProvider.addEventListener('collectionChange', membersChange); 
478       }
479       
480       private function membersChange(event:Event):void {
481           // Dropping all the members and re-adding them isn't exactly optimal
482           // but is at least robust for any kind of change.
483           // Figuring out a better way is someone else's FIXME
484           
485           var conn:Connection = Connection.getConnectionInstance();
486           var rel:Relation = selectedEntity as Relation
487           
488           // drop members
489           for (var i:int=rel.length-1 ; i>=0; i--) {
490             rel.removeMemberByIndex(i);
491           }
492           
493           // add members in new order
494           for each(var memberObject:Object in membersGrid.dataProvider) {
495             var e:Entity;
496             var id:Number = memberObject.id;
497             if(memberObject.type == 'node') {
498               e = conn.getNode(id);
499             } else if (memberObject.type == 'way') {
500               e = conn.getWay(id);
501             } else if (memberObject.type == 'relation') {
502               e = conn.getRelation(id);
503             }
504             rel.appendMember(new RelationMember(e, memberObject.role));
505           }
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           if ( feature != null && feature.hasHelpURL() )
549               navigateToURL(new URLRequest(feature.helpURL), "potlatch_help");
550       }
551
552       public function addNewTag():void {
553           var newKey:String = "(new tag)";
554           var newTag:Tag = new Tag(selectedEntity, newKey, "(new value)");
555           tagDataProvider.addItem(newTag);
556           advancedTagGrid.editedItemPosition = {rowIndex: tagDataProvider.getItemIndex(newTag), columnIndex: 0};
557       }
558
559       public function removeTag():void {
560           var k:String = advancedTagGrid.selectedItem.key;
561           selectedEntity.setTag(k, null, MainUndoStack.getGlobalStack().addAction);
562       }
563       
564       public function addToRelation():void {
565           new RelationSelectPanel().init(selectedEntity,new Object());
566       }
567       
568       public function removeFromRelation(id:Number, index:int):void {
569           Connection.getConnectionInstance().getRelation(id).removeMemberByIndex(index);
570       }
571       
572       public function initFeatureBox():void {
573           tw = new CategorySelector();
574           tw.addEventListener("selectedType", changeFeatureType);
575           popupChange.popUp = tw;
576       }
577       
578       public function changeFeatureType(event:Event):void {
579           if ( selectedEntity == null )
580               return;
581
582           UIComponent.suspendBackgroundProcessing();
583           var newFeature:Feature = tw.selectedType;
584           var undoStack:Function = MainUndoStack.getGlobalStack().addAction;
585           var action:CompositeUndoableAction = new CompositeUndoableAction(
586                   "Set "+selectedEntity.getType()+" "+selectedEntity.id+" to "+newFeature.name);
587                   selectedEntity.suspend();
588
589           // remove tags from the current feature
590           if ( feature != null ) {
591               for each( var oldtag:Object in feature.tags ) {
592                   selectedEntity.setTag(oldtag["k"], null, action.push);
593               }
594           }
595           
596           // set tags for new feature
597           if ( newFeature != null ) {
598               for each( var newtag:Object in newFeature.tags ) {
599                   selectedEntity.setTag(newtag["k"], newtag["v"], action.push);
600               }
601           }
602           
603                   selectedEntity.resume();
604           undoStack(action);
605           popupChange.close();
606           initialiseEditors();
607           UIComponent.resumeBackgroundProcessing();
608       }
609       
610         private function resizePOIGrid(event:Event):void {
611                 var rows:Number=event.target.dataProvider.length/event.target.columnCount;
612                 if (rows!=Math.floor(rows)) { rows=Math.floor(rows+1); }
613                 event.target.height=rows*(event.target.rowHeight+1);
614         }
615   ]]></mx:Script>
616 </mx:VBox>
617