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 public function closeAndNewRelation():void {
47 var relation:Relation = conn.createRelation({}, [new RelationMember(entity, '')])
48 PopUpManager.removePopUp(this);
49 trace("edit relation "+id);
50 var panel:RelationEditorPanel = RelationEditorPanel(
51 PopUpManager.createPopUp(Application(Application.application), RelationEditorPanel, true));
52 panel.setRelation(relation);
53 PopUpManager.centerPopUp(panel);
57 <mx:Text id="warning" text="" />
58 <mx:List width="100%" height="100%" id="relationSelector" verticalScrollPolicy="on">
61 <mx:Button label="New Relation..." click="closeAndNewRelation();"/>
62 <mx:Spacer width="100%"/>
63 <mx:Button label="Select" click="updateEntityAndClose();" enabled="{relationSelector.selectedItem != null? true : false}"/>