removed[0].entity.removeParent(this);
}
+ public function getDescription():String {
+ var desc:String = "";
+ var relTags:Object = getTagsHash();
+ if ( relTags["type"] ) {
+ desc = relTags["type"];
+ if ( relTags[desc] )
+ desc += " " + relTags[desc];
+ }
+ if ( relTags["ref"] )
+ desc += " " + relTags["ref"];
+ if ( relTags["name"] )
+ desc += " " + relTags["name"];
+ return desc;
+ }
+
public override function getType():String {
return 'relation';
}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<mx:TitleWindow
+ xmlns:mx="http://www.adobe.com/2006/mxml"
+ xmlns:potlatch2="net.systemeD.potlatch2.*"
+ title="Select Relation" width="350" height="400"
+ showCloseButton="true" close="PopUpManager.removePopUp(this);">
+
+ <mx:Script><![CDATA[
+ import net.systemeD.halcyon.*;
+ import net.systemeD.halcyon.connection.*;
+ import net.systemeD.potlatch2.*;
+ import mx.managers.PopUpManager;
+ import mx.core.Application;
+
+ private var conn:Connection;
+ private var relationList:Array;
+ private var entity:Entity;
+
+ public function init(e:Entity):void {
+ entity = e;
+ PopUpManager.addPopUp(this, Application(Application.application), true);
+ PopUpManager.centerPopUp(this);
+
+ var titles:Array = [];
+ conn = Connection.getConnectionInstance();
+ relationList = conn.getAllRelationIDs();
+ if (relationList.length == 0) {
+ warning.text = "No relations loaded";
+ } else {
+ warning.text = "These relations are available:";
+ }
+ //relationSelector.dataProvider = relationList;
+ for each (var id:Number in relationList) {
+ var relation:Relation = conn.getRelation(id);
+ titles.push({label:id + ": " + relation.getDescription(), relId:id});
+ }
+ relationSelector.dataProvider = titles;
+ }
+
+ public function updateEntityAndClose():void {
+ var relation:Relation = conn.getRelation(relationSelector.selectedItem.relId);
+ relation.appendMember(new RelationMember(entity, ''));
+ PopUpManager.removePopUp(this);
+ }
+ ]]></mx:Script>
+ <mx:Text id="warning" text="" />
+ <mx:List width="100%" height="100%" id="relationSelector" verticalScrollPolicy="on">
+ </mx:List>
+ <mx:ControlBar>
+ <mx:Button label="New Relation..." enabled="false"/>
+ <mx:Spacer width="100%"/>
+ <mx:Button label="Select" click="updateEntityAndClose();" enabled="{relationSelector.selectedItem != null? true : false}"/>
+ </mx:ControlBar>
+</mx:TitleWindow>
\ No newline at end of file
props["id"] = rel.id;
var memberIndex:uint = rel.findEntityMemberIndex(entity);
props["role"] = rel.getMember(memberIndex).role;
-
- var desc:String = "";
- var relTags:Object = rel.getTagsHash();
- if ( relTags["type"] ) {
- desc = relTags["type"];
- if ( relTags[desc] )
- desc += " " + relTags[desc];
- }
- if ( relTags["ref"] )
- desc += " " + relTags["ref"];
- if ( relTags["name"] )
- desc += " " + relTags["name"];
- props["description"] = desc;
+ props["description"] = rel.getDescription();
relations.push(props);
}
}
public function addToRelation():void {
+ new RelationSelectPanel().init(selectedEntity);
}
public function removeFromRelation():void {