bdbae0e574b7a610a6280c8046715c59c8a94c4b
[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   <s:RichText id="backgroundPanelText" text="You have selected a Background Feature." />
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       <s:RichText 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       <s:RichText 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.potlatch2.utils.SnapshotConnection;
35       import mx.collections.*;
36
37       private var selectedEntity:Entity;
38       private var tagDataProvider:ArrayCollection;
39       [Bindable]
40       private var connectionName:String;
41
42       public function init(entity:Entity):void {
43           if ( tagDataProvider == null ) {
44               tagDataProvider = new ArrayCollection();
45               backgroundPanelDG.dataProvider = tagDataProvider;
46           }
47
48           selectedEntity=entity;
49           selectedEntity.addEventListener(Connection.STATUS_CHANGED, statusEvent, false, 0, true);
50           connectionName = selectedEntity.connection.name;
51           setStatusStack();
52           updateTagDataProvider();
53       }
54
55       private function updateTagDataProvider():void {
56           tagDataProvider.removeAll();
57           if (selectedEntity==null) { return; }
58           var tags:Array = selectedEntity.getTagArray();
59           tags.sortOn("key");
60           for each(var tag:Tag in tags) { tagDataProvider.addItem(tag); }
61       }
62
63       private function statusEvent(e:Event):void {
64             setStatusStack();
65       }
66
67       private function setStatusStack():void {
68           switch (selectedEntity.status) {
69               case 'incomplete':
70                   statusStack.selectedChild = not_complete;
71                   break;
72               case 'complete':
73                   statusStack.selectedChild = complete;
74                   break;
75               default:
76                   statusStack.selectedChild = empty;
77           }
78       }
79
80       private function markComplete():void {
81           if (selectedEntity.connection is SnapshotConnection) {
82               SnapshotConnection(selectedEntity.connection).markComplete(selectedEntity);
83           }
84       }
85
86       private function markNotComplete():void {
87           if (selectedEntity.connection is SnapshotConnection) {
88               SnapshotConnection(selectedEntity.connection).markNotComplete(selectedEntity);
89           }
90       }
91       ]]>
92   </fx:Script>
93 </mx:VBox>