]> git.openstreetmap.org Git - potlatch2.git/blobdiff - net/systemeD/potlatch2/mapfeatures/editors/RouteIcon.mxml
forward & backward in route roles
[potlatch2.git] / net / systemeD / potlatch2 / mapfeatures / editors / RouteIcon.mxml
index 08b0b95f8f46b622c05abb510c511a81cfa986ca..7ad95f1e70f4cc8ab89f680da7a943f8028c66a4 100644 (file)
@@ -8,6 +8,9 @@
        
        <mx:Image source="{iconImage}"/>
     <mx:Text condenseWhite="true" width="100%" htmlText="{iconHTML}" selectable="false"/>
+    <mx:ComboBox id="dir" color="black" dataProvider="{routeDirs}" selectedItem="{findSelected(role)}"
+        click="event.stopPropagation()"
+        change="setRole(dir.selectedItem.data)" />
     
     <mx:Script><![CDATA[
     import net.systemeD.halcyon.connection.*;
     import net.systemeD.potlatch2.mapfeatures.*;
     import flash.events.*;
 
+    import mx.collections.ArrayCollection;
+
+    [Bindable]
+    public var routeDirs:ArrayCollection = new ArrayCollection(
+        [ {label:">>", data:"forward"}, 
+          {label:"<<", data:"backward"}, 
+          {label:"<>", data:""} ]);
+
     private var _iconImage:String = null;
     private var _iconHTML:String = "";
     private var _bg:String = "white";
     private var _fg:String = "black";
-    private var _relation:Relation;
+    private var _route:Object;
+    
+    private function findSelected(role:String):Object {
+        for each ( var item:Object in routeDirs ) {
+            if ( item.data == role )
+                return item;
+        }
+        return routeDirs[2];
+    }
          
-    public function setRoute(relation:Relation, icon:XMLList):void {   
-        _relation = relation;
+    public function setRoute(route:Object, icon:XMLList):void {   
+        _route = route;
+        var relation:Relation = route["relation"];
         _iconHTML = Feature.makeHTMLIcon(icon, relation);
 
         if ( icon.length() > 0 ) {
         return _iconHTML;
     }
 
+    [Bindable(event="route_changed")]
+    private function get role():String {
+        return _route["role"];
+    }
+
     [Bindable(event="route_changed")]
     private function get fg():uint {
         return MapCSS.parseCSSColor(_fg);
         return MapCSS.parseCSSColor(_bg);
     }
     
-    public function get route():Relation {
-        return _relation;
+    public function get route():Object {
+        return _route;
     }
+    
+    private function setRole(role:String):void {
+        var member:RelationMember = new RelationMember(_route["entity"], role);
+        _route["relation"].setMember(_route["index"], member);
+    }
+    
     ]]></mx:Script>
 </mx:HBox>