custom imagery dialogue
[potlatch2.git] / net / systemeD / potlatch2 / BackgroundDialog.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2 <mx:TitleWindow
3         xmlns:mx="http://www.adobe.com/2006/mxml" 
4         layout="vertical" showCloseButton="true"
5         horizontalAlign="center" title="Background imagery"
6         width="500" height="300" verticalGap="0">
7
8   <mx:DataGrid editable="true" width="100%" height="100%" id="imageryGrid">
9     <mx:columns>
10         <mx:DataGridColumn editable="true" dataField="label" headerText="Name"/>
11         <mx:DataGridColumn editable="true" dataField="data" headerText="URL"/>
12     </mx:columns>
13   </mx:DataGrid>        
14
15   <mx:HBox horizontalAlign="right" width="100%">
16     <mx:LinkButton label="Delete" click="removeSource()" enabled="{imageryGrid.selectedItem != null? true : false}"/>
17     <mx:LinkButton label="Add" click="addNewSource()"/>
18   </mx:HBox>
19
20   <mx:Script><![CDATA[
21
22         /*
23                 Still to do:
24                 - editable hotkeys for each layer
25                 - editable source tag for each layer
26                 - editable bbox for each layer
27                 - ability to use this dialogue to select as well as edit
28                 - automatically select imagery once you've edited it (i.e. itemEditEnd)
29                 - save/load imagery sets into OSM preferences
30         */
31
32     import mx.managers.PopUpManager;
33     import mx.events.CloseEvent;
34     import mx.core.Application;
35         import mx.collections.ArrayCollection;
36         import mx.controls.List;
37
38         public var imageryCollection:ArrayCollection = new ArrayCollection(Application.application.theController.imagery);
39         private var menu:List;
40
41     public function init(menu:List):void {
42                 this.menu=menu;
43         PopUpManager.addPopUp(this, Application(Application.application), true);
44         PopUpManager.centerPopUp(this);
45         this.addEventListener(CloseEvent.CLOSE, backgroundDialog_close);
46                 imageryGrid.dataProvider=imageryCollection;
47     }
48     
49     private function backgroundDialog_close(evt:CloseEvent):void {
50         PopUpManager.removePopUp(this);
51                 if (menu) { menu.invalidateList(); }
52     }
53
54         private function addNewSource():void {
55                 imageryCollection.addItemAt( {label:'(new name)',data:'(new URL)'} , imageryCollection.length);
56                 imageryGrid.validateNow();
57                 imageryGrid.verticalScrollPosition=imageryGrid.maxVerticalScrollPosition;
58                 imageryGrid.editedItemPosition = {rowIndex: imageryCollection.length-1, columnIndex: 0};
59         }
60         private function removeSource():void {
61                 imageryCollection.removeItemAt(imageryGrid.selectedIndex);
62         }
63
64   ]]>
65   </mx:Script>
66
67 </mx:TitleWindow>