Figure out the layer a Marker is on, and bounce it all the way to the MarkerPanel...
authorAndy Allan <gravitystorm@gmail.com>
Wed, 17 Nov 2010 13:03:40 +0000 (13:03 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Wed, 17 Nov 2010 13:03:40 +0000 (13:03 +0000)
net/systemeD/potlatch2/EditController.as
net/systemeD/potlatch2/MarkerPanel.mxml
net/systemeD/potlatch2/TagViewer.mxml
net/systemeD/potlatch2/controller/ControllerState.as
net/systemeD/potlatch2/controller/SelectedMarker.as

index 60ad793..2f7028f 100644 (file)
@@ -2,6 +2,7 @@ package net.systemeD.potlatch2 {
     import net.systemeD.halcyon.Map;
     import net.systemeD.halcyon.MapController;
     import net.systemeD.halcyon.connection.*;
+    import net.systemeD.halcyon.VectorLayer;
     import net.systemeD.potlatch2.controller.*;
        import mx.managers.CursorManager;
        import flash.events.*;
@@ -58,9 +59,15 @@ package net.systemeD.potlatch2 {
         public function get connection():Connection {
             return _connection;
         }
-        
-               public function updateSelectionUI():void {
-                       tagViewer.setEntity(state.selection);
+
+        /**
+        * Updates the various user interfaces that change when the selection changes.
+        * Currently this is the TagViewer and the Toolbox
+        *
+        * @param layer Optionally pass the layer of the currently selected entity, eg for BugLayers
+        */
+               public function updateSelectionUI(layer:VectorLayer = null):void {
+                       tagViewer.setEntity(state.selection, layer);
                        toolbox.updateSelectionUI();
                }
         
index 7cf6a1f..d9dd964 100644 (file)
       <mx:DataGridColumn editable="false" dataField="value" headerText="value" />
     </mx:columns>
   </mx:DataGrid>
+  <mx:HBox id="bugControl" horizontalAlign="right" width="100%" visible="false">
+    <mx:LinkButton label="Add Comment" enabled="false" />
+    <mx:LinkButton label="Close Bug" click="closeBug()" />
+  </mx:HBox>
   <mx:Script><![CDATA[
 
       import net.systemeD.halcyon.connection.*;
+      import net.systemeD.halcyon.VectorLayer;
+      import net.systemeD.potlatch2.BugLayer;
       import mx.collections.*;
 
       private var selectedEntity:Entity;
       private var tagDataProvider:ArrayCollection;
+      private var layer:VectorLayer;
 
-      public function init(entity:Entity):void {
+      public function init(entity:Entity, layer:VectorLayer):void {
+            this.layer = layer;
             if ( tagDataProvider == null ) {
                 tagDataProvider = new ArrayCollection();
                 markerPanelDG.dataProvider = tagDataProvider;
@@ -28,6 +36,9 @@
 
             selectedEntity=entity;
             updateTagDataProvider();
+            if (layer is BugLayer) {
+              bugControl.visible = true;
+            }
       }
 
       private function updateTagDataProvider():void {
             var tags:Array = selectedEntity.getTagArray();
             tags.sortOn("key");
             for each(var tag:Tag in tags) { tagDataProvider.addItem(tag); }
-        }
+      }
+
+      private function closeBug():void {
+            if (layer is BugLayer) {
+              BugLayer(layer).closeBug(selectedEntity as Marker);
+            }
+      }
       ]]>
   </mx:Script>
 </mx:VBox>
\ No newline at end of file
index 0e65881..0b1898a 100644 (file)
 
   <mx:Script><![CDATA[
       import net.systemeD.halcyon.connection.*;
+      import net.systemeD.halcyon.VectorLayer;
       import net.systemeD.potlatch2.mapfeatures.*;
 
       import mx.collections.*;
       private var tw:CategorySelector = null;
       private var feature:Feature = null;
 
-         public function setEntity(entities:Array):void {
+         public function setEntity(entities:Array, layer:VectorLayer=null):void {
                UIComponent.suspendBackgroundProcessing();
                
                var firstSelected:Entity=null;
                        if (advancedID!=null) { setupAdvanced(firstSelected); }
                        if (firstSelected is Relation) { stack.addChild(membersVBox); }
             if (selectedEntity is Marker) {
-              markerPanelContents.init(selectedEntity);
+              markerPanelContents.init(selectedEntity, layer);
               sidebar.selectedChild = markerPanel;
             } else {
               refreshFeatureIcon();
index 3237322..bf413a8 100644 (file)
@@ -73,7 +73,7 @@ package net.systemeD.potlatch2.controller {
                                        if (entity is Way) { return new SelectedWay(newEntity as Way); }
                                        else if (entity is Node) { return new SelectedPOINode(newEntity as Node); }
                 } else if (event.type == MouseEvent.MOUSE_DOWN && entity is Marker) {
-                    return new SelectedMarker(entity as Marker);
+                    return new SelectedMarker(entity as Marker, paint.findSource());
                                } else if ( event.type == MouseEvent.MOUSE_UP ) { 
                                        return (this is NoSelection) ? null : new NoSelection();
                                } else { return null; }
index 3e6207b..f158efe 100644 (file)
@@ -3,13 +3,16 @@ package net.systemeD.potlatch2.controller {
        import flash.ui.Keyboard;
     import net.systemeD.potlatch2.EditController;
     import net.systemeD.halcyon.connection.*;
+    import net.systemeD.halcyon.VectorLayer;
        import net.systemeD.halcyon.Globals;
 
     public class SelectedMarker extends ControllerState {
         protected var initMarker:Marker;
+        protected var layer:VectorLayer;
 
-        public function SelectedMarker(marker:Marker) {
+        public function SelectedMarker(marker:Marker, layer:VectorLayer) {
             initMarker = marker;
+            this.layer = layer;
         }
 
         protected function selectMarker(marker:Marker):void {
@@ -19,7 +22,7 @@ package net.systemeD.potlatch2.controller {
             clearSelection(this);
             controller.map.setHighlight(marker, { selected: true });
             selection = [marker];
-            controller.updateSelectionUI();
+            controller.updateSelectionUI(layer);
             initMarker = marker;
         }