From 6842a62be17b7e06d1b27b861b21a2c07abcb6c9 Mon Sep 17 00:00:00 2001 From: Dave Stubbs Date: Sun, 10 Jan 2010 14:29:55 +0000 Subject: [PATCH] forward & backward in route roles --- net/systemeD/halcyon/connection/Relation.as | 3 ++ .../editors/RelationMemberEditor.as | 13 +++++- .../mapfeatures/editors/RouteEditor.mxml | 6 +-- .../mapfeatures/editors/RouteIcon.mxml | 41 ++++++++++++++++--- 4 files changed, 53 insertions(+), 10 deletions(-) diff --git a/net/systemeD/halcyon/connection/Relation.as b/net/systemeD/halcyon/connection/Relation.as index 7d804d63..59524d06 100644 --- a/net/systemeD/halcyon/connection/Relation.as +++ b/net/systemeD/halcyon/connection/Relation.as @@ -45,6 +45,9 @@ package net.systemeD.halcyon.connection { } public function setMember(index:uint, member:RelationMember):void { + var oldMember:RelationMember = getMember(index); + oldMember.entity.removeParent(this); + member.entity.addParent(this); members.splice(index, 1, member); markDirty(); diff --git a/net/systemeD/potlatch2/mapfeatures/editors/RelationMemberEditor.as b/net/systemeD/potlatch2/mapfeatures/editors/RelationMemberEditor.as index b8fd1744..8d371fb9 100644 --- a/net/systemeD/potlatch2/mapfeatures/editors/RelationMemberEditor.as +++ b/net/systemeD/potlatch2/mapfeatures/editors/RelationMemberEditor.as @@ -34,8 +34,17 @@ package net.systemeD.potlatch2.mapfeatures.editors { if ( relVal != relationTags[k] ) addable = false; } - if (addable) - matched.push(relation); + if (addable) { + for each( var memberIndex:int in relation.findEntityMemberIndexes(_entity)) { + var props:Object = {}; + props["relation"] = relation; + props["id"] = relation.id; + props["index"] = memberIndex; + props["role"] = relation.getMember(memberIndex).role; + props["entity"] = _entity; + matched.push(props); + } + } } return matched; } diff --git a/net/systemeD/potlatch2/mapfeatures/editors/RouteEditor.mxml b/net/systemeD/potlatch2/mapfeatures/editors/RouteEditor.mxml index 95996203..33e308b0 100644 --- a/net/systemeD/potlatch2/mapfeatures/editors/RouteEditor.mxml +++ b/net/systemeD/potlatch2/mapfeatures/editors/RouteEditor.mxml @@ -19,7 +19,7 @@ import mx.core.*; public function addRoutes():void { - for each(var relation:Relation in matchedRelations) { + for each(var relation:Object in matchedRelations) { var icon:RouteIcon = new RouteIcon(); icon.setRoute(relation, RouteEditorFactory(_factory).icon); @@ -29,11 +29,11 @@ } public function routeClicked(event:Event):void { - var relation:Relation = RouteIcon(event.currentTarget).route; + var relation:Object = RouteIcon(event.currentTarget).route; trace(relation+" is clicked"); var panel:RelationEditorPanel = RelationEditorPanel( PopUpManager.createPopUp(Application(Application.application), RelationEditorPanel, true)); - panel.setRelation(relation); + panel.setRelation(relation["relation"]); PopUpManager.centerPopUp(panel); } diff --git a/net/systemeD/potlatch2/mapfeatures/editors/RouteIcon.mxml b/net/systemeD/potlatch2/mapfeatures/editors/RouteIcon.mxml index 08b0b95f..7ad95f1e 100644 --- a/net/systemeD/potlatch2/mapfeatures/editors/RouteIcon.mxml +++ b/net/systemeD/potlatch2/mapfeatures/editors/RouteIcon.mxml @@ -8,6 +8,9 @@ + >", 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 ) { @@ -47,6 +67,11 @@ 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); @@ -57,9 +82,15 @@ 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); + } + ]]> -- 2.37.0