Merge branch 'refactor'
authorRichard Fairhurst <richard@systemeD.net>
Fri, 17 Jun 2011 17:36:52 +0000 (18:36 +0100)
committerRichard Fairhurst <richard@systemeD.net>
Fri, 17 Jun 2011 17:36:52 +0000 (18:36 +0100)
1  2 
net/systemeD/halcyon/connection/XMLBaseConnection.as
net/systemeD/halcyon/connection/XMLConnection.as
net/systemeD/potlatch2/mapfeatures/editors/TurnRestrictionIcon.mxml

index 4910bb50a5237679c59eae17c0ab8f48aaeb39ce,d2e5164ea0601f221f28d930abc4d8428af4e8dd..c94a8572b2533e01f1544551babdd4fa52b190f7
  package net.systemeD.halcyon.connection {
  
--    import flash.events.*;
++      import flash.events.*;
  
        import flash.system.Security;
        import flash.net.*;
--    import org.iotashan.oauth.*;
++      import org.iotashan.oauth.*;
  
-     import net.systemeD.halcyon.MapEvent;
 -    /**
 -    * XMLBaseConnection is the common code between connecting to an OSM server
 -    * (i.e. XMLConnection) and connecting to a standalone .osm file (i.e. OSMConnection)
 -    * and so mainly concerns itself with /map -call-ish related matters
 -    */
++      import net.systemeD.halcyon.MapEvent;
 +
-     /**
-     * XMLBaseConnection is the common code between connecting to an OSM server
-     * (i.e. XMLConnection) and connecting to a standalone .osm file (i.e. OSMConnection)
-     * and so mainly concerns itself with /map -call-ish related matters
-     */
++      /**
++      * XMLBaseConnection is the common code between connecting to an OSM server
++      * (i.e. XMLConnection) and connecting to a standalone .osm file (i.e. OSMConnection)
++      * and so mainly concerns itself with /map -call-ish related matters
++      */
        public class XMLBaseConnection extends Connection {
  
-               public function XMLBaseConnection() {
+               public function XMLBaseConnection(name:String,api:String,policy:String,initparams:Object) {
+                       super(name,api,policy,initparams);
                }
                
--        protected function loadedMap(event:Event):void {
--            var map:XML = new XML(URLLoader(event.target).data);
-             
 -            var id:Number;
 -            var version:uint;
 -            var uid:Number;
 -            var timestamp:String;
 -            var tags:Object;
 -            var node:Node, newNode:Node;
 -            var unusedNodes:Object={};
 -                      var createdEntities:Array=[];
++              protected function loadedMap(event:Event):void {
++                      var map:XML = new XML(URLLoader(event.target).data);
++                      
 +                      if (map.localName=="osmError") {
-                 dispatchEvent(new MapEvent(MapEvent.ERROR, { message: "Couldn't load the map: " + map.message } ));
++                              dispatchEvent(new MapEvent(MapEvent.ERROR, { message: "Couldn't load the map: " + map.message } ));
 +                      } else {
-                 var id:Number;
-                 var version:uint;
-                 var uid:Number;
-                 var timestamp:String;
-                 var tags:Object;
-                 var node:Node, newNode:Node;
-                 var unusedNodes:Object={};
++                              var id:Number;
++                              var version:uint;
++                              var uid:Number;
++                              var timestamp:String;
++                              var tags:Object;
++                              var node:Node, newNode:Node;
++                              var unusedNodes:Object={};
++                              var createdEntities:Array=[];
  
-                       var minlon:Number, maxlon:Number, minlat:Number, maxlat:Number;
-                       var singleEntityRequest:Boolean=true;
-                       if (map.bounds.@minlon.length()) {
-                               minlon=map.bounds.@minlon;
-                               maxlon=map.bounds.@maxlon;
-                               minlat=map.bounds.@minlat;
-                               maxlat=map.bounds.@maxlat;
-                               singleEntityRequest=false;
-                       }
 -                      var minlon:Number, maxlon:Number, minlat:Number, maxlat:Number;
 -                      var singleEntityRequest:Boolean=true;
 -                      if (map.bounds.@minlon.length()) {
 -                              minlon=map.bounds.@minlon;
 -                              maxlon=map.bounds.@maxlon;
 -                              minlat=map.bounds.@minlat;
 -                              maxlat=map.bounds.@maxlat;
 -                              singleEntityRequest=false;
 -                      }
++                              var minlon:Number, maxlon:Number, minlat:Number, maxlat:Number;
++                              var singleEntityRequest:Boolean=true;
++                              if (map.bounds.@minlon.length()) {
++                                      minlon=map.bounds.@minlon;
++                                      maxlon=map.bounds.@maxlon;
++                                      minlat=map.bounds.@minlat;
++                                      maxlat=map.bounds.@maxlat;
++                                      singleEntityRequest=false;
++                              }
  
-                 for each(var relData:XML in map.relation) {
-                     id = Number(relData.@id);
-                     version = uint(relData.@version);
-                     uid = Number(relData.@uid);
-                     timestamp = relData.@timestamp;
 -            for each(var relData:XML in map.relation) {
 -                id = Number(relData.@id);
 -                version = uint(relData.@version);
 -                uid = Number(relData.@uid);
 -                timestamp = relData.@timestamp;
--                
-                     var rel:Relation = getRelation(id);
-                     if ( rel == null || !rel.loaded || singleEntityRequest ) {
-                         tags = parseTags(relData.tag);
-                         var members:Array = [];
-                         for each(var memberXML:XML in relData.member) {
-                             var type:String = memberXML.@type.toLowerCase();
-                             var role:String = memberXML.@role;
-                             var memberID:Number = Number(memberXML.@ref);
-                             var member:Entity = null;
-                             if ( type == "node" ) {
-                                 member = getNode(memberID);
-                                 if ( member == null ) {
-                                     member = new Node(memberID,0,{},false,0,0);
-                                     setNode(Node(member),true);
-                                 } else if (member.isDeleted()) {
-                                     member.setDeletedState(false);
-                                 }
-                             } else if ( type == "way" ) {
-                                 member = getWay(memberID);
-                                 if (member == null) {
-                                     member = new Way(memberID,0,{},false,[]);
-                                     setWay(Way(member),true);
-                                 }
-                             } else if ( type == "relation" ) {
-                                 member = getRelation(memberID);
-                                 if (member == null) {
-                                     member = new Relation(memberID,0,{},false,[]);
-                                     setRelation(Relation(member),true);
-                                 }
 -                var rel:Relation = getRelation(id);
 -                if ( rel == null || !rel.loaded ) {
 -                    tags = parseTags(relData.tag);
 -                    var members:Array = [];
 -                    for each(var memberXML:XML in relData.member) {
 -                        var type:String = memberXML.@type.toLowerCase();
 -                        var role:String = memberXML.@role;
 -                        var memberID:Number = Number(memberXML.@ref);
 -                        var member:Entity = null;
 -                        if ( type == "node" ) {
 -                            member = getNode(memberID);
 -                            if ( member == null ) {
 -                                member = new Node(this,memberID,0,{},false,0,0);
 -                                setNode(Node(member),true);
 -                            } else if (member.isDeleted()) {
 -                                member.setDeletedState(false);
--                            }
-                         
-                             if ( member != null )
-                                 members.push(new RelationMember(member, role));
 -                        } else if ( type == "way" ) {
 -                            member = getWay(memberID);
 -                            if (member == null) {
 -                                member = new Way(this,memberID,0,{},false,[]);
 -                                setWay(Way(member),true);
 -                            }
 -                        } else if ( type == "relation" ) {
 -                            member = getRelation(memberID);
 -                            if (member == null) {
 -                                member = new Relation(this,memberID,0,{},false,[]);
 -                                setRelation(Relation(member),true);
 -                            }
--                        }
 -                        
 -                        if ( member != null )
 -                            members.push(new RelationMember(member, role));
 -                    }
--                    
-                         if ( rel == null )
-                             setRelation(new Relation(id, version, tags, true, members, uid, timestamp), false);
-                         else {
-                             rel.update(version, tags, true, false, members, uid, timestamp);
-                             sendEvent(new EntityEvent(NEW_RELATION, rel), false);
-                         }
 -                    if ( rel == null ) {
 -                        rel=new Relation(this, id, version, tags, true, members, uid, timestamp);
 -                        setRelation(rel, false);
 -                        createdEntities.push(rel);
 -                    } else {
 -                        rel.update(version, tags, true, false, members, uid, timestamp);
 -                        sendEvent(new EntityEvent(NEW_RELATION, rel), false);
--                    }
--                }
 -            }
++                              for each(var relData:XML in map.relation) {
++                                      id = Number(relData.@id);
++                                      version = uint(relData.@version);
++                                      uid = Number(relData.@uid);
++                                      timestamp = relData.@timestamp;
++                         
++                                      var rel:Relation = getRelation(id);
++                                      if ( rel == null || !rel.loaded || singleEntityRequest ) {
++                                              tags = parseTags(relData.tag);
++                                              var members:Array = [];
++                                              for each(var memberXML:XML in relData.member) {
++                                                      var type:String = memberXML.@type.toLowerCase();
++                                                      var role:String = memberXML.@role;
++                                                      var memberID:Number = Number(memberXML.@ref);
++                                                      var member:Entity = null;
++                                                      if ( type == "node" ) {
++                                                              member = getNode(memberID);
++                                                              if ( member == null ) {
++                                                                      member = new Node(this,memberID,0,{},false,0,0);
++                                                                      setNode(Node(member),true);
++                                                              } else if (member.isDeleted()) {
++                                                                      member.setDeletedState(false);
++                                                              }
++                                                      } else if ( type == "way" ) {
++                                                              member = getWay(memberID);
++                                                              if (member == null) {
++                                                                      member = new Way(this,memberID,0,{},false,[]);
++                                                                      setWay(Way(member),true);
++                                                              }
++                                                      } else if ( type == "relation" ) {
++                                                              member = getRelation(memberID);
++                                                              if (member == null) {
++                                                                      member = new Relation(this,memberID,0,{},false,[]);
++                                                                      setRelation(Relation(member),true);
++                                                              }
++                                                      }
++                                              
++                                                      if ( member != null )
++                                                              members.push(new RelationMember(member, role));
++                                              }
++                                      
++                                              if ( rel == null ) {
++                                                      rel=new Relation(this, id, version, tags, true, members, uid, timestamp);
++                                                      setRelation(rel, false);
++                                                      createdEntities.push(rel);
++                                              } else {
++                                                      rel.update(version, tags, true, false, members, uid, timestamp);
++                                                      sendEvent(new EntityEvent(NEW_RELATION, rel), false);
++                                              }
++                                      }
++                              }
  
-                 for each(var nodeData:XML in map.node) {
-                               id = Number(nodeData.@id);
-                               node = getNode(id);
-                               newNode = new Node(id, 
-                                                  uint(nodeData.@version), 
-                                                  parseTags(nodeData.tag),
-                                                  true, 
-                                                  Number(nodeData.@lat),
-                                                  Number(nodeData.@lon),
-                                                  Number(nodeData.@uid),
-                                                  nodeData.@timestamp);
 -            for each(var nodeData:XML in map.node) {
 -                              id = Number(nodeData.@id);
 -                              node = getNode(id);
 -                              newNode = new Node(this,
 -                                                 id, 
 -                                                 uint(nodeData.@version), 
 -                                                 parseTags(nodeData.tag),
 -                                                 true, 
 -                                                 Number(nodeData.@lat),
 -                                                 Number(nodeData.@lon),
 -                                                 Number(nodeData.@uid),
 -                                                 nodeData.@timestamp);
++                              for each(var nodeData:XML in map.node) {
++                                      id = Number(nodeData.@id);
++                                      node = getNode(id);
++                                      newNode = new Node(this,
++                                                                         id, 
++                                                                         uint(nodeData.@version), 
++                                                                         parseTags(nodeData.tag),
++                                                                         true, 
++                                                                         Number(nodeData.@lat),
++                                                                         Number(nodeData.@lon),
++                                                                         Number(nodeData.@uid),
++                                                                         nodeData.@timestamp);
                                
-                               if ( singleEntityRequest ) {
-                                       // it's a revert request, so create/update the node
-                                       setOrUpdateNode(newNode, true);
-                               } else if ( node == null || !node.loaded) {
-                                       // the node didn't exist before, so create/update it
-                                       newNode.parentsLoaded=newNode.within(minlon,maxlon,minlat,maxlat);
-                                       setOrUpdateNode(newNode, true);
-                               } else {
-                                       // the node's already in memory, but store it in case one of the new ways needs it
-                                       if (newNode.within(minlon,maxlon,minlat,maxlat)) newNode.parentsLoaded=true;
-                                       unusedNodes[id]=newNode;
-                               }
-                       }
-             
-                 for each(var data:XML in map.way) {
-                     id = Number(data.@id);
-                     version = uint(data.@version);
-                     uid = Number(data.@uid);
-                     timestamp = data.@timestamp;
 -                              if ( singleEntityRequest ) {
 -                                      // it's a revert request, so create/update the node
 -                                      setOrUpdateNode(newNode, true);
 -                              } else if ( node == null || !node.loaded) {
 -                                      // the node didn't exist before, so create/update it
 -                                      newNode.parentsLoaded=newNode.within(minlon,maxlon,minlat,maxlat);
 -                                      setOrUpdateNode(newNode, true);
 -                                      createdEntities.push(newNode);
 -                              } else {
 -                                      // the node's already in memory, but store it in case one of the new ways needs it
 -                                      if (newNode.within(minlon,maxlon,minlat,maxlat)) newNode.parentsLoaded=true;
 -                                      unusedNodes[id]=newNode;
++                                      if ( singleEntityRequest ) {
++                                              // it's a revert request, so create/update the node
++                                              setOrUpdateNode(newNode, true);
++                                      } else if ( node == null || !node.loaded) {
++                                              // the node didn't exist before, so create/update it
++                                              newNode.parentsLoaded=newNode.within(minlon,maxlon,minlat,maxlat);
++                                              setOrUpdateNode(newNode, true);
++                                              createdEntities.push(newNode);
++                                      } else {
++                                              // the node's already in memory, but store it in case one of the new ways needs it
++                                              if (newNode.within(minlon,maxlon,minlat,maxlat)) newNode.parentsLoaded=true;
++                                              unusedNodes[id]=newNode;
++                                      }
+                               }
 -                      }
 -            
 -            for each(var data:XML in map.way) {
 -                id = Number(data.@id);
 -                version = uint(data.@version);
 -                uid = Number(data.@uid);
 -                timestamp = data.@timestamp;
++                      
++                              for each(var data:XML in map.way) {
++                                      id = Number(data.@id);
++                                      version = uint(data.@version);
++                                      uid = Number(data.@uid);
++                                      timestamp = data.@timestamp;
  
-                     var way:Way = getWay(id);
-                     if ( way == null || !way.loaded || singleEntityRequest) {
-                         var nodes:Array = [];
-                         for each(var nd:XML in data.nd) {
-                                               var nodeid:Number=Number(nd.@ref)
-                                               if (getNode(nodeid).isDeleted() && unusedNodes[nodeid]) { 
-                                                       setOrUpdateNode(unusedNodes[nodeid], true); 
-                                               }
-                             nodes.push(getNode(nodeid));
-                                       }
-                         tags = parseTags(data.tag);
-                         if ( way == null ) {
-                             setWay(new Way(id, version, tags, true, nodes, uid, timestamp),false);
-                         } else {
-                                               waycount++;
-                             way.update(version, tags, true, true, nodes, uid, timestamp);
-                             sendEvent(new EntityEvent(NEW_WAY, way), false);
-                         }
-                     }
-                 }
-             
-                 markBboxLoaded(minlon,maxlon,maxlat,minlat);
-                 registerPOINodes();
-             }
 -                var way:Way = getWay(id);
 -                if ( way == null || !way.loaded || singleEntityRequest) {
 -                    var nodelist:Array = [];
 -                    for each(var nd:XML in data.nd) {
 -                                              var nodeid:Number=Number(nd.@ref)
 -                                              if (getNode(nodeid).isDeleted() && unusedNodes[nodeid]) { 
 -                                                      setOrUpdateNode(unusedNodes[nodeid], true); 
++                                      var way:Way = getWay(id);
++                                      if ( way == null || !way.loaded || singleEntityRequest) {
++                                              var nodelist:Array = [];
++                                              for each(var nd:XML in data.nd) {
++                                                      var nodeid:Number=Number(nd.@ref)
++                                                      if (getNode(nodeid).isDeleted() && unusedNodes[nodeid]) { 
++                                                              setOrUpdateNode(unusedNodes[nodeid], true); 
++                                                      }
++                                                      nodelist.push(getNode(nodeid));
++                                              }
++                                              tags = parseTags(data.tag);
++                                              if ( way == null ) {
++                                                      way=new Way(this, id, version, tags, true, nodelist, uid, timestamp)
++                                                      setWay(way,false);
++                                                      createdEntities.push(way);
++                                              } else {
++                                                      waycount++;
++                                                      way.update(version, tags, true, true, nodelist, uid, timestamp);
++                                                      sendEvent(new EntityEvent(NEW_WAY, way), false);
+                                               }
 -                        nodelist.push(getNode(nodeid));
+                                       }
 -                    tags = parseTags(data.tag);
 -                    if ( way == null ) {
 -                        way=new Way(this, id, version, tags, true, nodelist, uid, timestamp)
 -                        setWay(way,false);
 -                        createdEntities.push(way);
 -                    } else {
 -                                              waycount++;
 -                        way.update(version, tags, true, true, nodelist, uid, timestamp);
 -                        sendEvent(new EntityEvent(NEW_WAY, way), false);
 -                    }
 -                }
 -            }
 -            
 -            markBboxLoaded(minlon,maxlon,maxlat,minlat);
 -            registerPOINodes();
 -            dispatchEvent(new Event(LOAD_COMPLETED));
++                              }
++                      
++                              markBboxLoaded(minlon,maxlon,maxlat,minlat);
++                              registerPOINodes();
++                      }
  
-             dispatchEvent(new Event(LOAD_COMPLETED));
 -            if (statusFetcher) statusFetcher.fetch(createdEntities); 
--        }
--        
--        protected function registerPOINodes():void {
--            for each (var nodeID:Number in getAllNodeIDs()) {
--                var node:Node = getNode(nodeID);
--                if (!node.hasParentWays)
--                    registerPOI(node);
--            }
--        }
++                      dispatchEvent(new Event(LOAD_COMPLETED));
  
--        private function parseTags(tagElements:XMLList):Object {
--            var tags:Object = {};
--            for each (var tagEl:XML in tagElements)
--                tags[tagEl.@k] = tagEl.@v;
--            return tags;
--        }
++                      if (statusFetcher) statusFetcher.fetch(createdEntities); 
++              }
++              
++              protected function registerPOINodes():void {
++                      for each (var nodeID:Number in getAllNodeIDs()) {
++                              var node:Node = getNode(nodeID);
++                              if (!node.hasParentWays)
++                                      registerPOI(node);
++                      }
++              }
++
++              private function parseTags(tagElements:XMLList):Object {
++                      var tags:Object = {};
++                      for each (var tagEl:XML in tagElements)
++                              tags[tagEl.@k] = tagEl.@v;
++                      return tags;
++              }
  
        }
  }
index 7fe45ec751d2346cc6cc62acbefdb58859e08f2d,d87d87eed958aa92705f8eb76bdf2e650be1cb48..3a4c5ef3bfaedb745ebfa39d1dd1d5f672b1db03
@@@ -16,14 -16,13 +16,13 @@@ package net.systemeD.halcyon.connectio
      */
        public class XMLConnection extends XMLBaseConnection {
  
-               public function XMLConnection() {
+               public function XMLConnection(name:String,api:String,policy:String,initparams:Object) {
  
-                       if (Connection.policyURL!='')
-                 Security.loadPolicyFile(Connection.policyURL);
-             var oauthPolicy:String = Connection.getParam("oauth_policy", "");
-             if ( oauthPolicy != "" ) {
-                 Security.loadPolicyFile(oauthPolicy);
-             }
+                       super(name,api,policy,initparams);
+                       if (policyURL != "") Security.loadPolicyFile(policyURL);
+             var oauthPolicy:String = getParam("oauth_policy", "");
+             if (oauthPolicy != "") Security.loadPolicyFile(oauthPolicy);
                }
                
                override public function loadBbox(left:Number,right:Number,
              var mapVars:URLVariables = new URLVariables();
              mapVars.bbox= left+","+bottom+","+right+","+top;
  
-             var mapRequest:URLRequest = new URLRequest(Connection.apiBaseURL+"map");
+             var mapRequest:URLRequest = new URLRequest(apiBaseURL+"map");
              mapRequest.data = mapVars;
  
              sendLoadRequest(mapRequest);
                }
  
                override public function loadEntityByID(type:String, id:Number):void {
-                       var url:String=Connection.apiBaseURL + type + "/" + id;
+                       var url:String=apiBaseURL + type + "/" + id;
                        if (type=='way') url+="/full";
                        sendLoadRequest(new URLRequest(url));
                }
@@@ -57,7 -56,6 +56,7 @@@
                        mapLoader.addEventListener(Event.COMPLETE, loadedMap);
                        mapLoader.addEventListener(IOErrorEvent.IO_ERROR, errorOnMapLoad);
                        mapLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, mapLoadStatus);
 +            request.requestHeaders.push(new URLRequestHeader("X-Error-Format", "XML"));
                        mapLoader.load(request);
                        dispatchEvent(new Event(LOAD_STARTED));
                }
                changesetXML.changeset.appendChild(tagXML);
              }        
  
-                       sendOAuthPut(Connection.apiBaseURL+"changeset/create",
+                       sendOAuthPut(apiBaseURL+"changeset/create",
                                                 changesetXML,
                                                 changesetCreateComplete, changesetCreateError, recordStatus);
            }
              var id:Number = Number(URLLoader(event.target).data);
              
              // which means we now have a new changeset!
-             setActiveChangeset(new Changeset(id, lastUploadedChangesetTags));
+             setActiveChangeset(new Changeset(this, id, lastUploadedChangesetTags));
          }
  
          private function changesetCreateError(event:IOErrorEvent):void {
              var cs:Changeset = getActiveChangeset();
                        if (!cs) return;
                        
-                       sendOAuthPut(Connection.apiBaseURL+"changeset/"+cs.id+"/close",
+                       sendOAuthPut(apiBaseURL+"changeset/"+cs.id+"/close",
                                                 null,
                                                 changesetCloseComplete, changesetCloseError, recordStatus);
                        closeActiveChangeset();
              loader.load(urlReq);
          }
  
-         override public function uploadChanges():void {
+               /** Create XML changeset and send it to the server. Returns the XML string for use in the 'Show data' button.
+                   (We don't mind what's returned as long as it implements .toString() ) */
+         override public function uploadChanges():* {
              var changeset:Changeset = getActiveChangeset();
              var upload:XML = <osmChange version="0.6"/>
              upload.appendChild(addCreated(changeset, getAllNodeIDs, getNode, serialiseNode));
  
              // now actually upload them
              // make an OAuth query
-             var url:String = Connection.apiBaseURL+"changeset/" + changeset.id + "/upload";
+             var url:String = apiBaseURL+"changeset/" + changeset.id + "/upload";
  
              // build the actual request
                        var serv:HTTPService=new HTTPService();
                        serv.addEventListener(FaultEvent.FAULT, diffUploadIOError);
                        serv.send(upload);
                
-               dispatchEvent(new Event(SAVE_STARTED));
+                       dispatchEvent(new Event(SAVE_STARTED));
+                       return upload;
          }
  
          private function diffUploadComplete(event:ResultEvent):void {
              if (traces_loaded && !refresh) {
                dispatchEvent(new Event(TRACES_LOADED));
              } else {
-               sendOAuthGet(Connection.apiBaseURL+"user/gpx_files",
-                           tracesLoadComplete, errorOnMapLoad, mapLoadStatus); //needs error handlers
+               sendOAuthGet(apiBaseURL+"user/gpx_files", tracesLoadComplete, errorOnMapLoad, mapLoadStatus); //needs error handlers
                dispatchEvent(new Event(LOAD_STARTED)); //specific to map or reusable?
              }
          }
              clearTraces();
              var files:XML = new XML(URLLoader(event.target).data);
              for each(var traceData:XML in files.gpx_file) {
-               var t:Trace = new Trace().fromXML(traceData);
+               var t:Trace = new Trace(this).fromXML(traceData);
                addTrace(t);
              }
              traces_loaded = true;
          }
  
          override public function fetchTrace(id:Number, callback:Function):void {
-             sendOAuthGet(Connection.apiBaseURL+"gpx/"+id+"/data.xml", 
+             sendOAuthGet(apiBaseURL+"gpx/"+id+"/data.xml", 
                                function(e:Event):void { 
                        dispatchEvent(new Event(LOAD_COMPLETED));
                                        callback(e);
index 40259a2671d9bc2663eba3b561526ff00b2d1014,f7cebe687d4e854192ae37ebc836847c98e3bdde..11465a4a692b104c97e05497ccf64a7301eed413
@@@ -63,6 -63,7 +63,7 @@@
      import net.systemeD.potlatch2.RelationEditorPanel;
      import net.systemeD.potlatch2.mapfeatures.*;
        import net.systemeD.halcyon.Map;
+       import net.systemeD.halcyon.MapPaint;
        import net.systemeD.halcyon.Globals;
      import flash.events.*;
      import mx.collections.ArrayCollection;
                // now add new entity
                rel.appendMember(new RelationMember(entity,role), undo.push);
  
 -        undo.doAction();
 +        MainUndoStack.getGlobalStack().addAction(undo);
  
                if (show.label=='Hide') { setHighlights(true); }
        }
        }
        
        private function setHighlights(bool:Boolean):void {
-               var map:Map = Globals.vars.root;
-               var from:Object=findSelected('from'); if (from) { map.setHighlight(from.data, { restrictfrom: bool } ); }
-               var to:Object  =findSelected('to'  ); if (to  ) { map.setHighlight(to.data  , { restrictto: bool   } ); }
+               var paint:MapPaint = Map(Globals.vars.root).editableLayer;      // ** FIXME: should really be the mapPaint layer where the objects are located
+               var from:Object=findSelected('from'); if (from) { paint.setHighlight(from.data, { restrictfrom: bool } ); }
+               var to:Object  =findSelected('to'  ); if (to  ) { paint.setHighlight(to.data  , { restrictto: bool   } ); }
        }
      
      ]]></mx:Script>