More styleparser documentation.
[potlatch2.git] / potlatch2.mxml
index 7f6af6f..81dfce4 100644 (file)
@@ -7,7 +7,8 @@
        horizontalScrollPolicy="off"
        verticalScrollPolicy="off"
        horizontalAlign="center" 
        horizontalScrollPolicy="off"
        verticalScrollPolicy="off"
        horizontalAlign="center" 
-       addedToStage="initApp()">
+       addedToStage="initApp()"
+       preloader="net.systemeD.potlatch2.Preloader">
        
        <mx:Style source="styles/Application.css"/>
 
        
        <mx:Style source="styles/Application.css"/>
 
                </mx:PopUpMenuButton>
         <mx:Spacer width="100%"/>
         <mx:Button label="Undo" click="MainUndoStack.getGlobalStack().undo();" styleName="appBarButton"
                </mx:PopUpMenuButton>
         <mx:Spacer width="100%"/>
         <mx:Button label="Undo" click="MainUndoStack.getGlobalStack().undo();" styleName="appBarButton"
-            enabled="{MainUndoStack.getGlobalStack().canUndo()}"/>
+            enabled="{MainUndoStack.getGlobalStack().canUndo()}"
+            toolTip="{MainUndoStack.getGlobalStack().getUndoDescription() ? 'Undo '+MainUndoStack.getGlobalStack().getUndoDescription() : 'Undo last action'}" />
         <mx:Button label="Redo" click="MainUndoStack.getGlobalStack().redo();" styleName="appBarButton"
             enabled="{MainUndoStack.getGlobalStack().canRedo()}"/>
         <mx:Spacer width="100%"/>
         <mx:Button label="Help" click="new HelpDialog().init();" styleName="appBarButton" />
         <mx:Button label="Options" click="new OptionsDialog().init();" styleName="appBarButton" /> 
         <mx:Button label="Redo" click="MainUndoStack.getGlobalStack().redo();" styleName="appBarButton"
             enabled="{MainUndoStack.getGlobalStack().canRedo()}"/>
         <mx:Spacer width="100%"/>
         <mx:Button label="Help" click="new HelpDialog().init();" styleName="appBarButton" />
         <mx:Button label="Options" click="new OptionsDialog().init();" styleName="appBarButton" /> 
-        <mx:Button label="Save" icon="@Embed('embedded/save.svg')" disabledIcon="@Embed('embedded/save_disabled.svg')" styleName="appBarButton"
+        <mx:Button label="Save" icon="@Embed('embedded/upload.svg')" disabledIcon="@Embed('embedded/upload_disabled.svg')" styleName="appBarButton"
                        click="SaveManager.saveChanges();" id="saveButton" enabled="false"/>
     </mx:ApplicationControlBar>
     
                        click="SaveManager.saveChanges();" id="saveButton" enabled="false"/>
     </mx:ApplicationControlBar>
     
@@ -82,6 +84,7 @@
                import net.systemeD.potlatch2.options.*;
                import net.systemeD.potlatch2.utils.*;
         import net.systemeD.potlatch2.mygpx.*;
                import net.systemeD.potlatch2.options.*;
                import net.systemeD.potlatch2.utils.*;
         import net.systemeD.potlatch2.mygpx.*;
+               import net.systemeD.controls.FloatingAlert;
                import mx.managers.PopUpManager;
                import flash.system.Security;
                import flash.net.*;
                import mx.managers.PopUpManager;
                import flash.system.Security;
                import flash.net.*;
@@ -91,6 +94,7 @@
         import mx.containers.Canvas;
                import mx.core.Application;
         import mx.events.DragEvent;
         import mx.containers.Canvas;
                import mx.core.Application;
         import mx.events.DragEvent;
+        import mx.events.CloseEvent;
         import mx.managers.DragManager;
         import mx.core.DragSource;
         import mx.controls.Alert;
         import mx.managers.DragManager;
         import mx.core.DragSource;
         import mx.controls.Alert;
             theMap.updateSize(w,h);
                        theMap.addEventListener(MapEvent.SCALE, scaleHandler);
 
             theMap.updateSize(w,h);
                        theMap.addEventListener(MapEvent.SCALE, scaleHandler);
 
-                       // add mask for map
-                       var s:Sprite=new Sprite();
-                       s.graphics.beginFill(0xFFFFFF,100);
-                       s.graphics.drawRect(0,0,w,h);
-                       s.graphics.endFill();
-                       _root.addChild(s);
-                       theMap.mask=s;
-
                        // add attribution/logo sprite
                        var overlay:Sprite=new Sprite();
                        var attribution:TextField=new TextField();
                        // add attribution/logo sprite
                        var overlay:Sprite=new Sprite();
                        var attribution:TextField=new TextField();
             conn.addEventListener(Connection.DATA_DIRTY, onDataDirty);
             conn.addEventListener(Connection.DATA_CLEAN, onDataClean);
                        conn.addEventListener(MapEvent.ERROR, onMapError);
             conn.addEventListener(Connection.DATA_DIRTY, onDataDirty);
             conn.addEventListener(Connection.DATA_CLEAN, onDataClean);
                        conn.addEventListener(MapEvent.ERROR, onMapError);
+                       conn.addEventListener(AttentionEvent.ATTENTION, onAttention);
+                       conn.addEventListener(AttentionEvent.ALERT, onAlert);
 
             // set the access token from saved cookie
             var tokenObject:SharedObject = SharedObject.getLocal("access_token");
 
             // set the access token from saved cookie
             var tokenObject:SharedObject = SharedObject.getLocal("access_token");
 
                        // Load arbitrary GPX from provided URL
                        if (loaderInfo.parameters['gpx_url']) {
 
                        // Load arbitrary GPX from provided URL
                        if (loaderInfo.parameters['gpx_url']) {
-                               var vectorlayer:VectorLayer=new VectorLayer(name,theMap,"gpx.css");
+                               var vectorlayer:VectorLayer=new VectorLayer(name,theMap,"stylesheets/gpx.css");
                                vectorlayer.url=loaderInfo.parameters['gpx_url'];
                                var gpx:GpxImporter=new GpxImporter(vectorlayer, vectorlayer.paint, [vectorlayer.url], 
                                                                    function(success:Boolean,message:String=null):void {
                                vectorlayer.url=loaderInfo.parameters['gpx_url'];
                                var gpx:GpxImporter=new GpxImporter(vectorlayer, vectorlayer.paint, [vectorlayer.url], 
                                                                    function(success:Boolean,message:String=null):void {
             Globals.vars.highlightTiger = obj.data['tiger_highlighted'];
                }
                
             Globals.vars.highlightTiger = obj.data['tiger_highlighted'];
                }
                
-               public function onMapError(event:MapEvent):void {
-                       Alert.show(event.params.message, 'Error', mx.controls.Alert.OK);
+               public function onMapError(mapEvent:MapEvent):void {
+                       var buttons:uint=0;
+                       if (mapEvent.params.no) { trace("no is set"); }
+                       if (mapEvent.params.yes             ) buttons|=mx.controls.Alert.YES;
+                       if (mapEvent.params.no              ) buttons|=mx.controls.Alert.NO;
+                       if (mapEvent.params.cancel          ) buttons|=mx.controls.Alert.CANCEL;
+                       if (mapEvent.params.ok || buttons==0) buttons|=mx.controls.Alert.OK;
+                       trace("showing alert with "+buttons);
+                       Alert.show(mapEvent.params.message, 'Error', buttons, null, function(closeEvent:CloseEvent):void { 
+                               switch (closeEvent.detail) {
+                                       case mx.controls.Alert.CANCEL:  mapEvent.params.cancel(); break;
+                                       case mx.controls.Alert.YES:             mapEvent.params.yes(); break;
+                                       case mx.controls.Alert.NO:              mapEvent.params.no(); break;
+                                       default:                                                if (mapEvent.params.ok) mapEvent.params.ok();
+                               }
+                       });
+               }
+
+               /** Highlight an entity in response to an 'attention' event */
+
+               public function onAttention(event:AttentionEvent):void {
+                       var entity:Entity=event.entity;
+                       if (entity is Relation) {
+                               // If it's a relation, just bring up the editor panel
+                               var panel:RelationEditorPanel = RelationEditorPanel(
+                                       PopUpManager.createPopUp(Application(Application.application), RelationEditorPanel, true));
+                               panel.setRelation(entity as Relation);
+                               PopUpManager.centerPopUp(panel);
+                               return;
+                       }
+
+                       var lat:Number, lon:Number;
+                       var panTo:Boolean=true;
+                       if (entity is Way) {
+                               // If it's a way, find if it's on-screen
+                               for (var i:uint=0; i<Way(entity).length; i++) {
+                                       var node:Node=Way(entity).getNode(i)
+                                       if (node.within(theMap.edge_l,theMap.edge_r,theMap.edge_t,theMap.edge_b)) { panTo=false; }
+                                       lat=node.lat; lon=node.lon;
+                               }
+                       } else if (entity is Node) {
+                               // If it's a node, check if it's on-screen
+                               if (entity.within(theMap.edge_l,theMap.edge_r,theMap.edge_t,theMap.edge_b)) { panTo=false; }
+                               lat=Node(entity).lat; lon=Node(entity).lon;
+                       }
+                       // Pan if required, and select the object
+                       if (panTo) { theMap.moveMapFromLatLon(lat,lon); }
+                       theController.setState(theController.findStateForSelection([entity]));
+               }
+
+               /** Display floating warning in response to an 'alert' event */
+
+               public function onAlert(event:AttentionEvent):void {
+                       var alert:FloatingAlert=new FloatingAlert(event.message);
+                       stage.addChild(alert);
                }
 
         public function onResizeMap():void {
                }
 
         public function onResizeMap():void {