1 <?xml version="1.0" encoding="utf-8"?>
3 xmlns:fx="http://ns.adobe.com/mxml/2009"
4 xmlns:mx="library://ns.adobe.com/flex/mx"
5 layout="vertical" showCloseButton="true"
6 horizontalAlign="center"
7 width="500" height="300" verticalGap="0">
9 <mx:DataGrid editable="true" width="100%" height="100%" id="dataGrid" itemEditEnd="updateSource()">
11 <mx:DataGridColumn editable="true" dataField="name" headerText="Name"/>
12 <mx:DataGridColumn editable="true" dataField="url" headerText="URL"/>
13 <mx:DataGridColumn editable="false" headerText="Key" width="70">
17 selectedItem="{FunctionKeyManager.instance().getKeyFor(outerDocument.title,data.name)}"
18 dataProvider="{FunctionKeyManager.fkeysCollection}"
19 change="FunctionKeyManager.instance().setKeyFromFString(selectedItem as String,outerDocument.title,data.name)">
20 <fx:Script><![CDATA[ import net.systemeD.potlatch2.FunctionKeyManager; ]]></fx:Script>
28 <mx:HBox horizontalAlign="right" width="100%">
29 <mx:LinkButton label="Delete" click="removeSource()" enabled="{dataGrid.selectedItem != null? true : false}"/>
30 <mx:LinkButton label="Add" click="addNewSource()"/>
37 - editable source tag for each layer
38 - editable bbox for each layer
39 - ability to use this dialogue to select as well as edit
40 - automatically select imagery once you've edited it (i.e. itemEditEnd)
41 - edits should stick around, either in SharedObjects or OSM preferences
44 import mx.managers.PopUpManager;
45 import mx.events.CloseEvent;
46 import mx.core.Application;
47 import mx.core.FlexGlobals;
48 import mx.collections.ArrayCollection;
49 import mx.controls.List;
50 import net.systemeD.potlatch2.FunctionKeyManager;
52 public var dataCollection:ArrayCollection;
53 private var menu:List;
54 private var collection:Object;
56 public function init(title:String, menu:List, source:Object):void {
60 dataCollection=new ArrayCollection(source.collection);
61 PopUpManager.addPopUp(this, Application(FlexGlobals.topLevelApplication), true);
62 PopUpManager.centerPopUp(this);
63 this.addEventListener(CloseEvent.CLOSE, backgroundDialog_close);
64 dataGrid.dataProvider=dataCollection;
67 private function backgroundDialog_close(evt:CloseEvent):void {
68 PopUpManager.removePopUp(this);
69 if (menu) { menu.invalidateList(); }
72 private function addNewSource():void {
73 dataCollection.addItemAt( {name:'(new name)',url:'(new URL)'} , dataCollection.length);
74 dataGrid.validateNow();
75 dataGrid.verticalScrollPosition=dataGrid.maxVerticalScrollPosition;
76 dataGrid.editedItemPosition = {rowIndex: dataCollection.length-1, columnIndex: 0};
78 private function removeSource():void {
79 dataCollection.removeItemAt(dataGrid.selectedIndex);
81 public function updateSource():void {
82 collection.dispatchEvent(new Event("collection_changed"));