Allow pubs to be given names.
[potlatch2.git] / potlatch2.mxml
index 999930ac561e75c0631719aeb9ff12b2b16b4c67..0ed126352b574ea8fb59740d0abbe2b3ca4f9b6b 100755 (executable)
     <mx:WipeRight id="wipeIn" duration="250"/>
 
     <mx:ApplicationControlBar dock="true">
     <mx:WipeRight id="wipeIn" duration="250"/>
 
     <mx:ApplicationControlBar dock="true">
+        <mx:PopUpButton id="bgButton" label="Background" openAlways="true"
+            creationComplete="bgButton.popUp = new BackgroundSelector();"/>
+        <mx:PopUpButton id="styleButton" label="Map Style" openAlways="true"
+            creationComplete="styleButton.popUp = new StyleSelector();"/>
         <mx:Spacer width="100%"/>
         <mx:Button label="Help" click="new HelpDialog().init();" />
         <mx:Button label="Options" click="new OptionsDialog().init();" />
         <mx:Spacer width="100%"/>
         <mx:Button label="Help" click="new HelpDialog().init();" />
         <mx:Button label="Options" click="new OptionsDialog().init();" />
     
     <mx:HDividedBox width="100%" height="100%">
 
     
     <mx:HDividedBox width="100%" height="100%">
 
-       <!-- The left-hand accordion is to give access to a small number of options that the user 
-            may want to change rapidly: tags, of course; stylesheet; and background layer. Lesser-
-            used options should go in the options dialogue. Tools (e.g. split ways) should probably 
-            go in a floating palette or somesuch, so that there is access no matter which accordion 
-            pane is open. -->
-
-       <mx:Accordion height="100%" width="25%" headerStyleName="header">
-
-               <!-- Tag viewer -->
-               <mx:VBox height="100%" width="100%" horizontalAlign="right" label="Tags">
-                       <potlatch2:TagViewer width="100%" height="100%" id="tagViewer"/>
-               </mx:VBox>
-
-               <!-- Stylesheet -->
-               <!-- should be pretty much the same as the background selector below, with the
-                    added ability to enter your own stylesheet URL -->
-               <mx:VBox label="Map style" width="100%">
-               </mx:VBox>
-
-               <!-- Background -->
-               <mx:VBox label="Background" width="100%">
-               <!-- Needs a dimming checkbox control -->
-           <mx:List width="100%" height="100%" id="background" change="updateBackground();"> 
-                       <!-- This should be pulled in from an XML file rather than sitting in the source -->
-               <mx:dataProvider>
-                   <mx:Object label="None" data="" />
-                   <mx:Object label="Yahoo!" data="yahoo" />
-                   <mx:Object label="New Popular Edition" data="http://npe.openstreetmap.org/$z/$x/$y.png" />
-                   <mx:Object label="OpenCycleMap" data="http://andy.sandbox.cloudmade.com/tiles/cycle/$z/$x/$y.png" />
-               </mx:dataProvider>
-           </mx:List>
-               </mx:VBox>
-
-       </mx:Accordion>
+         <!-- Tag viewer -->
+         <potlatch2:TagViewer width="25%" height="100%" id="tagViewer"/>
 
       <mx:Canvas width="75%" height="100%">
         <mx:Canvas id="map_area" resize="onResizeMap()"
 
       <mx:Canvas width="75%" height="100%">
         <mx:Canvas id="map_area" resize="onResizeMap()"
-            top="0" left="0" width="100%" height="100%">
+            top="0" left="0" width="100%" height="100%" dragEnter="dragEnterHandler(event);" dragDrop="dragDropHandler(event);">
         </mx:Canvas>
         <mx:Image source="@Embed('embedded/zoomIn.svg')" right="3" top="3" click="theMap.zoomIn();"
             rollOverEffect="glowImage" rollOutEffect="unglowImage"/>
         </mx:Canvas>
         <mx:Image source="@Embed('embedded/zoomIn.svg')" right="3" top="3" click="theMap.zoomIn();"
             rollOverEffect="glowImage" rollOutEffect="unglowImage"/>
@@ -87,6 +59,7 @@
                import net.systemeD.potlatch2.save.SaveManager;
                import net.systemeD.potlatch2.help.*;
                import net.systemeD.potlatch2.options.*;
                import net.systemeD.potlatch2.save.SaveManager;
                import net.systemeD.potlatch2.help.*;
                import net.systemeD.potlatch2.options.*;
+               import net.systemeD.potlatch2.utils.*;
                import mx.managers.PopUpManager;
                import flash.system.Security;
                import flash.net.*;
                import mx.managers.PopUpManager;
                import flash.system.Security;
                import flash.net.*;
@@ -98,6 +71,9 @@
                import com.yahoo.maps.api.YahooMap;
                import com.yahoo.maps.api.YahooMapEvent;
                import com.yahoo.maps.api.core.location.LatLon;
                import com.yahoo.maps.api.YahooMap;
                import com.yahoo.maps.api.YahooMapEvent;
                import com.yahoo.maps.api.core.location.LatLon;
+        import mx.events.DragEvent;
+        import mx.managers.DragManager;
+        import mx.core.DragSource;
 
         public var theMap:Map;
                public var yahooListener:Object = new Object();
 
         public var theMap:Map;
                public var yahooListener:Object = new Object();
 
                private function initApp():void {
 
 
                private function initApp():void {
 
-                       Globals.vars.map_area=map_area;
-                       Globals.vars.root=map_area.rawChildren;                 // set up global reference to root level
-                       var _root:IChildList=map_area.rawChildren;              // convenient local shorthand
+                       Globals.vars.map_area = map_area;
+                       Globals.vars.yahoo = yahoo;
+                       Globals.vars.root = map_area.rawChildren;                       // set up global reference to root level
+                       var _root:IChildList = map_area.rawChildren;            // convenient local shorthand
 
                        // map backdrop object
             var w:uint = map_area.width;
 
                        // map backdrop object
             var w:uint = map_area.width;
                        yahoo.mapType="satellite";
                        _root.addChild(yahoo);
                        yahoo.visible=false;
                        yahoo.mapType="satellite";
                        _root.addChild(yahoo);
                        yahoo.visible=false;
+                       yahoo.alpha=0.5;
 
                        // Yahoo! listeners
                        yahooListener.yahooInit=function(event:YahooMapEvent):void {
 
                        // Yahoo! listeners
                        yahooListener.yahooInit=function(event:YahooMapEvent):void {
             var conn:Connection = Connection.getConnectionInstance();
             conn.addEventListener(Connection.LOAD_STARTED, onDataStart);
             conn.addEventListener(Connection.LOAD_COMPLETED, onDataComplete);
             var conn:Connection = Connection.getConnectionInstance();
             conn.addEventListener(Connection.LOAD_STARTED, onDataStart);
             conn.addEventListener(Connection.LOAD_COMPLETED, onDataComplete);
+
+                       // and to import a shapefile...
+//                     var importer:ShpImporter = new ShpImporter(theMap, ["http://127.0.0.1/~richard/shp/wildrnp020.shp","http://127.0.0.1/~richard/shp/wildrnp020.shx","http://127.0.0.1/~richard/shp/wildrnp020.dbf"]);
                }
 
         public function onResizeMap():void {
                }
 
         public function onResizeMap():void {
         private function onDataComplete(event:Event):void {
             dataWorking.visible = false;
         }
         private function onDataComplete(event:Event):void {
             dataWorking.visible = false;
         }
+        
+
+        
+        private function dragEnterHandler(event:DragEvent):void {
+            // Get the drop target component from the event object.
+            var dropTarget:Canvas=event.currentTarget as Canvas;
+            // Accept the drag only if the user is dragging poi with tags
+            if (event.dragSource.hasFormat('tags')) 
+            {
+                DragManager.acceptDragDrop(dropTarget);
+            }
+        }
+        
+        private function dragDropHandler(event:DragEvent):void {
+            // Get the data identified by the color format from the drag source.
+            // Blame http://www.adobe.com/devnet/flex/quickstart/adding_drag_and_drop/#manual
+            // for whatever horrid abuse of "color format" this is doing
+            var tags:Array = event.dragSource.dataForFormat('tags') as Array;
+            var mapLoc:Point = Globals.vars.root.globalToLocal(new Point(event.stageX, event.stageY));
+            var lat:Number = Globals.vars.root.coord2lat(mapLoc.y);
+            var lon:Number = Globals.vars.root.coord2lon(mapLoc.x);
+            var node:Node = Connection.getConnectionInstance().createNode({}, lat, lon);
+            for each ( var tag:Object in tags ) {
+              node.setTag(tag.k, tag.v);
+            }
+                       Connection.getConnectionInstance().registerPOI(node);
+        }
 
 
-               private function updateBackground():void {
-                       var bg:String=background.selectedItem.data;
-                       if (bg=='yahoo') {
-                               theMap.tileset.init('',false);
-                               yahoo.visible=true;
-                               yahoo.zoomLevel = 18-theMap.scale;
-                               yahoo.centerLatLon = new LatLon(theMap.centre_lat, theMap.centre_lon);
-                       } else {
-                               theMap.tileset.init(background.selectedItem.data,true);
-                               yahoo.visible=false;
-                       }
-               }
-               
        ]]></mx:Script>
 
 </mx:Application>
        ]]></mx:Script>
 
 </mx:Application>