support GPX 1.1 too
[potlatch2.git] / net / systemeD / potlatch2 / BackgroundDialog.mxml
index 22b9988697c7d5441b3c20f5c48d24374abb4dcb..580a090ae8c4e550a0980d34679282531a88c5fb 100644 (file)
@@ -2,18 +2,28 @@
 <mx:TitleWindow
         xmlns:mx="http://www.adobe.com/2006/mxml" 
         layout="vertical" showCloseButton="true"
-        horizontalAlign="center" title="Background imagery"
+        horizontalAlign="center" 
         width="500" height="300" verticalGap="0">
 
-  <mx:DataGrid editable="true" width="100%" height="100%" id="imageryGrid">
+  <mx:DataGrid editable="true" width="100%" height="100%" id="dataGrid" itemEditEnd="updateSource()">
     <mx:columns>
-        <mx:DataGridColumn editable="true" dataField="label" headerText="Name"/>
-        <mx:DataGridColumn editable="true" dataField="data" headerText="URL"/>
+        <mx:DataGridColumn editable="true"  dataField="name" headerText="Name"/>
+        <mx:DataGridColumn editable="true"  dataField="url" headerText="URL"/>
+        <mx:DataGridColumn editable="false" headerText="Key" width="70">
+                       <mx:itemRenderer>
+                               <mx:Component>
+                               <mx:ComboBox
+                                       selectedItem="{FunctionKeyManager.instance().getKeyFor(outerDocument.title,data.name)}"
+                                   dataProvider="{FunctionKeyManager.fkeysCollection}"
+                                       change="FunctionKeyManager.instance().setKeyFromFString(selectedItem as String,outerDocument.title,data.name)" />
+                               </mx:Component>
+                       </mx:itemRenderer>
+               </mx:DataGridColumn>
     </mx:columns>
-  </mx:DataGrid>        
+  </mx:DataGrid>
 
   <mx:HBox horizontalAlign="right" width="100%">
-    <mx:LinkButton label="Delete" click="removeSource()" enabled="{imageryGrid.selectedItem != null? true : false}"/>
+    <mx:LinkButton label="Delete" click="removeSource()" enabled="{dataGrid.selectedItem != null? true : false}"/>
     <mx:LinkButton label="Add" click="addNewSource()"/>
   </mx:HBox>
 
 
        /*
                Still to do:
-               - editable hotkeys for each layer
                - editable source tag for each layer
                - editable bbox for each layer
                - ability to use this dialogue to select as well as edit
                - automatically select imagery once you've edited it (i.e. itemEditEnd)
-               - save/load imagery sets into OSM preferences
+               - edits should stick around, either in SharedObjects or OSM preferences
        */
 
     import mx.managers.PopUpManager;
     import mx.core.Application;
        import mx.collections.ArrayCollection;
        import mx.controls.List;
+       import net.systemeD.potlatch2.FunctionKeyManager;
 
-       public var imageryCollection:ArrayCollection = new ArrayCollection(Application.application.theController.imagery);
+       public var dataCollection:ArrayCollection;
        private var menu:List;
+       private var collection:Object;
 
-    public function init(menu:List):void {
+    public function init(title:String, menu:List, source:Object):void {
+               this.title=title;
                this.menu=menu;
+               collection=source;
+               dataCollection=new ArrayCollection(source.collection);
         PopUpManager.addPopUp(this, Application(Application.application), true);
         PopUpManager.centerPopUp(this);
         this.addEventListener(CloseEvent.CLOSE, backgroundDialog_close);
-               imageryGrid.dataProvider=imageryCollection;
+               dataGrid.dataProvider=dataCollection;
     }
     
     private function backgroundDialog_close(evt:CloseEvent):void {
     }
 
        private function addNewSource():void {
-               imageryCollection.addItemAt( {label:'(new name)',data:'(new URL)'} , imageryCollection.length);
-               imageryGrid.validateNow();
-               imageryGrid.verticalScrollPosition=imageryGrid.maxVerticalScrollPosition;
-               imageryGrid.editedItemPosition = {rowIndex: imageryCollection.length-1, columnIndex: 0};
+               dataCollection.addItemAt( {name:'(new name)',url:'(new URL)'} , dataCollection.length);
+               dataGrid.validateNow();
+               dataGrid.verticalScrollPosition=dataGrid.maxVerticalScrollPosition;
+               dataGrid.editedItemPosition = {rowIndex: dataCollection.length-1, columnIndex: 0};
        }
        private function removeSource():void {
-               imageryCollection.removeItemAt(imageryGrid.selectedIndex);
+               dataCollection.removeItemAt(dataGrid.selectedIndex);
+       }
+       public function updateSource():void {
+               collection.dispatchEvent(new Event("collection_changed"));
        }
 
   ]]>