Show the background layer name.
[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
8     xmlns:fx="http://ns.adobe.com/mxml/2009"
9     xmlns:mx="library://ns.adobe.com/flex/mx"
10     xmlns:s="library://ns.adobe.com/flex/spark"
11     height="100%">
12   <mx:Text id="backgroundPanelText" text="You have selected a Background Feature." width="100%" styleName="helpInfo" />
13   <s:RichText text="{connectionName}" />
14   <mx:DataGrid editable="false" id="backgroundPanelDG" width="100%" height="50%">
15     <mx:columns>
16       <mx:DataGridColumn editable="false" dataField="key" headerText="key" />
17       <mx:DataGridColumn editable="false" dataField="value" headerText="value" />
18     </mx:columns>
19   </mx:DataGrid>
20   <mx:ViewStack id="statusStack" resizeToContent="true" width="100%">
21     <mx:VBox id="empty" />
22     <mx:VBox id="not_complete">
23       <mx:Text text="All the data copied to the main layer? Click 'complete'!" />
24       <mx:Button label="Complete" click="markComplete()"/>
25     </mx:VBox>
26     <mx:VBox id="complete">
27       <mx:Text text="This feature has been marked as complete. If this is wrong, press the button below." />
28       <mx:Button label="Not complete" click="markNotComplete()"/>
29     </mx:VBox>
30   </mx:ViewStack>
31   <fx:Script><![CDATA[
32
33       import net.systemeD.halcyon.connection.*;
34       import net.systemeD.halcyon.MapPaint;
35       import net.systemeD.potlatch2.utils.SnapshotConnection;
36       import mx.collections.*;
37
38       private var selectedEntity:Entity;
39       private var tagDataProvider:ArrayCollection;
40       private var layer:MapPaint;
41       [Bindable]
42       private var connectionName:String;
43
44       public function init(entity:Entity, layer:MapPaint):void {
45           this.layer = layer;
46           if ( tagDataProvider == null ) {
47               tagDataProvider = new ArrayCollection();
48               backgroundPanelDG.dataProvider = tagDataProvider;
49           }
50
51           selectedEntity=entity;
52           selectedEntity.addEventListener(Connection.STATUS_CHANGED, statusEvent, false, 0, true);
53           connectionName = selectedEntity.connection.name;
54           setStatusStack();
55           updateTagDataProvider();
56       }
57
58       private function updateTagDataProvider():void {
59           tagDataProvider.removeAll();
60           if (selectedEntity==null) { return; }
61           var tags:Array = selectedEntity.getTagArray();
62           tags.sortOn("key");
63           for each(var tag:Tag in tags) { tagDataProvider.addItem(tag); }
64       }
65
66       private function statusEvent(e:Event):void {
67             setStatusStack();
68       }
69
70       private function setStatusStack():void {
71           switch (selectedEntity.status) {
72               case 'incomplete':
73                   statusStack.selectedChild = not_complete;
74                   break;
75               case 'complete':
76                   statusStack.selectedChild = complete;
77                   break;
78               default:
79                   statusStack.selectedChild = empty;
80           }
81       }
82
83       private function markComplete():void {
84           if (selectedEntity.connection is SnapshotConnection) {
85               SnapshotConnection(selectedEntity.connection).markComplete(selectedEntity);
86           }
87       }
88
89       private function markNotComplete():void {
90           if (selectedEntity.connection is SnapshotConnection) {
91               SnapshotConnection(selectedEntity.connection).markNotComplete(selectedEntity);
92           }
93       }
94       ]]>
95   </fx:Script>
96 </mx:VBox>