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