Update history dialog with new Connection and Entity syntax
authorAndy Allan <andy@gravitystorm.co.uk>
Wed, 22 Jun 2011 16:12:43 +0000 (17:12 +0100)
committerAndy Allan <andy@gravitystorm.co.uk>
Wed, 22 Jun 2011 16:12:43 +0000 (17:12 +0100)
net/systemeD/halcyon/connection/XMLBaseConnection.as
net/systemeD/halcyon/connection/XMLConnection.as
net/systemeD/potlatch2/controller/ControllerState.as
net/systemeD/potlatch2/history/HistoryDialog.mxml

index 9d05aa0aa5c95749241dd389fd773e8e8f86795a..8ba3233c67bab61a809c2ecdaa1c023d6172bb35 100644 (file)
@@ -174,7 +174,7 @@ package net.systemeD.halcyon.connection {
                        }
                }
 
-               private function parseTags(tagElements:XMLList):Object {
+               protected function parseTags(tagElements:XMLList):Object {
                        var tags:Object = {};
                        for each (var tagEl:XML in tagElements)
                                tags[tagEl.@k] = tagEl.@v;
index 6d3abe547d76ade7d0bb246b0027dcf2ea88629f..37f72c41ca7df8ee1b9d3c725118e09d0171496a 100644 (file)
@@ -464,7 +464,7 @@ package net.systemeD.halcyon.connection {
         /** Fetch the history for the given entity. The callback function will be given an array of entities of that type, representing the different versions */
         override public function fetchHistory(entity:Entity, callback:Function):void {
             if (entity.id >= 0) {
-              var request:URLRequest = new URLRequest(Connection.apiBaseURL + entity.getType() + "/" + entity.id + "/history");
+              var request:URLRequest = new URLRequest(apiBaseURL + entity.getType() + "/" + entity.id + "/history");
               var loader:ExtendedURLLoader = new ExtendedURLLoader();
               loader.addEventListener(Event.COMPLETE, loadedHistory);
               loader.addEventListener(IOErrorEvent.IO_ERROR, errorOnMapLoad); //needs error handlers
@@ -481,11 +481,13 @@ package net.systemeD.halcyon.connection {
         private function loadedHistory(event:Event):void {
             var _xml:XML = new XML(ExtendedURLLoader(event.target).data);
             var results:Array = [];
+            var dummyConn:Connection = new Connection("dummy", null, null);
 
             // only one type of entity should be returned, but this handles any
 
             for each(var nodeData:XML in _xml.node) {
                 var newNode:Node = new Node(
+                    dummyConn,
                     Number(nodeData.@id),
                     uint(nodeData.@version),
                     parseTags(nodeData.tag),
@@ -502,9 +504,10 @@ package net.systemeD.halcyon.connection {
             for each(var wayData:XML in _xml.way) {
                 var nodes:Array = [];
                 for each(var nd:XML in wayData.nd) {
-                  nodes.push(new Node(Number(nd.@ref), NaN, null, false, NaN, NaN));
+                  nodes.push(new Node(dummyConn,Number(nd.@ref), NaN, null, false, NaN, NaN));
                 }
                 var newWay:Way = new Way(
+                    dummyConn,
                     Number(wayData.@id),
                     uint(wayData.@version),
                     parseTags(wayData.tag),
index 06c50e728325317022ca26d71a8cf2cfd82be3dc..b5e0e35a429047493dc34a564ffab2a6d310f1e7 100644 (file)
@@ -204,9 +204,9 @@ package net.systemeD.potlatch2.controller {
             if (selectCount == 1) {
                 new HistoryDialog().init(firstSelected);
             } else if (selectCount == 0) {
-                map.connection.dispatchEvent(new AttentionEvent(AttentionEvent.ALERT, null, "Can't show history, nothing selected"));
+                controller.dispatchEvent(new AttentionEvent(AttentionEvent.ALERT, null, "Can't show history, nothing selected"));
             } else {
-                map.connection.dispatchEvent(new AttentionEvent(AttentionEvent.ALERT, null, "Can't show history, multiple objects selected"));
+                controller.dispatchEvent(new AttentionEvent(AttentionEvent.ALERT, null, "Can't show history, multiple objects selected"));
             }
         }
 
index 314ff3c834f49a6a6345a06c2d54c26da6f24ccb..5f41f87c2190a46ba10a6549338123a5d2bdc268 100644 (file)
     private function openEntityPage():void {
         if (entity != null && entity.id >= 0) {
             // This is slightly hard-coded, but not drastically. The ../s could be changed for string manipulation of the apiBase
-            var urlBase:String = Connection.getConnectionInstance().apiBase + '../../browse/';
+            var urlBase:String = entity.connection.apiBase + '../../browse/';
             navigateToURL(new URLRequest(urlBase+entity.getType()+'/'+entity.id), "potlatch_browse");
         }
     }
 
     private function fetchHistory():void {
         if (entity is Node) {
-            Connection.getConnection().fetchHistory(entity, processNode);
+            entity.connection.fetchHistory(entity, processNode);
         } else if (entity is Way) {
-            Connection.getConnection().fetchHistory(entity, processWay);
+            entity.connection.fetchHistory(entity, processWay);
         } else {
             // not implemented
         }
         pendingNodeFetches = count;
 
         for each (var n:Node in nodes) {
-            Connection.getConnection().fetchHistory(n, pendingNode);
+            entity.connection.fetchHistory(n, pendingNode);
         }
     }
 
 
     public function message(entity:Entity):void {
         if (entity.user != null) {
-            var urlBase:String = Connection.getConnectionInstance().apiBase + '../../message/new/';
+            var urlBase:String = entity.connection.apiBase + '../../message/new/';
             navigateToURL(new URLRequest(urlBase+entity.user), "potlatch_message");
         }
     }