[Commits] r2016 - in sandbox/mapgears/geoext.ux/ux/WMSBrowser: examples lib/GeoExt.ux lib/GeoExt.ux/data lib/GeoExt.ux/widgets resources/lang

commits at geoext.org commits at geoext.org
Fri Mar 19 18:29:40 CET 2010


Author: adube
Date: 2010-03-19 18:29:40 +0100 (Fri, 19 Mar 2010)
New Revision: 2016

Added:
   sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/data/
   sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/data/Store.js
Modified:
   sandbox/mapgears/geoext.ux/ux/WMSBrowser/examples/WMSBrowserExample.js
   sandbox/mapgears/geoext.ux/ux/WMSBrowser/examples/WMSBrowserInWindowExample.js
   sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/SingleFile.js
   sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/WMSBrowser.js
   sandbox/mapgears/geoext.ux/ux/WMSBrowser/resources/lang/fr.js
Log:
wmsbrowser - url validation and storing

Modified: sandbox/mapgears/geoext.ux/ux/WMSBrowser/examples/WMSBrowserExample.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WMSBrowser/examples/WMSBrowserExample.js	2010-03-19 16:14:51 UTC (rev 2015)
+++ sandbox/mapgears/geoext.ux/ux/WMSBrowser/examples/WMSBrowserExample.js	2010-03-19 17:29:40 UTC (rev 2016)
@@ -20,6 +20,7 @@
         region: "east",
         width: 500,
         gridPanelOptions: {'height': 210},
+        allowInvalidUrl: true,
         // comment the below line to have a 'textfield' instead of a 'combobox'
         serverStore: oServerStore,
         mapPanel: mapPanel

Modified: sandbox/mapgears/geoext.ux/ux/WMSBrowser/examples/WMSBrowserInWindowExample.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WMSBrowser/examples/WMSBrowserInWindowExample.js	2010-03-19 16:14:51 UTC (rev 2015)
+++ sandbox/mapgears/geoext.ux/ux/WMSBrowser/examples/WMSBrowserInWindowExample.js	2010-03-19 17:29:40 UTC (rev 2016)
@@ -67,6 +67,7 @@
             gridPanelOptions: {'height': 260},
             zoomOnLayerAdded: false,
             closeOnLayerAdded: true,
+            allowInvalidUrl: true,
             // comment the below line to have a 'textfield' instead of a 
             // 'combobox'.  oServerStore is in ./store.js
             serverStore: oServerStore,

Modified: sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/SingleFile.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/SingleFile.js	2010-03-19 16:14:51 UTC (rev 2015)
+++ sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/SingleFile.js	2010-03-19 17:29:40 UTC (rev 2016)
@@ -52,6 +52,7 @@
     };
 
     var jsfiles = new Array(
+        "data/Store.js",
         "widgets/WMSBrowser.js"
     );
 

Added: sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/data/Store.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/data/Store.js	                        (rev 0)
+++ sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/data/Store.js	2010-03-19 17:29:40 UTC (rev 2016)
@@ -0,0 +1,12 @@
+Ext.namespace("Ext.data.Store")
+
+Ext.data.Store.prototype.getValueArray = function(value) {
+    var aszValues = [];
+    var nValues = this.getCount();
+
+    for(var i=0; i<nValues; i++) {
+        aszValues.push(this.getAt(i).get(value));
+    }
+
+    return aszValues;
+};


Property changes on: sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/data/Store.js
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/WMSBrowser.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/WMSBrowser.js	2010-03-19 16:14:51 UTC (rev 2015)
+++ sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/WMSBrowser.js	2010-03-19 17:29:40 UTC (rev 2016)
@@ -58,6 +58,10 @@
 
     closeOnLayerAdded: false,
 
+    allowInvalidUrl: false,
+
+    currentUrl: null,
+
     /** private: method[constructor]
      */
     constructor: function(config) {
@@ -113,6 +117,9 @@
                 mode: 'local',
                 forceSelection: false,
                 triggerAction: 'all',
+                allowBlank: false,
+                validator:this.urlValidator,
+                invalidText: OpenLayers.i18n('The url address entered is not valid.'),
                 emptyText:OpenLayers.i18n('Select or input a server address (URL)'),
                 selectOnFocus:true
             };
@@ -124,6 +131,9 @@
                 'name': 'wms_url',
                 'id': 'wms_url',
                 border: false,
+                allowBlank: false,
+                validator:this.urlValidator,
+                invalidText: OpenLayers.i18n('The url address entered is not valid.'),
                 'emptyText': OpenLayers.i18n('Input the server address (URL)')
             };
         }
@@ -212,13 +222,29 @@
     },
 
     triggerGetCapabilities: function() {
-        var url = Ext.getCmp('wms_url').getValue();
+        var urlField = Ext.getCmp('wms_url');
+        var url = urlField.getValue();
 
-        if(!url) {
-            alert(OpenLayers.i18n('Please, enter an url in the textbox first'));
-            return;
+        // if url in not valid
+        if(!urlField.isValid()) {
+            // if url is blank, throw error
+            if(!url) {
+                alert(OpenLayers.i18n('Please, enter an url in the textbox first'));
+                return;
+            }
+            // if url is not blank and the widget don't allow invalid urls, 
+            // throw error
+            else if (!this.allowInvalidUrl){
+                alert( OpenLayers.i18n('The url address entered is not valid.'));
+                return;
+            }
         }
 
+        // keep the inputed url in order to add it to the url store later if
+        // it was valid
+        this.currentUrl = url;
+
+        // add the GetCapabilities parameters to the url
         var params = OpenLayers.Util.getParameterString(this.capabilitiesParams);        
         url = OpenLayers.Util.urlAppend(url, params);
 
@@ -457,6 +483,8 @@
 
     onWMSCapabilitiesStoreLoad: function(store, records, options) {
         var srs = this.mapPanel.map.getProjection();
+        var grid = Ext.getCmp('wms_capabilities_grid_panel');
+        var urlField = Ext.getCmp('wms_url');
 
         // loop through all records (layers) to see if they contain the current
         // map projection
@@ -473,10 +501,19 @@
             }
         }
 
-        // select the first element of the list on load end
-        var grid = Ext.getCmp('wms_capabilities_grid_panel');
-        if(grid.store.getTotalCount() > 0) {
+        if(grid.store.getCount() > 0) {
+            // select the first element of the list on load end
             grid.getSelectionModel().selectRow(0);
+
+            // the url that was used was a valid WMS server, keep it if the
+            // url field is a combobox and if it's not already added
+            if(urlField.getXType() == Ext.form.ComboBox.xtype) {
+                var aszUrls = urlField.store.getValueArray('url');
+                if(OpenLayers.Util.indexOf(aszUrls, this.currentUrl) == -1) {
+                    var record = new Ext.data.Record({'url': this.currentUrl});
+                    urlField.store.add([record]);
+                }
+            }
         }
     },
 
@@ -516,5 +553,11 @@
 
     closeWindow: function() {
         this.ownerCt.hide();
+    },
+
+    urlValidator: function(url) {
+        var result = Ext.form.VTypes.url(url);
+
+        return result;
     }
 });

Modified: sandbox/mapgears/geoext.ux/ux/WMSBrowser/resources/lang/fr.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WMSBrowser/resources/lang/fr.js	2010-03-19 16:14:51 UTC (rev 2015)
+++ sandbox/mapgears/geoext.ux/ux/WMSBrowser/resources/lang/fr.js	2010-03-19 17:29:40 UTC (rev 2016)
@@ -21,5 +21,6 @@
     'Please, select a layer from the grid first.': "Veuillez sélectionner une couche dans la grille d'abord",
     'Please, enter an url in the textbox then click \'Connect\'.': "Veuillez entrer une url dans la boîte de texte puis cliquer sur 'Connexion'",
     'Close this window': "Fermer cette fenêtre",
-    'Close': "Fermer"
+    'Close': "Fermer",
+    'The url address entered is not valid.': "L'adresse url entrée est non conforme."
 });



More information about the Commits mailing list