1 <?xml version="1.0" encoding="utf-8"?>
3 xmlns:mx="http://www.adobe.com/2006/mxml"
4 xmlns:potlatch2="net.systemeD.potlatch2.*"
5 title="Select Relation" width="350" height="400"
6 showCloseButton="true" close="PopUpManager.removePopUp(this);">
9 import net.systemeD.halcyon.*;
10 import net.systemeD.halcyon.connection.*;
11 import net.systemeD.potlatch2.*;
12 import mx.managers.PopUpManager;
13 import mx.core.Application;
15 private var conn:Connection;
16 private var relationList:Array;
17 private var entity:Entity;
19 public function init(e:Entity):void {
21 PopUpManager.addPopUp(this, Application(Application.application), true);
22 PopUpManager.centerPopUp(this);
24 var titles:Array = [];
25 conn = Connection.getConnectionInstance();
26 relationList = conn.getAllRelationIDs();
27 if (relationList.length == 0) {
28 warning.text = "No relations loaded";
30 warning.text = "These relations are available:";
32 //relationSelector.dataProvider = relationList;
33 for each (var id:Number in relationList) {
34 var relation:Relation = conn.getRelation(id);
35 titles.push({label:id + ": " + relation.getDescription(), relId:id});
37 relationSelector.dataProvider = titles;
40 public function updateEntityAndClose():void {
41 var relation:Relation = conn.getRelation(relationSelector.selectedItem.relId);
42 relation.appendMember(new RelationMember(entity, ''));
43 PopUpManager.removePopUp(this);
46 <mx:Text id="warning" text="" />
47 <mx:List width="100%" height="100%" id="relationSelector" verticalScrollPolicy="on">
50 <mx:Button label="New Relation..." enabled="false"/>
51 <mx:Spacer width="100%"/>
52 <mx:Button label="Select" click="updateEntityAndClose();" enabled="{relationSelector.selectedItem != null? true : false}"/>