Merge remote-tracking branch 'gravitystorm/mygpx'
authorRichard Fairhurst <richard@systemeD.net>
Sun, 25 Mar 2012 15:32:41 +0000 (16:32 +0100)
committerRichard Fairhurst <richard@systemeD.net>
Sun, 25 Mar 2012 15:32:41 +0000 (16:32 +0100)
net/systemeD/halcyon/connection/Trace.as
net/systemeD/halcyon/connection/XMLConnection.as
net/systemeD/potlatch2/dialogs/MyGpxDialog.mxml
net/systemeD/potlatch2/save/OAuthPanel.mxml

index d3bc0f2d8cb8f6bd325679d2040a6b70b921973e..bf785de8952f0b559240d281f8841c17d1cd364d 100644 (file)
@@ -46,6 +46,7 @@ package net.systemeD.halcyon.connection {
             _id = Number(xml.@id);
             _filename = xml.@name;
             _description = xml.description;
+            tags = [];
             for each(var tag:XML in xml.tag) {
               tags.push(String(tag));
             }
index 2cd5f0958c2b210f8dc1778fa9d4fd53235307d6..30aef5e757b43fdc5f31c30a807ded7bff1e3c6e 100644 (file)
@@ -489,8 +489,13 @@ package net.systemeD.halcyon.connection {
                                function(e:Event):void { 
                        dispatchEvent(new Event(LOAD_COMPLETED));
                                        callback(e);
-                               }, errorOnMapLoad, mapLoadStatus); // needs error handlers
+                               }, errorOnTraceLoad, mapLoadStatus); // needs error handlers
             dispatchEvent(new Event(LOAD_STARTED)); //specifc to map or reusable?
         }
+
+        private function errorOnTraceLoad(event:Event):void {
+            trace("Trace load error");
+            dispatchEvent(new Event(LOAD_COMPLETED));
+        }
        }
 }
index 019ab46561e3be61ddc81a191663fb195f8dbeb4..f024c27eb89fdde2fea8d3879b75597b0bf53c78 100644 (file)
@@ -1,11 +1,45 @@
 <?xml version="1.0" encoding="utf-8"?>
-<mx:TitleWindow
+<s:TitleWindow
         xmlns:fx="http://ns.adobe.com/mxml/2009"
         xmlns:mx="library://ns.adobe.com/flex/mx"
-        layout="vertical" showCloseButton="true"
-        horizontalAlign="center" title="My tracks"
-        width="600" height="400"
-        verticalGap="0">
+        xmlns:s="library://ns.adobe.com/flex/spark"
+        title="My tracks"
+        width="600" height="400">
+
+  <s:layout>
+    <s:VerticalLayout />
+  </s:layout>
+   
+  <s:HGroup width="100%" horizontalAlign="center" verticalAlign="middle" paddingTop="5">
+    <s:RichText text="Traces" id="results" />
+  </s:HGroup>
+  <s:DataGrid dataProvider="{traces}" width="100%" height="100%" id="traceGrid">
+    <s:columns>
+      <s:ArrayCollection>
+        <s:GridColumn editable="false" dataField="id" headerText="id" width="45"/>
+        <s:GridColumn editable="false" dataField="filename" headerText="filename"/>
+        <s:GridColumn editable="false" dataField="description" headerText="description"/>
+        <s:GridColumn editable="false" dataField="tagsText" headerText="tags"/>
+        <s:GridColumn editable="false">
+          <s:itemRenderer>
+            <fx:Component>
+              <s:GridItemRenderer>
+                <s:VGroup horizontalAlign="center" verticalAlign="middle" width="100%" height="100%">
+                  <s:Button label="Load"
+                      click="outerDocument.loadFile(data)"/>
+                </s:VGroup>
+              </s:GridItemRenderer>
+            </fx:Component>
+          </s:itemRenderer>
+        </s:GridColumn>
+      </s:ArrayCollection>
+    </s:columns>
+  </s:DataGrid>
+
+  <s:controlBarContent>
+    <s:Button label="Refresh List" click="fetchList(true)" />
+  </s:controlBarContent>
+
   <fx:Script><![CDATA[
     import mx.managers.PopUpManager;
     import mx.events.CloseEvent;
@@ -29,9 +63,9 @@
         PopUpManager.centerPopUp(this);
         this.addEventListener(CloseEvent.CLOSE, myGpxDialog_close);
 
-               // >>>> REFACTOR: really horrible way of getting both map and connection
+        // >>>> REFACTOR: really horrible way of getting both map and connection
         map = Globals.vars.root;
-               conn = map.editableLayer.connection;
+        conn = map.editableLayer.connection;
 
         conn.addEventListener(Connection.TRACES_LOADED, onTracesLoaded);
         SaveManager.ensureAccess(fetchList, conn);
 
     [Bindable(event="traces_loaded")]
     private function get traces():VectorCollection {
-               return new VectorCollection(conn.getTraces());
+        return new VectorCollection(conn.getTraces().sort(f).reverse());
     }
 
-    public function loadFile(t:Trace):void {
+    private function f(a:Trace, b:Trace):int {
+        return a.id - b.id
+    }
+
+    public function loadFile(o:Object):void {
+        var t:Trace = Trace(o);
         t.addToMap();
     }
 
     }
               ]]>
   </fx:Script>
-
-  <mx:Text text="Traces" id="results" />
-  <mx:DataGrid dataProvider="{traces}" width="100%" height="100%" id="traceGrid">
-    <mx:columns>
-            <mx:DataGridColumn editable="false" dataField="id" headerText="id" width="45"/>
-            <mx:DataGridColumn editable="false" dataField="filename" headerText="filename"/>
-            <mx:DataGridColumn editable="false" dataField="description" headerText="description"/>
-            <mx:DataGridColumn editable="false" dataField="tagsText" headerText="tags"/>
-            <mx:DataGridColumn editable="false">
-              <mx:itemRenderer>
-                <fx:Component>
-                  <mx:VBox>
-                    <mx:Button label="Load"
-                      click="parentDocument.loadFile(data)"/>
-                  </mx:VBox>
-                </fx:Component>
-              </mx:itemRenderer>
-            </mx:DataGridColumn>
-    </mx:columns>
-  </mx:DataGrid>
-  <mx:ControlBar>
-    <mx:Button label="Refresh List" click="fetchList(true)" />
-  </mx:ControlBar>
-</mx:TitleWindow>
\ No newline at end of file
+</s:TitleWindow>
\ No newline at end of file
index f345701fc16f4abda2de5d1123f5687c14e64399..2e629a804e1a2681278164e3c85ccac73c933bf0 100644 (file)
             var urlStr:Object = oauthRequest.buildRequest(sig, OAuthRequest.RESULT_TYPE_URL_STRING)
 
                        //register the "pressTry" function so the oAuth callback page can try to advance the editor directly to the next step
-                       ExternalInterface.addCallback("pressTry", pressTry);            
+            if (ExternalInterface.available) {
+                ExternalInterface.addCallback("pressTry", pressTry);
+            }
                        
             // build the actual request
             var urlReq:URLRequest = new URLRequest(String(urlStr));