slash and burn trace statements, and fix areas on vector background layers
[potlatch2.git] / net / systemeD / potlatch2 / RelationSelectPanel.mxml
index 5b2a8bd8d17f3909c38f93ce6fe48cd4788ae4b1..93193768833fa9474ccf5697d6e1114949faaf80 100644 (file)
         private var conn:Connection;
         private var relationList:Array;
         private var entity:Entity;
+               private var tags:Object;
 
-        public function init(e:Entity):void {
+        public function init(e:Entity, t:Object):void {
           entity = e;
+                 tags = t;
           PopUpManager.addPopUp(this, Application(Application.application), true);
           PopUpManager.centerPopUp(this);
     
           var titles:Array = [];
           conn = Connection.getConnectionInstance();
-          relationList = conn.getAllRelationIDs();
+          relationList = conn.getMatchingRelationIDs(tags);
           if (relationList.length == 0) {
-            warning.text = "No relations loaded";
+            warning.text = "No relations available";
           } else {
             warning.text = "These relations are available:";
           }
           relation.appendMember(new RelationMember(entity, ''));
           PopUpManager.removePopUp(this);
         }
+        
+        public function closeAndNewRelation():void {
+          var relation:Relation = conn.createRelation(tags, [new RelationMember(entity, '')],
+              MainUndoStack.getGlobalStack().addAction)
+          PopUpManager.removePopUp(this);
+          var panel:RelationEditorPanel = RelationEditorPanel(
+              PopUpManager.createPopUp(Application(Application.application), RelationEditorPanel, true));
+          panel.setRelation(relation);
+          PopUpManager.centerPopUp(panel);
+        }
+        
     ]]></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:Button label="New Relation..." click="closeAndNewRelation();"/>
       <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
+</mx:TitleWindow>