Merge remote-tracking branch 'gravitystorm/snapshotserver' into refactor
[potlatch2.git] / net / systemeD / potlatch2 / panels / BackgroundPanel.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2
3 <!--
4     Background Panel
5 -->
6
7 <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" height="100%">
8   <mx:Text id="backgroundPanelText" text="You have selected a Background Feature." width="100%" styleName="helpInfo" />
9   <mx:DataGrid editable="false" id="backgroundPanelDG" width="100%" height="50%">
10     <mx:columns>
11       <mx:DataGridColumn editable="false" dataField="key" headerText="key" />
12       <mx:DataGridColumn editable="false" dataField="value" headerText="value" />
13     </mx:columns>
14   </mx:DataGrid>
15   <mx:Text text="All the data copied to the main layer? Click 'complete'!" />
16   <mx:Button label="Complete" click="markComplete()"/>
17   <mx:Script><![CDATA[
18
19       import net.systemeD.halcyon.connection.*;
20       import net.systemeD.halcyon.MapPaint;
21       import net.systemeD.potlatch2.utils.SnapshotConnection;
22       import mx.collections.*;
23
24       private var selectedEntity:Entity;
25       private var tagDataProvider:ArrayCollection;
26       private var layer:MapPaint;
27
28       public function init(entity:Entity, layer:MapPaint):void {
29             this.layer = layer;
30             if ( tagDataProvider == null ) {
31                 tagDataProvider = new ArrayCollection();
32                 backgroundPanelDG.dataProvider = tagDataProvider;
33             }
34
35             selectedEntity=entity;
36             updateTagDataProvider();
37       }
38
39       private function updateTagDataProvider():void {
40             tagDataProvider.removeAll();
41             if (selectedEntity==null) { return; }
42             var tags:Array = selectedEntity.getTagArray();
43             tags.sortOn("key");
44             for each(var tag:Tag in tags) { tagDataProvider.addItem(tag); }
45       }
46
47       private function markComplete():void {
48             if (selectedEntity.connection is SnapshotConnection) {
49                 SnapshotConnection(selectedEntity.connection).markComplete(selectedEntity);
50             }
51       }
52       ]]>
53   </mx:Script>
54 </mx:VBox>