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()" dataProvider="{dataCollection}">
11 <mx:DataGridColumn editable="true" dataField="name" headerText="Name"/>
12 <mx:DataGridColumn editable="true" dataField="url" headerText="URL"/>
13 <mx:DataGridColumn editable="false" dataField="name" 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)" />
26 <mx:HBox horizontalAlign="right" width="100%">
27 <mx:LinkButton label="Delete" click="removeSource()" enabled="{dataGrid.selectedItem != null? true : false}"/>
28 <mx:LinkButton label="Add" click="addNewSource()"/>
35 - editable source tag for each layer
36 - editable bbox for each layer
37 - ability to use this dialogue to select as well as edit
38 - automatically select imagery once you've edited it (i.e. itemEditEnd)
39 - edits should stick around, either in SharedObjects or OSM preferences
42 import mx.managers.PopUpManager;
43 import mx.events.CloseEvent;
44 import mx.core.Application;
45 import mx.core.FlexGlobals;
46 import mx.collections.ArrayCollection;
47 import spark.components.List;
48 import net.systemeD.potlatch2.FunctionKeyManager;
50 public var dataCollection:ArrayCollection;
51 private var menu:List;
52 private var collection:Object;
54 public function init(title:String, menu:List, source:Object):void {
58 dataCollection = source.getCollection();
59 PopUpManager.addPopUp(this, Application(FlexGlobals.topLevelApplication), true);
60 PopUpManager.centerPopUp(this);
61 this.addEventListener(CloseEvent.CLOSE, backgroundDialog_close);
64 private function backgroundDialog_close(evt:CloseEvent):void {
65 PopUpManager.removePopUp(this);
68 private function addNewSource():void {
69 dataCollection.addItemAt( {name:'(new name)',url:'(new URL)'} , dataCollection.length);
70 dataGrid.validateNow();
71 dataGrid.verticalScrollPosition=dataGrid.maxVerticalScrollPosition;
72 dataGrid.editedItemPosition = {rowIndex: dataCollection.length-1, columnIndex: 0};
74 private function removeSource():void {
75 dataCollection.removeItemAt(dataGrid.selectedIndex);
77 public function updateSource():void {
78 collection.dispatchEvent(new Event("collection_changed"));