[Commits] r907 - apps/opengeo/geoexplorer/trunk/lib

commits at geoext.org commits at geoext.org
Fri May 29 21:05:26 CEST 2009


Author: tcoulter
Date: 2009-05-29 21:05:26 +0200 (Fri, 29 May 2009)
New Revision: 907

Modified:
   apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
Log:
Add multiple source combo box in the CapsGrid window. This should fix #206.

Modified: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js	2009-05-29 19:04:29 UTC (rev 906)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js	2009-05-29 19:05:26 UTC (rev 907)
@@ -88,7 +88,7 @@
     load: function() {
         
         this.layerSources = new Ext.data.SimpleStore({
-            fields: ["id", "name", "store"],
+            fields: ["identifier", "name", "store"],
             data: []
         });
         
@@ -110,18 +110,27 @@
                     // Create a new scope for 'id'.
                     return function(done){
                         var store = new GeoExt.data.WMSCapabilitiesStore();
-                        var url = this.createWMSCapabilitiesURL(this.ows[id])
+                        var url = this.createWMSCapabilitiesURL(this.ows[id]);
                         
                         OpenLayers.Request.GET({
                             proxy: this.proxy, 
                             url: url,
                             success: function(request){
                                 var data = request.responseXML || request.responseText
+                                
+                                // Read the response. It's important to note that the
+                                // WMSCapabilitiesStore reads the data as well, though
+                                // we need to do it ourselves in order to maintain
+                                // low coupling.
+                                var format = new OpenLayers.Format.WMSCapabilities();
+                                var extractedData = format.read(data);
+ 
                                 store.loadData(data);
                                 
                                 var record = new this.layerSources.recordType({
                                     store: store,
-                                    id: id
+                                    identifier: id,
+                                    name: extractedData.service.title || id
                                 });
                                 
                                 this.layerSources.add(record);
@@ -413,7 +422,7 @@
             
             for(var i = 0; i < mapConfig.layers.length; ++i) {
                 var conf = mapConfig.layers[i];
-                var index = this.layerSources.find("id", conf.ows);
+                var index = this.layerSources.find("identifier", conf.ows);
                 
                 if (index == -1) {
                     continue;
@@ -476,8 +485,10 @@
      */
     initCapGrid: function(){
 
+        var firstSource = this.layerSources.getAt(0);
+
         var capGridPanel = new CapabilitiesGrid({
-            store: this.capabilities,
+            store: firstSource.data.store,
             mapPanel : this.mapPanel,
             layout: 'fit',
             region: 'center',
@@ -489,7 +500,22 @@
                 }
             }
         });
-
+        
+        var sourceComboBox = new Ext.form.ComboBox({
+            store: this.layerSources,
+            valueField: "identifier",
+            displayField: "name",
+            triggerAction: "all",
+            editable: false,
+            allowBlank: false,
+            mode: "local",
+            value: firstSource.data.identifier
+        });
+        
+        sourceComboBox.on("select", function(combo, record, index) {
+            capGridPanel.reconfigure(record.data.store, capGridPanel.getColumnModel());
+        }, this);
+        
         this.capGrid = new Ext.Window({
             title: "Available Layers",
             closeAction: 'hide',
@@ -499,6 +525,12 @@
             items: [
                 capGridPanel
             ],
+            tbar: [
+                new Ext.Toolbar.TextItem({
+                    text: "View available data from:"
+                }),
+                sourceComboBox
+            ],
             bbar: [
                 "->",
                 new Ext.Button({



More information about the Commits mailing list