more
[potlatch2.git] / net / systemeD / potlatch2 / mapfeatures / editors / RouteEditor.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2 <edit:RelationMemberEditor
3         xmlns:fx="http://ns.adobe.com/mxml/2009"
4         xmlns:mx="library://ns.adobe.com/flex/mx"
5         xmlns:edit="net.systemeD.potlatch2.mapfeatures.editors.*"
6         xmlns:flexlib="flexlib.controls.*"
7         verticalGap="0"
8         width="100%"
9         toolTip="{fieldDescription}"
10         initialize="addRoutes()">
11
12   <mx:Label text="{fieldName}:"/>
13   <mx:VBox verticalGap="0" width="100%" id="routeIcons"/>
14   <mx:LinkButton label="Add to a route" click="addToRelation()" />
15
16   <fx:Script><![CDATA[
17     import net.systemeD.halcyon.connection.*;
18     import net.systemeD.potlatch2.*;
19     import mx.managers.PopUpManager;
20     import mx.core.*;
21    
22     public function addRoutes(event:Event=null):void {
23                 routeIcons.removeAllChildren();
24                 addEventListener("relations_changed", addRoutes);
25         for each(var relation:Object in matchedRelations) {
26             var icon:RouteIcon = new RouteIcon();
27             icon.setRoute(relation, RouteEditorFactory(_factory).icon);
28             
29             icon.addEventListener(MouseEvent.CLICK, routeClicked, false, 0, true);
30             routeIcons.addChild(icon);
31         }
32     }
33     
34     public function routeClicked(event:Event):void {
35         var relation:Object = RouteIcon(event.currentTarget).route;
36         var panel:RelationEditorPanel = RelationEditorPanel(
37             PopUpManager.createPopUp(Application(FlexGlobals.topLevelApplication), RelationEditorPanel, true));
38         panel.setRelation(relation["relation"]);
39         PopUpManager.centerPopUp(panel);
40     }
41
42         public function addToRelation():void {
43                 new RelationSelectPanel().init(_entity, _factory.relationTagPatterns);        
44         }
45     
46   ]]></fx:Script>
47 </edit:RelationMemberEditor>
48