user-definable function keys for background imagery and stylesheets
[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" 
6         width="500" height="300" verticalGap="0">
7
8   <mx:DataGrid editable="true" width="100%" height="100%" id="dataGrid">
9     <mx:columns>
10         <mx:DataGridColumn editable="true"  dataField="name" headerText="Name"/>
11         <mx:DataGridColumn editable="true"  dataField="url" headerText="URL"/>
12         <mx:DataGridColumn editable="false" headerText="Key" width="70">
13                         <mx:itemRenderer>
14                                 <mx:Component>
15                                 <mx:ComboBox
16                                         selectedItem="{FunctionKeyManager.instance().getKeyFor(outerDocument.title,data.name)}"
17                                     dataProvider="{FunctionKeyManager.fkeysCollection}"
18                                         change="FunctionKeyManager.instance().setKeyFromFString(selectedItem as String,outerDocument.title,data.name)" />
19                                 </mx:Component>
20                         </mx:itemRenderer>
21                 </mx:DataGridColumn>
22     </mx:columns>
23   </mx:DataGrid>
24
25   <mx:HBox horizontalAlign="right" width="100%">
26     <mx:LinkButton label="Delete" click="removeSource()" enabled="{dataGrid.selectedItem != null? true : false}"/>
27     <mx:LinkButton label="Add" click="addNewSource()"/>
28   </mx:HBox>
29
30   <mx:Script><![CDATA[
31
32         /*
33                 Still to do:
34                 - editable source tag for each layer
35                 - editable bbox for each layer
36                 - ability to use this dialogue to select as well as edit
37                 - automatically select imagery once you've edited it (i.e. itemEditEnd)
38                 - edits should stick around, either in SharedObjects or OSM preferences
39         */
40
41     import mx.managers.PopUpManager;
42     import mx.events.CloseEvent;
43     import mx.core.Application;
44         import mx.collections.ArrayCollection;
45         import mx.controls.List;
46         import net.systemeD.potlatch2.FunctionKeyManager;
47
48         public var dataCollection:ArrayCollection;
49         private var menu:List;
50
51     public function init(title:String, menu:List, source:Array):void {
52                 this.title=title;
53                 this.menu=menu;
54                 dataCollection=new ArrayCollection(source);
55         PopUpManager.addPopUp(this, Application(Application.application), true);
56         PopUpManager.centerPopUp(this);
57         this.addEventListener(CloseEvent.CLOSE, backgroundDialog_close);
58                 dataGrid.dataProvider=dataCollection;
59     }
60     
61     private function backgroundDialog_close(evt:CloseEvent):void {
62         PopUpManager.removePopUp(this);
63                 if (menu) { menu.invalidateList(); }
64     }
65
66         private function addNewSource():void {
67                 dataCollection.addItemAt( {name:'(new name)',url:'(new URL)'} , dataCollection.length);
68                 dataGrid.validateNow();
69                 dataGrid.verticalScrollPosition=dataGrid.maxVerticalScrollPosition;
70                 dataGrid.editedItemPosition = {rowIndex: dataCollection.length-1, columnIndex: 0};
71         }
72         private function removeSource():void {
73                 dataCollection.removeItemAt(dataGrid.selectedIndex);
74         }
75
76   ]]>
77   </mx:Script>
78
79 </mx:TitleWindow>