1 <?xml version="1.0" encoding="utf-8"?>
3 xmlns:mx="http://www.adobe.com/2006/mxml"
4 layout="vertical" showCloseButton="true"
5 horizontalAlign="center" title="MyGpx Files"
6 width="600" height="400"
9 import mx.managers.PopUpManager;
10 import mx.events.CloseEvent;
11 import mx.core.Application;
13 import net.systemeD.halcyon.connection.*;
14 import net.systemeD.potlatch2.save.*;
15 import net.systemeD.halcyon.Map;
16 import net.systemeD.halcyon.Globals;
17 import net.systemeD.potlatch2.utils.Importer;
18 import net.systemeD.potlatch2.utils.GpxImporter;
19 import mx.controls.Alert;
22 private var conn:Connection;
24 public function init():void {
25 PopUpManager.addPopUp(this, Application(Application.application), true);
26 PopUpManager.centerPopUp(this);
27 this.addEventListener(CloseEvent.CLOSE, myGpxDialog_close);
29 // >>>> REFACTOR: really horrible way of getting both map and connection
30 map = Globals.vars.root;
31 conn = map.editableLayer.connection;
33 conn.addEventListener(Connection.TRACES_LOADED, onTracesLoaded);
34 SaveManager.ensureAccess(fetchList, conn);
37 private function myGpxDialog_close(evt:CloseEvent):void {
38 PopUpManager.removePopUp(this);
39 conn.removeEventListener(Connection.TRACES_LOADED, onTracesLoaded);
42 private function fetchList(refresh:Boolean=false):void {
43 results.text = "Fetching Traces...";
44 conn.fetchUserTraces(refresh);
47 private function onTracesLoaded(e:Event):void {
48 results.text = "Traces Loaded";
49 dispatchEvent(new Event("traces_loaded"));
52 [Bindable(event="traces_loaded")]
53 private function get traces():Array {
54 return conn.getTraces();
57 public function loadFile(t:Trace):void {
61 public function filesLoaded(success:Boolean,message:String=null):void {
63 dispatchEvent(new Event("layers_changed"));
65 Alert.show(message, 'Error', mx.controls.Alert.OK);
71 <mx:Text text="Traces" id="results" />
72 <mx:DataGrid dataProvider="{traces}" width="100%" height="100%" id="traceGrid">
74 <mx:DataGridColumn editable="false" dataField="id" headerText="id" width="45"/>
75 <mx:DataGridColumn editable="false" dataField="filename" headerText="filename"/>
76 <mx:DataGridColumn editable="false" dataField="description" headerText="description"/>
77 <mx:DataGridColumn editable="false" dataField="tagsText" headerText="tags"/>
78 <mx:DataGridColumn editable="false">
82 <mx:Button label="Load"
83 click="parentDocument.loadFile(data)"/>
91 <mx:Button label="Refresh List" click="fetchList(true)" />