[Commits] r1991 - sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/lib/GeoExt.ux/widgets

commits at geoext.org commits at geoext.org
Wed Mar 17 14:49:22 CET 2010


Author: adube
Date: 2010-03-17 14:49:22 +0100 (Wed, 17 Mar 2010)
New Revision: 1991

Modified:
   sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/lib/GeoExt.ux/widgets/WMSLayerAdder.js
Log:
wmslayeradder - close button when window, some error msg added

Modified: sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/lib/GeoExt.ux/widgets/WMSLayerAdder.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/lib/GeoExt.ux/widgets/WMSLayerAdder.js	2010-03-17 13:00:00 UTC (rev 1990)
+++ sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/lib/GeoExt.ux/widgets/WMSLayerAdder.js	2010-03-17 13:49:22 UTC (rev 1991)
@@ -67,6 +67,8 @@
         this.initMyToolbar();
 
         arguments.callee.superclass.constructor.call(this, config);
+
+        this.on("afterrender", this.onAfterRender, this);
     },
 
     initMyItems: function() {
@@ -209,7 +211,7 @@
         var url = Ext.getCmp('wms_url').getValue();
 
         if(!url) {
-            alert(OpenLayers.i18n('Please, enter an url in the textbox'));
+            alert(OpenLayers.i18n('Please, enter an url in the textbox first'));
             return;
         }
 
@@ -405,7 +407,7 @@
 
             var copy = record.copy();
 
-            // the following line gives "too much recursion".
+            // the following line gives a "too much recursion" error.
             //copy.set("layer", record.get("layer"));
             copy.data.layer = record.data.layer;
 
@@ -419,6 +421,16 @@
             this.mapPanel.map.zoomToExtent(
                 OpenLayers.Bounds.fromArray(copy.get("llbbox"))
             );
+        } else {
+            // means no record was selected
+            if(grid.store.getTotalCount() > 0) {
+                var error = "Please, select a layer from the grid first.";
+                alert(OpenLayers.i18n(error));
+            } else {
+                var error = "Please, enter an url in the textbox " + 
+                            "then click \'Connect\'.";
+                alert(OpenLayers.i18n(error));
+            }
         }
     },
 
@@ -451,5 +463,37 @@
         return (bool)
             ? '<span style="color:green;">' + OpenLayers.i18n("Yes") + '</span>'
             : '<span style="color:red;">' + OpenLayers.i18n("No") + '</span>';
+    },
+
+    /** private: method[onAfterRender]
+     *  Called after this element was rendered.
+     *  If the owner is a window, add a 'close' button.
+     */
+    onAfterRender : function() {
+        if(this.ownerCt.getXType() == Ext.Window.xtype) {
+            this.addCloseButton();
+        }
+    },
+
+    addCloseButton : function() {
+        var actionOptions = {
+            handler: this.closeWindow,
+            scope: this,
+            tooltip: OpenLayers.i18n('Close this window')
+        };
+
+        if (this.useIcons === true) {
+            actionOptions.iconCls = "gx-wmslayeradder-close";
+        } else {
+            actionOptions.text = OpenLayers.i18n('Close');
+        }
+
+        var action = new Ext.Action(actionOptions);
+
+        this.getBottomToolbar().add(action);
+    },
+
+    closeWindow: function() {
+        this.ownerCt.hide();
     }
 });



More information about the Commits mailing list