ADD support for non-drag-and-droppable point features. These are specified as <point...
authorSteve Bennett <stevagewp@gmail.com>
Sat, 12 Feb 2011 05:53:24 +0000 (05:53 +0000)
committerSteve Bennett <stevagewp@gmail.com>
Sat, 12 Feb 2011 05:53:24 +0000 (05:53 +0000)
net/systemeD/potlatch2/TagViewer.mxml
net/systemeD/potlatch2/mapfeatures/Category.as
net/systemeD/potlatch2/mapfeatures/Feature.as

index b6db2ec..239ea6f 100644 (file)
@@ -20,7 +20,7 @@
                        <mx:Label text="{dndRep.currentItem.name}:" styleName="dndPanelCategoryLabel"/>
                </mx:HBox>
 
-               <mx:TileList dataProvider="{dndRep.currentItem.getFeaturesForType('point')}" width="100%" height="1"
+               <mx:TileList dataProvider="{dndRep.currentItem.getFeaturesForType('point', true)}" width="100%" height="1"
                                     rowHeight="32" columnWidth="32" updateComplete="resizePOIGrid(event)" styleName="dndPanelTileList">
                        <mx:itemRenderer>
                                <mx:Component>
index 4c67960..4cb1dd2 100644 (file)
@@ -1,7 +1,6 @@
 package net.systemeD.potlatch2.mapfeatures {
 
     import flash.events.EventDispatcher;
-    import flash.events.Event;
 
         /** A Category is a (non-exclusive) grouping of related Features used to help the user find the map feature they are interested in using. */
        public class Category extends EventDispatcher {
@@ -46,14 +45,16 @@ package net.systemeD.potlatch2.mapfeatures {
 
         [Bindable(event="featuresChanged")]
         /** Get an array of all features in this category that have the requested type, or possibly empty list. */
-        public function getFeaturesForType(type:String):Array {
+        public function getFeaturesForType(type:String, onlydnd:Boolean=false):Array {
             if ( type == null || type == "" )
                 return []; //_features;
 
             var filteredFeatures:Array = new Array();
             for each( var feature:Feature in _features ) {
                 if ( feature.isType(type) )
-                    filteredFeatures.push(feature);
+                    if (!onlydnd || feature.canDND()) {
+                        filteredFeatures.push(feature);
+                    }
             }
             return filteredFeatures;
         }
index 4e2b54f..7466e2e 100644 (file)
@@ -1,12 +1,13 @@
 package net.systemeD.potlatch2.mapfeatures {
 
-    import flash.events.EventDispatcher;
     import flash.events.Event;
+    import flash.events.EventDispatcher;
     import flash.net.*;
     import flash.utils.ByteArray;
+    
     import mx.core.BitmapAsset;
     import mx.graphics.codec.PNGEncoder;
-
+    
     import net.systemeD.halcyon.connection.Entity;
     import net.systemeD.potlatch2.utils.CachedDataLoader;
 
@@ -113,6 +114,7 @@ package net.systemeD.potlatch2.mapfeatures {
             var imageURL:String = null;
             var img:ByteArray;
 
+            
             if ( icon.length() > 0 && icon[0].hasOwnProperty("@image") )
                 imageURL = icon[0].@image;
 
@@ -125,6 +127,14 @@ package net.systemeD.potlatch2.mapfeatures {
             var bitmap:BitmapAsset = new missingIconCls() as BitmapAsset;
             return new PNGEncoder().encode(bitmap.bitmapData);
         }
+        
+        /** Can this feature be drag-and-dropped from the side panel? By default, any "point" feature can,
+        *   unless it has <point draganddrop="no"/> 
+        * */
+        public function canDND():Boolean {
+               var point:XMLList = _xml.elements("point");
+               return point.length() > 0 && !(XML(point[0]).attribute("draganddrop")[0] == "no");
+        }
 
         private function imageLoaded(url:String, data:ByteArray):void {
             dispatchEvent(new Event("imageChanged"));