[fusion-commits] r2686 - in trunk: layers/MapGuide lib text widgets widgets/FeatureInfo widgets/Query widgets/Redline widgets/scalebar

svn_fusion at osgeo.org svn_fusion at osgeo.org
Fri Apr 5 04:44:40 PDT 2013


Author: jng
Date: 2013-04-05 04:44:39 -0700 (Fri, 05 Apr 2013)
New Revision: 2686

Modified:
   trunk/layers/MapGuide/MapGuideViewerApi.js
   trunk/lib/Map.js
   trunk/text/en
   trunk/widgets/FeatureInfo/featureinfomain.php
   trunk/widgets/Maptip.js
   trunk/widgets/Measure.js
   trunk/widgets/Pan.js
   trunk/widgets/Query/querymain.php
   trunk/widgets/Redline/editmarkup.php
   trunk/widgets/Redline/markupmain.php
   trunk/widgets/SelectPolygon.js
   trunk/widgets/SelectRadius.js
   trunk/widgets/Zoom.js
   trunk/widgets/scalebar/scalebar-fancy.css
   trunk/widgets/scalebar/scalebar-fat.css
   trunk/widgets/scalebar/scalebar-thin.css
   trunk/widgets/scalebar/scalebar-thinner.css
Log:
This mega submission includes the following changes to promote greater widget harmony wrt active digitizers. This set of changes resolves (http://trac.osgeo.org/mapguide/ticket/2254) and (http://trac.osgeo.org/mapguide/ticket/2253):
 - Map: Add 2 new events:
   - MAP_DIGITIZER_ACTIVATED: Raised when a digitizer is active
   - MAP_DIGITIZER_DEACTIVATED: Raised when a digitizer is deactivated
   - Any code that starts/stop digitization will trigger these necessary events
 - MapGuideViewerApi:
   - Trigger MAP_DIGITIZER_ACTIVATED and MAP_DIGITIZER_DEACTIVATED as appropriate on any DigitizeXXX API.
 - Zoom/Pan: 
   - Listen to MAP_DIGITIZER_ACTIVATED and MAP_DIGITIZER_DEACTIVATED
   - deactivate widget on active digitizer. Note mouse-wheel zooming is still possible here, which is a *good* thing as it means we're not constrained to the current map view when digitizing and can "move around" with some limited degree. However panning will be disabled and current OpenLayers hard-codes pan behaviour to the left mouse button. Ideally we want to switch to middle mouse for panning when this happens. That's a future TODO item.
   - activate widget when active digitizer's deactivated only if the widget was originally activated before digitization
 - FeatureInfo:
   - Tweak refresh label
   - Add an extra help blurb under "Select Features" section as you can use standard selection tools for this.
   - Add abort link in digitization prompt on map message bar
 - Query:
   - Add abort link in digitization prompt on map message bar
   - Clear map message bar on unload
 - Redline:
   - Tweak some button labels
   - Add missing unload hook in editmarkup.php to clear current map message and any active digitizers
   - Add abort link in digitization prompt on map message bar
 - SelectRadius: 
   - Make this widget not mutually-exclusive
   - Trigger MAP_DIGITIZER_ACTIVATED and MAP_DIGITIZER_DEACTIVATED as required
   - Add abort link in digitization prompt on map message bar
 - SelectPolygon:
   - Make this widget not mutually-exclusive
   - Trigger MAP_DIGITIZER_ACTIVATED and MAP_DIGITIZER_DEACTIVATED as required
   - Add abort link in digitization prompt on map message bar
 - Maptip: Listen to MAP_DIGITIZER_ACTIVATED and MAP_DIGITIZER_DEACTIAVTED and update a boolean control variable that determines whether a maptip should be displayed or a maptip query should be dispatched. This is to prevent the Maptip widget from interfering with digitizing operations.
 - Scalebar: Fix z-index in css

Modified: trunk/layers/MapGuide/MapGuideViewerApi.js
===================================================================
--- trunk/layers/MapGuide/MapGuideViewerApi.js	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/layers/MapGuide/MapGuideViewerApi.js	2013-04-05 11:44:39 UTC (rev 2686)
@@ -152,6 +152,7 @@
       if (mgApiActiveWidget) {
         mapWidget.deactivateWidget(mgApiActiveWidget);
       }
+      mapWidget.triggerEvent(Fusion.Event.MAP_DIGITIZER_ACTIVATED);
       
       var control = mgApiDrawControls[type];
       control.userHandler = handler;
@@ -201,12 +202,13 @@
         mgApiActiveControl.deactivate();
         mgApiActiveControl = null;
     }
-  if (mgApiActiveWidget) {
-    //var Fusion = window.top.Fusion;
     var mapWidget = Fusion.getWidgetById(mgApiMapWidgetId);
-    mapWidget.activateWidget(mgApiActiveWidget);
-    mgApiActiveWidget = null;
-  }
+    if (mgApiActiveWidget) {
+        //var Fusion = window.top.Fusion;
+        mapWidget.activateWidget(mgApiActiveWidget);
+        mgApiActiveWidget = null;
+    }
+    mapWidget.triggerEvent(Fusion.Event.MAP_DIGITIZER_DEACTIVATED);
 }
 
 // set the Stylemap for the MGAPI

Modified: trunk/lib/Map.js
===================================================================
--- trunk/lib/Map.js	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/lib/Map.js	2013-04-05 11:44:39 UTC (rev 2686)
@@ -83,8 +83,15 @@
  * Constant: Fusion.Event.MAP_MAP_GROUP_LOADED
  */
 Fusion.Event.MAP_MAP_GROUP_LOADED = Fusion.Event.lastEventId++;
-
 /**
+ * Constant: Fusion.Event.MAP_DIGITIZER_ACTIVATED
+ */
+Fusion.Event.MAP_DIGITIZER_ACTIVATED = Fusion.Event.lastEventId++;
+/**
+ * Constant: Fusion.Event.MAP_DIGITIZER_DEACTIVATED
+ */
+Fusion.Event.MAP_DIGITIZER_DEACTIVATED = Fusion.Event.lastEventId++;
+/**
  * Constant: Fusion.Constant.LAYER_POINT_TYPE
  */
 Fusion.Constant.LAYER_POINT_TYPE = 0;
@@ -282,6 +289,8 @@
         this.registerEventID(Fusion.Event.WMS_LAYER_ADDED);
         this.registerEventID(Fusion.Event.MAP_SCALE_RANGE_LOADED);
         this.registerEventID(Fusion.Event.MAP_MAP_GROUP_LOADED);
+        this.registerEventID(Fusion.Event.MAP_DIGITIZER_ACTIVATED);
+        this.registerEventID(Fusion.Event.MAP_DIGITIZER_DEACTIVATED);
 
         this.registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.mapLoaded,this));
         this.registerForEvent(Fusion.Event.MAP_RELOADED, OpenLayers.Function.bind(this.mapLoaded,this));

Modified: trunk/text/en
===================================================================
--- trunk/text/en	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/text/en	2013-04-05 11:44:39 UTC (rev 2686)
@@ -143,6 +143,7 @@
 FEATUREINFOSUBTITLE     = Select a Layer
 FEATUREINFOLAYER        = Layer:
 FEATUREINFOSELECTFEATURE= Select Features:
+FEATUREINFOEXTRAHELP    = Select features using the standard selection tools or select features based on the digitized geometry you select below
 FEATUREINFODIGITIZE     = Digitize:
 FEATUREINFOPOINT        = Point
 FEATUREINFORECTANGLE    = Rectangle
@@ -229,7 +230,8 @@
 REDLINEEDIT             = Add/Edit Redlines
 REDLINEREMOVEFROMMAP    = Remove From Map
 REDLINEDOWNLOADOPTIONS  = Download Options
-REDLINEDOWNLOAD         = Native Format
+REDLINEDOWNLOAD         = Download
+REDLINEDOWNLOADNATIVE   = Native Format
 REDLINEDOWNLOADKML      = KML Format
 REDLINEDOWNLOADKMZ      = KMZ Format
 REDLINEUPLOAD           = Upload Redline

Modified: trunk/widgets/FeatureInfo/featureinfomain.php
===================================================================
--- trunk/widgets/FeatureInfo/featureinfomain.php	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/widgets/FeatureInfo/featureinfomain.php	2013-04-05 11:44:39 UTC (rev 2686)
@@ -56,6 +56,7 @@
     $areaUndefinedLocal = GetLocalizedString('FEATUREINFOAREAUNDEFINE', $locale );
     $noLayerInfoLocal = GetLocalizedString('FEATUREINFONOINFO', $locale );
     $noFeatureInLocal = GetLocalizedString('FEATUREINFONOFEATUREIN', $locale );
+    $featureInfoExtraHelpLocal = GetLocalizedString('FEATUREINFOEXTRAHELP', $locale );
 
     $drawPointLocal = GetLocalizedString("REDLINEEDITPOINTHELP", $locale );
     $drawRectLocal = GetLocalizedString("REDLINEEDITRECTANGLEHELP", $locale );
@@ -130,7 +131,17 @@
 
         function SetMessage(msg) {
             var map = GetFusionMapWidget();
-            map.message.info(msg);
+            if (msg == DRAW_POINT_HELP || msg == DRAW_RECT_HELP || DRAW_POLY_HELP) {
+                map.message.info(msg + " <a id='measureMsgDismiss' href='javascript:void(0)'>" + OpenLayers.i18n("stop") + "</a>");
+                var link = map.message.container.ownerDocument.getElementById("measureMsgDismiss");
+                //Wire the anchor click
+                link.onclick = function() {
+                    ClearMessage();
+                    ClearDigitization(true);
+                };
+            } else {
+                map.message.info(msg);
+            }
         }
 
         function ClearMessage() {
@@ -262,7 +273,7 @@
                         document.getElementById('totalArea').innerHTML = '<?php echo $noLayerInfoLocal ?>';
                     }
                 } else {
-                  document.getElementById('totalFeatures').innerHTML = '<?php echo $noFeatureInLocal ?>';
+                    document.getElementById('totalFeatures').innerHTML = '<?php echo $noFeatureInLocal ?>';
                 }
 
 
@@ -309,8 +320,8 @@
 
 <table class="RegText" border="0" cellspacing="0" width="100%">
     <tr><td class="Title"><img id="busyImg" src="../../common/images/loader_inactive.gif" style="vertical-align:bottom"> <?php echo $titleLocal ?><hr></td></tr>
-    <tr><td class="SubTitle"><?php echo $subtitleLocal ?></td></tr>
-    <tr><td><?php echo $layerLocal ?> <a href="<?= $_SERVER['REQUEST_URI'] ?>">(<?= $refreshLocal ?>)</a></td></tr>
+    <tr><td class="SubTitle"><?php echo $subtitleLocal ?> <a href="<?= $_SERVER['REQUEST_URI'] ?>">(<?= $refreshLocal ?>)</a></td></tr>
+    <tr><td><?php echo $layerLocal ?></td></tr>
     <tr>
         <td class="RegText">
             <select size="1" class="Ctrl" id="layerSelect" onChange="OnLayerChange()" style="width: 100%">
@@ -329,6 +340,7 @@
     <tr><td class="Spacer"></td></tr>
 
     <tr><td class="SubTitle"><?php echo $selectFeatureLocal ?></td></tr>
+    <tr><td class="InfoText"><?php echo $featureInfoExtraHelpLocal ?></td></tr>
     <tr><td><?php echo $digitizeLocal ?></td></tr>
     <tr>
         <td align="center">

Modified: trunk/widgets/Maptip.js
===================================================================
--- trunk/widgets/Maptip.js	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/widgets/Maptip.js	2013-04-05 11:44:39 UTC (rev 2686)
@@ -122,8 +122,21 @@
         this.mapTipReqFinishedFunc = OpenLayers.Function.bind(this._display,this);
         this.mapBusyChangedFunc = this.busyChanged.bind(this);
         this.mapLoaded = this.startMapTips.bind(this);
+        
+        //Subscribe to digitizer events so we know when not to interfere
+        this.getMap().registerForEvent(Fusion.Event.MAP_DIGITIZER_ACTIVATED, OpenLayers.Function.bind(this.onDigitizerActivated, this));
+        this.getMap().registerForEvent(Fusion.Event.MAP_DIGITIZER_DEACTIVATED, OpenLayers.Function.bind(this.onDigitizerDeactivated, this));
     },
     
+    onDigitizerActivated: function() {
+        this.hideMaptip();
+        this.bDigitizerActive = true;
+    },
+    
+    onDigitizerDeactivated: function() {
+        this.bDigitizerActive = false;
+    },
+    
     setUiObject: function(uiObj) {
         Fusion.Widget.uiInstances[this.type].push(this);
 
@@ -164,7 +177,7 @@
                 }).bind(this)
         }).addTo(uiObj);
         if (this.widgetTag.tooltip) {
-          this.mapTipBtn.setTooltip(this.widgetTag.tooltip);
+            this.mapTipBtn.setTooltip(this.widgetTag.tooltip);
         }
         if (uiObj.options.active) {
             this.mapTipBtn.setActive(true);
@@ -271,12 +284,17 @@
     },
     
     showMaptip: function() {
+        if (this.bDigitizerActive === true) {
+            //console.log("Abort maptip query");
+            return;
+        }
         this.getMapLayer().getMapTip(this);
         this.mapTipFired = true;
     },
     
     _display: function(eventID,oMapTip) {
-        if (typeof(oMapTip) == "undefined" || oMapTip.t == '') {
+        if (this.bDigitizerActive === true || typeof(oMapTip) == "undefined" || oMapTip.t == '') {
+            //console.log("Abort maptip display");
             return;
         }
         if(this.domObj.style.visibility != 'visible' || oMapTip.t != this.szTip ){

Modified: trunk/widgets/Measure.js
===================================================================
--- trunk/widgets/Measure.js	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/widgets/Measure.js	2013-04-05 11:44:39 UTC (rev 2686)
@@ -206,11 +206,11 @@
     },
     
     clearMeasure: function() {
-      this.control.cancel();
+        this.control.cancel();
     },
 
     toggleClearButton: function(enabled) {
-      this.clearButton.setEnabled(enabled);
+        this.clearButton.setEnabled(enabled);
     },
 
     extentsChangedCB: function() {
@@ -466,6 +466,8 @@
         OpenLayers.Event.observe(document,"keypress",this.keyHandler);
         this.getMap().supressContextMenu(true);
         this.updateButtonStates();
+        //This is digitization, so trigger the necessary event
+        this.getMap().triggerEvent(Fusion.Event.MAP_DIGITIZER_ACTIVATED);
     },
     
     stopMeasurement: function() {
@@ -475,6 +477,8 @@
         this.getMap().message.clear();
         this.getMap().supressContextMenu(false);
         this.updateButtonStates();
+        //This is digitization, so trigger the necessary event
+        this.getMap().triggerEvent(Fusion.Event.MAP_DIGITIZER_DEACTIVATED);
     },
     
     updateButtonStates: function() {

Modified: trunk/widgets/Pan.js
===================================================================
--- trunk/widgets/Pan.js	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/widgets/Pan.js	2013-04-05 11:44:39 UTC (rev 2686)
@@ -48,14 +48,36 @@
         
         this.cursorNormal = [grabpath, 'grab', '-moz-grab', 'move'];
         this.cursorDrag = [grabbingpath, 'grabbing', '-moz-grabbing', 'move'];
+        
+        //We're interested in these events, because this widget could get in the way
+        this.getMap().registerForEvent(Fusion.Event.MAP_DIGITIZER_ACTIVATED, OpenLayers.Function.bind(this.onDigitizerActivated, this));
+        this.getMap().registerForEvent(Fusion.Event.MAP_DIGITIZER_DEACTIVATED, OpenLayers.Function.bind(this.onDigitizerDeactivated, this));
     },
+    
+    onDigitizerActivated: function() {
+        this.bRestoreActiveState = this.isActive;
+        //TODO: What we really want is to do is filter out the valid mouse buttons for a drag. So we can
+        //still pan while digitizing via the middle mouse button.
+        //This is an OpenLayers-level limitation (the drag handler is hardcoded to left mouse button)
+        this.deactivate();
+    },
+    
+    onDigitizerDeactivated: function() {
+        if (this.bRestoreActiveState === true) {
+            this.activate();
+            this.bRestoreActiveState = false;
+        }
+    },
 
     activate : function() {
+        //TODO: Why Fusion.Widget has no active state flag? Probably should have one
+        this.isActive = true;
         this.control.activate();
         this.getMap().setCursor(this.cursorNormal);
     },
     
     deactivate: function() {
+        this.isActive = false;
         /*console.log('Pan.deactivate');*/
         this.control.deactivate();
         this.getMap().setCursor('auto');

Modified: trunk/widgets/Query/querymain.php
===================================================================
--- trunk/widgets/Query/querymain.php	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/widgets/Query/querymain.php	2013-04-05 11:44:39 UTC (rev 2686)
@@ -181,14 +181,19 @@
         {
             ClearDigitization();
             var map = Fusion.getMapByName(mapName).mapWidget;
-            map.message.info("<?= $rectangleHelpLocal ?>");
+            map.message.info("<?= $rectangleHelpLocal ?>" + " <a id='digitizeDismiss' href='javascript:void(0)'>" + OpenLayers.i18n("stop") + "</a>");
+            var link = map.message.container.ownerDocument.getElementById("digitizeDismiss");
+            //Wire the anchor click
+            link.onclick = function() {
+                ClearMessage();
+                ClearDigitization(true);
+            };
             DigitizeRectangle(OnRectangleDigitized);
         }
 
         function OnRectangleDigitized(rectangle)
         {
-            var map = Fusion.getMapByName(mapName).mapWidget;
-            map.message.clear();
+            ClearMessage();
             var geomText = "5,"
                 + rectangle.Point1.X + "," + rectangle.Point1.Y + ","
                 + rectangle.Point2.X + "," + rectangle.Point1.Y + ","
@@ -203,14 +208,19 @@
         {
             ClearDigitization();
             var map = Fusion.getMapByName(mapName).mapWidget;
-            map.message.info("<?= $polygonHelpLocal ?>");
+            map.message.info("<?= $polygonHelpLocal ?>" + " <a id='digitizeDismiss' href='javascript:void(0)'>" + OpenLayers.i18n("stop") + "</a>");
+            var link = map.message.container.ownerDocument.getElementById("digitizeDismiss");
+            //Wire the anchor click
+            link.onclick = function() {
+                ClearMessage();
+                ClearDigitization(true);
+            };
             DigitizePolygon(OnPolyonDigitized);
         }
 
         function OnPolyonDigitized(polygon)
         {
-            var map = Fusion.getMapByName(mapName).mapWidget;
-            map.message.clear();
+            ClearMessage();
             var geomText = polygon.Count;
             for (var i = 0; i < polygon.Count; i++)
             {
@@ -415,9 +425,16 @@
 
         function OnUnload()
         {
-            ClearDigitization();
+            ClearMessage();
+            ClearDigitization(true);
             ToggleSpatialFilter(false);
         }
+        
+        function ClearMessage() 
+        {
+            var map = GetFusionMapWidget();
+            map.message.clear();
+        }
 
         function OnResize()
         {

Modified: trunk/widgets/Redline/editmarkup.php
===================================================================
--- trunk/widgets/Redline/editmarkup.php	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/widgets/Redline/editmarkup.php	2013-04-05 11:44:39 UTC (rev 2686)
@@ -143,7 +143,19 @@
             var widget = Fusion.getWidgetsByType("Redline")[0];
             if (widget.mapMessagePrompt) {
                 var map = Fusion.getMapByName(mapName).mapWidget;
-                map.message.info(text);
+                var msg = map.message;
+                //It's a digitization prompt
+                if (text != EDIT_DEFAULT_HELP) {
+                    msg.info(text + ' <a id="abortDigitizationLink" href="javascript:void(0)">' + OpenLayers.i18n("stop") + '</a>');
+                    var link = msg.container.ownerDocument.getElementById("abortDigitizationLink");
+                    //Wire the anchor click
+                    link.onclick = function() {
+                        msg.clear();
+                        PromptAndSetMarkupText();
+                    };
+                } else {
+                    msg.info(text);
+                }
             }
         }
 
@@ -348,10 +360,17 @@
         <?php } ?>
             SetDigitizeInfo(EDIT_DEFAULT_HELP);
         }
+        
+        function OnUnload()
+        {
+            ClearDigitization(true);
+            var map = Fusion.getMapByName(mapName).mapWidget;
+            map.message.clear();
+        }
     </script>
 </head>
 
-<body onLoad="OnLoad()" marginwidth=5 marginheight=5 leftmargin=5 topmargin=5 bottommargin=5 rightmargin=5>
+<body onLoad="OnLoad()" onUnload="OnUnload()" marginwidth=5 marginheight=5 leftmargin=5 topmargin=5 bottommargin=5 rightmargin=5>
 
 <form action="editmarkup.php" method="post" enctype="application/x-www-form-urlencoded" id="editForm" target="_self">
 <table class="RegText" border="0" cellspacing="0" width="100%">

Modified: trunk/widgets/Redline/markupmain.php
===================================================================
--- trunk/widgets/Redline/markupmain.php	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/widgets/Redline/markupmain.php	2013-04-05 11:44:39 UTC (rev 2686)
@@ -94,6 +94,7 @@
         $addEditLocal = GetLocalizedString('REDLINEEDIT', $locale );
         $removeFromMapLocal = GetLocalizedString('REDLINEREMOVEFROMMAP', $locale );
         $downloadLocal = GetLocalizedString('REDLINEDOWNLOAD', $locale );
+        $downloadNativeLocal = GetLocalizedString('REDLINEDOWNLOADNATIVE', $locale );
         $uploadLocal = GetLocalizedString('REDLINEUPLOAD', $locale );
         $editStyleLocal = GetLocalizedString('REDLINEEDITSTYLE', $locale );
         $redlineCreateFailureLocal = GetLocalizedString('REDLINECREATEFAILURE', $locale );
@@ -377,7 +378,7 @@
             <input class="Ctrl" type="button" id="openBtn" onClick="SubmitCommand(CMD_OPEN)" value="<?=$addToMapLocal?>" style="width:95px">
             <input class="Ctrl" type="button" id="deleteBtn" onClick="SubmitCommand(CMD_DELETE)" value="<?=$deleteLocal?>" style="width:95px">
             <input class="Ctrl" type="button" id="downloadBtn" onClick="SubmitCommand(CMD_DOWNLOAD)" value="<?=$downloadLocal?>" style="width:95px">
-            <br><br>
+            <br/><br/>
         </td>
     </tr>
     <tr><td class="SubTitle"><?=$otherOptionsLocal?></td></tr>
@@ -414,7 +415,7 @@
     <tr><td class="SubTitle"><?=$downloadOptionsLocal?></td></tr>
     <tr>
         <td>
-            <input class="Ctrl" type="button" id="downloadDataBtn" onClick="SubmitCommand(CMD_DOWNLOAD_LAYER_DATA)" value="<?=$downloadLocal?>" style="width:95px">
+            <input class="Ctrl" type="button" id="downloadDataBtn" onClick="SubmitCommand(CMD_DOWNLOAD_LAYER_DATA)" value="<?=$downloadNativeLocal?>" style="width:95px">
             <input class="Ctrl" type="button" id="downloadKmlBtn" onClick="SubmitCommand(CMD_DOWNLOAD_KML)" value="<?=$downloadKmlLocal?>" style="width:95px">
             <input class="Ctrl" type="button" id="downloadKmzBtn" onClick="SubmitCommand(CMD_DOWNLOAD_KMZ)" value="<?=$downloadKmzLocal?>" style="width:95px">
         </td>

Modified: trunk/widgets/SelectPolygon.js
===================================================================
--- trunk/widgets/SelectPolygon.js	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/widgets/SelectPolygon.js	2013-04-05 11:44:39 UTC (rev 2686)
@@ -33,7 +33,7 @@
  * **********************************************************************/
 
 Fusion.Widget.SelectPolygon = OpenLayers.Class(Fusion.Widget, {
-    isExclusive: true,
+    isExclusive: false,
     uiClass: Jx.Button,
     bActiveOnly: false, //only select feature(s) on the active layer?
     selectionType: 'INTERSECTS',
@@ -63,12 +63,20 @@
         this.handlerOptions = {};
         this.handler = new OpenLayers.Handler.Polygon(this, {done: this.execute}, this.handlerOptions);
         mapWidget.handlers.push(this.handler);
+        
+        this.keyHandler = OpenLayers.Function.bind(this.onKeyPress, this);
     },
     
+    onKeyPress: function(e) {
+        var charCode = (e.charCode ) ? e.charCode : ((e.keyCode) ? e.keyCode : e.which);
+        if (charCode == OpenLayers.Event.KEY_ESC) {
+            this.deactivate();
+        }
+    },
+    
     shouldActivateWith: function(widget) {
         return (widget instanceof Fusion.Widget.SelectPolygon &&
                 widget.widgetUniqueId == this.widgetUniqueId);
-        
     },
     
     /**
@@ -77,11 +85,17 @@
      * as a widget in the map
      */
     activate: function() {
+        OpenLayers.Event.observe(document,"keypress",this.keyHandler);
         this.handler.activate();
         var map = this.getMap();
-        map.message.info(OpenLayers.i18n("selectPolygonPrompt"))
+        var msg = map.message;
+        msg.info(OpenLayers.i18n("selectPolygonPrompt") + ' <a id="abortSelectPolygonLink" href="javascript:void(0)">' + OpenLayers.i18n("stop") + '</a>');
+        var link = msg.container.ownerDocument.getElementById("abortSelectPolygonLink");
+        //Wire the anchor click
+        link.onclick = OpenLayers.Function.bind(this.deactivate, this);
         map.setCursor(this.asCursor);
         map.supressContextMenu(true);
+        this.getMap().triggerEvent(Fusion.Event.MAP_DIGITIZER_ACTIVATED);
     },
 
     /**
@@ -89,13 +103,14 @@
      * This function should be defined for all functions that register
      * as a widget in the map
      **/
-    deactivate: function()
-    {
+    deactivate: function() {
+        OpenLayers.Event.stopObserving(document,"keypress",this.keyHandler);
         this.handler.deactivate();
         var map = this.getMap();
         map.message.clear();
         map.setCursor('auto');
         map.supressContextMenu(false);
+        this.getMap().triggerEvent(Fusion.Event.MAP_DIGITIZER_DEACTIVATED);
     },
     
     /**
@@ -109,7 +124,7 @@
         options.computed = this.bComputeMetadata;
         
         if (this.handler.evt.ctrlKey) {
-          options.extendSelection = true;
+            options.extendSelection = true;
         }
 
         if (this.bActiveOnly) {
@@ -122,6 +137,7 @@
         }
         
         this.getMap().query(options);
+        this.deactivate();
         return false;
     },
     

Modified: trunk/widgets/SelectRadius.js
===================================================================
--- trunk/widgets/SelectRadius.js	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/widgets/SelectRadius.js	2013-04-05 11:44:39 UTC (rev 2686)
@@ -34,7 +34,7 @@
 Fusion.Event.RADIUS_WIDGET_ACTIVATED = Fusion.Event.lastEventId++;
 
 Fusion.Widget.SelectRadius = OpenLayers.Class(Fusion.Widget, {
-    isExclusive: true,
+    isExclusive: false,
     uiClass: Jx.Button,
     selectionType: 'INTERSECTS',
     bActiveOnly: false, //only select feature(s) on the active layer?
@@ -92,6 +92,8 @@
             move: this.mouseMove
             }, this.handlerOptions);
         mapWidget.handlers.push(this.handler);
+        
+        this.keyHandler = OpenLayers.Function.bind(this.onKeyPress, this);
     },
     
     setRadius: function(r) {
@@ -106,12 +108,20 @@
         }
     },
     
+    onKeyPress: function(e) {
+        var charCode = (e.charCode ) ? e.charCode : ((e.keyCode) ? e.keyCode : e.which);
+        if (charCode == OpenLayers.Event.KEY_ESC) {
+            this.deactivate();
+        }
+    },
+    
     /**
      * activate the widget (listen to mouse events and change cursor)
      * This function should be defined for all functions that register
      * as a widget in the map
      */
     activate: function() {
+        OpenLayers.Event.observe(document,"keypress",this.keyHandler);
         var radius = this.getMap().pixToGeoMeasure(this.defaultRadius);
         this.handler.setOptions({radius: radius});
         this.handler.activate();
@@ -119,9 +129,14 @@
         map.setCursor(this.asCursor);
         /*map units for tool tip*/
         this.units = map.units;
-        map.message.info(OpenLayers.i18n("selectRadiusPrompt"))
+        var msg = map.message;
+        msg.info(OpenLayers.i18n("selectRadiusPrompt") + ' <a id="abortSelectRadiusLink" href="javascript:void(0)">' + OpenLayers.i18n("stop") + '</a>');
+        var link = msg.container.ownerDocument.getElementById("abortSelectRadiusLink");
+        //Wire the anchor click
+        link.onclick = OpenLayers.Function.bind(this.deactivate, this);
         map.supressContextMenu(true);
         this.triggerEvent(Fusion.Event.RADIUS_WIDGET_ACTIVATED, true);
+        this.getMap().triggerEvent(Fusion.Event.MAP_DIGITIZER_ACTIVATED);
     },
 
     /**
@@ -130,6 +145,7 @@
      * as a widget in the map
      **/
     deactivate: function() {
+        OpenLayers.Event.stopObserving(document,"keypress",this.keyHandler);
         this.handler.deactivate();
         var map = this.getMap();
         map.message.clear();
@@ -137,6 +153,7 @@
         map.supressContextMenu(false);
         /*icon button*/
         this.triggerEvent(Fusion.Event.RADIUS_WIDGET_ACTIVATED, false);
+        this.getMap().triggerEvent(Fusion.Event.MAP_DIGITIZER_DEACTIVATED);
     },
     
     /**
@@ -147,25 +164,25 @@
      * @param e Event the event that happened on the mapObj
      */
     mouseDown: function(geom) {
-      var evt = this.handler.evt;
-      if (OpenLayers.Event.isLeftClick(evt)) {
-          this.handler.fixedRadius = false;
-          
-          var p = this.getMap().getEventPosition(evt);
-          var point = this.getMap().pixToGeo(p.x, p.y);
-          var radius = this.getMap().pixToGeoMeasure(this.handler.radius);
-          
-          if (this.radiusTip && this.radiusTipType == 'dynamic') {
-              this.radiusTip.style.display = 'block';
-              var size = $(this.radiusTip).getBorderBoxSize();
-              this.radiusTip.style.top = (p.y - size.height*2) + 'px';
-              this.radiusTip.style.left = p.x + 'px';
-              if (this.units == 'm' || this.units == 'ft') {
-                  radius = Math.round(radius * 100)/100;
-              }
-              this.radiusTip.innerHTML = radius + this.units;
-          }
-      }
+        var evt = this.handler.evt;
+        if (OpenLayers.Event.isLeftClick(evt)) {
+            this.handler.fixedRadius = false;
+
+            var p = this.getMap().getEventPosition(evt);
+            var point = this.getMap().pixToGeo(p.x, p.y);
+            var radius = this.getMap().pixToGeoMeasure(this.handler.radius);
+
+            if (this.radiusTip && this.radiusTipType == 'dynamic') {
+                this.radiusTip.style.display = 'block';
+                var size = $(this.radiusTip).getBorderBoxSize();
+                this.radiusTip.style.top = (p.y - size.height*2) + 'px';
+                this.radiusTip.style.left = p.x + 'px';
+                if (this.units == 'm' || this.units == 'ft') {
+                    radius = Math.round(radius * 100)/100;
+                }
+                this.radiusTip.innerHTML = radius + this.units;
+            }
+        }
     },
 
     /**
@@ -177,26 +194,26 @@
      */
     mouseMove: function(geom) {
         
-      var evt = this.handler.evt;
-      if (OpenLayers.Event.isLeftClick(evt)) {
-        var map = this.getMap();
-        var p = map.getEventPosition(evt);
-        var point = map.pixToGeo(p.x, p.y);
-        //var center = this.circle.center;
-        
-        var radius = this.getMap().pixToGeoMeasure(this.handler.radius);//Math.sqrt(Math.pow(center.x-point.x,2) + Math.pow(center.y-point.y,2));
+        var evt = this.handler.evt;
+        if (OpenLayers.Event.isLeftClick(evt)) {
+            var map = this.getMap();
+            var p = map.getEventPosition(evt);
+            var point = map.pixToGeo(p.x, p.y);
+            //var center = this.circle.center;
 
-        if (this.radiusTip && this.radiusTipType == 'dynamic') {
-            this.radiusTip.style.display = 'block';
-            var size = $(this.radiusTip).getBorderBoxSize();
-            this.radiusTip.style.top = (p.y - size.height*2) + 'px';
-            this.radiusTip.style.left = p.x + 'px';
-            if (this.units == 'm' || this.units == 'ft') {
-                radius = Math.round(radius * 100)/100;
+            var radius = this.getMap().pixToGeoMeasure(this.handler.radius);//Math.sqrt(Math.pow(center.x-point.x,2) + Math.pow(center.y-point.y,2));
+
+            if (this.radiusTip && this.radiusTipType == 'dynamic') {
+                this.radiusTip.style.display = 'block';
+                var size = $(this.radiusTip).getBorderBoxSize();
+                this.radiusTip.style.top = (p.y - size.height*2) + 'px';
+                this.radiusTip.style.left = p.x + 'px';
+                if (this.units == 'm' || this.units == 'ft') {
+                    radius = Math.round(radius * 100)/100;
+                }
+                this.radiusTip.innerHTML = radius + this.units;
             }
-            this.radiusTip.innerHTML = radius + this.units;
         }
-      }
     },
     
     /**
@@ -212,7 +229,7 @@
             this.radiusTip.innerHTML = '';
         }
         if (this.handler.start == this.handler.last) {
-          this.handler.clear();
+            this.handler.clear();
         }
 
         var options = {};
@@ -234,6 +251,7 @@
         }
         
         this.getMap().query(options);
+        this.deactivate();
     },
     
     setParameter : function(param, value) {

Modified: trunk/widgets/Zoom.js
===================================================================
--- trunk/widgets/Zoom.js	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/widgets/Zoom.js	2013-04-05 11:44:39 UTC (rev 2686)
@@ -65,8 +65,28 @@
                                         {keyMask:OpenLayers.Handler.MOD_SHIFT});
         mapWidget.handlers.push(this.handler);
         mapWidget.handlers.push(this.shiftHandler);
+        
+        //We're interested in these events, because this widget could get in the way
+        this.getMap().registerForEvent(Fusion.Event.MAP_DIGITIZER_ACTIVATED, OpenLayers.Function.bind(this.onDigitizerActivated, this));
+        this.getMap().registerForEvent(Fusion.Event.MAP_DIGITIZER_DEACTIVATED, OpenLayers.Function.bind(this.onDigitizerDeactivated, this));
     },
     
+    onDigitizerActivated: function() {
+        //Do not allow this widget to interfere with active digitization, but do record the active state
+        //so we can restore it afterwards
+        this.bRestoreActiveState = this.isActive;
+        //NOTE: This only deactivates zoom by mouse click and box drag. Mouse wheel zoom is still active, which
+        //is a *good* thing.
+        this.deactivate();
+    },
+    
+    onDigitizerDeactivated: function() {
+        if (this.bRestoreActiveState === true) {
+            this.activate();
+            this.bRestoreActiveState = false;
+        }
+    },
+    
     shouldActivateWith: function(widget) {
         return (widget instanceof Fusion.Widget.SelectPolygon &&
                 widget.widgetUniqueId == this.widgetUniqueId);
@@ -79,6 +99,8 @@
      * as a widget in the map
      */
     activate : function() {
+        //TODO: Why Fusion.Widget has no active state flag? Probably should have one
+        this.isActive = true;
         //console.log('Zoom.activate');
         this.handler.activate();
         this.shiftHandler.activate();
@@ -97,6 +119,7 @@
      * as a widget in the map
      **/
     deactivate : function() {
+        this.isActive = false;
         //console.log('Zoom.deactivate');
         this.handler.deactivate();
         this.shiftHandler.deactivate();

Modified: trunk/widgets/scalebar/scalebar-fancy.css
===================================================================
--- trunk/widgets/scalebar/scalebar-fancy.css	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/widgets/scalebar/scalebar-fancy.css	2013-04-05 11:44:39 UTC (rev 2686)
@@ -1,5 +1,6 @@
 .sbWrapper {
     position: absolute;
+    z-index: 1000;
     margin: 25px 50% 0 50%;
     font-family: "Lucida Grande", Georgia, "Times New Roman", Times, serif;
 }

Modified: trunk/widgets/scalebar/scalebar-fat.css
===================================================================
--- trunk/widgets/scalebar/scalebar-fat.css	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/widgets/scalebar/scalebar-fat.css	2013-04-05 11:44:39 UTC (rev 2686)
@@ -1,5 +1,6 @@
 .sbWrapper {
     position: absolute;
+    z-index: 1000;
     margin: 25px 50% 0 50%;
     font-family: Verdana, sans-serif;
 }

Modified: trunk/widgets/scalebar/scalebar-thin.css
===================================================================
--- trunk/widgets/scalebar/scalebar-thin.css	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/widgets/scalebar/scalebar-thin.css	2013-04-05 11:44:39 UTC (rev 2686)
@@ -1,5 +1,6 @@
 .sbWrapper {
     position: absolute;
+    z-index: 1000;
     margin: 25px 50% 0 50%;
     font-family: Tahoma, Arial, Verdana, sans-serif;
 }

Modified: trunk/widgets/scalebar/scalebar-thinner.css
===================================================================
--- trunk/widgets/scalebar/scalebar-thinner.css	2013-04-05 06:24:33 UTC (rev 2685)
+++ trunk/widgets/scalebar/scalebar-thinner.css	2013-04-05 11:44:39 UTC (rev 2686)
@@ -1,5 +1,6 @@
 .sbWrapper {
     position: absolute;
+    z-index: 1000;
     margin: 25px 50% 0 50%;
     font-family: Tahoma, Arial, Verdana, sans-serif;
 }



More information about the fusion-commits mailing list