support GPX 1.1 too
[potlatch2.git] / net / systemeD / potlatch2 / BackgroundDialog.mxml
index c8efd81fafb248bb63b2c966802e25ea61997132..580a090ae8c4e550a0980d34679282531a88c5fb 100644 (file)
@@ -5,12 +5,22 @@
         horizontalAlign="center" 
         width="500" height="300" verticalGap="0">
 
-  <mx:DataGrid editable="true" width="100%" height="100%" id="dataGrid">
+  <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="{dataGrid.selectedItem != null? true : false}"/>
@@ -21,7 +31,6 @@
 
        /*
                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
     import mx.core.Application;
        import mx.collections.ArrayCollection;
        import mx.controls.List;
+       import net.systemeD.potlatch2.FunctionKeyManager;
 
        public var dataCollection:ArrayCollection;
        private var menu:List;
+       private var collection:Object;
 
-    public function init(title:String, menu:List, source:Array):void {
+    public function init(title:String, menu:List, source:Object):void {
                this.title=title;
                this.menu=menu;
-               dataCollection=new ArrayCollection(source);
+               collection=source;
+               dataCollection=new ArrayCollection(source.collection);
         PopUpManager.addPopUp(this, Application(Application.application), true);
         PopUpManager.centerPopUp(this);
         this.addEventListener(CloseEvent.CLOSE, backgroundDialog_close);
@@ -54,7 +66,7 @@
     }
 
        private function addNewSource():void {
-               dataCollection.addItemAt( {label:'(new name)',data:'(new URL)'} , dataCollection.length);
+               dataCollection.addItemAt( {name:'(new name)',url:'(new URL)'} , dataCollection.length);
                dataGrid.validateNow();
                dataGrid.verticalScrollPosition=dataGrid.maxVerticalScrollPosition;
                dataGrid.editedItemPosition = {rowIndex: dataCollection.length-1, columnIndex: 0};
@@ -62,6 +74,9 @@
        private function removeSource():void {
                dataCollection.removeItemAt(dataGrid.selectedIndex);
        }
+       public function updateSource():void {
+               collection.dispatchEvent(new Event("collection_changed"));
+       }
 
   ]]>
   </mx:Script>