[Commits] r1961 - in sandbox/mapgears/geoext.ux/ux/WMSLayerAdder: examples lib/GeoExt.ux/widgets

commits at geoext.org commits at geoext.org
Mon Mar 15 19:19:24 CET 2010


Author: adube
Date: 2010-03-15 19:19:24 +0100 (Mon, 15 Mar 2010)
New Revision: 1961

Modified:
   sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/examples/WMSLayerAdderExample.html
   sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/examples/WMSLayerAdderExample.js
   sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/lib/GeoExt.ux/widgets/WMSLayerAdder.js
Log:
wmslayeradder - layout reorganization

Modified: sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/examples/WMSLayerAdderExample.html
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/examples/WMSLayerAdderExample.html	2010-03-15 12:40:43 UTC (rev 1960)
+++ sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/examples/WMSLayerAdderExample.html	2010-03-15 18:19:24 UTC (rev 1961)
@@ -1,6 +1,6 @@
 <html>
     <head>
-        <title>RedLiningPanel Example</title>
+        <title>WMSLayerAdder Example</title>
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
         <!-- ext version 3.1.0 -->
         <script type="text/javascript" src="../../../../ext/adapter/ext/ext-base.js"></script>

Modified: sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/examples/WMSLayerAdderExample.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/examples/WMSLayerAdderExample.js	2010-03-15 12:40:43 UTC (rev 1960)
+++ sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/examples/WMSLayerAdderExample.js	2010-03-15 18:19:24 UTC (rev 1961)
@@ -1,5 +1,7 @@
 var WMSLayerAdder, mapPanel;
 
+//OpenLayers.ProxyHost = "./proxy.py?url=";
+
 Ext.onReady(function() {
 
     Ext.QuickTips.init();
@@ -13,10 +15,20 @@
         zoom: 6
     });
 
+    var oServerStore  = new Ext.data.SimpleStore({
+        fields: ['url'],
+        data : [
+            ["http://127.0.0.1/cgi-bin/mapserv?map=/home/adube/proj/bdga/msp/wms/bdga.map"],
+            ['http://dev4g.mapgears.com/cgi-bin/mapserv?map=/home/mapgears/proj/geoprisma-demo/map/gmap/gmap75_wms.map']
+        ]
+    });
+
     WMSLayerAdder = new GeoExt.ux.WMSLayerAdder({
         title: OpenLayers.i18n("WMSLayerAdder"),
         region: "east",
         width: 500,
+        gridPanelOptions: {'height': 227},
+        serverStore: oServerStore,
         map: mapPanel.map
     });
 

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-15 12:40:43 UTC (rev 1960)
+++ sandbox/mapgears/geoext.ux/ux/WMSLayerAdder/lib/GeoExt.ux/widgets/WMSLayerAdder.js	2010-03-15 18:19:24 UTC (rev 1961)
@@ -22,9 +22,273 @@
  */
 GeoExt.ux.WMSLayerAdder = Ext.extend(Ext.Panel, {
 
+    layout: 'fit',
+
+    minWidth: 300,
+    minHeight: 200,
+    plain:true,
+    bodyStyle:'padding:5px;',
+    buttonAlign:'center',
+
+    serverStore: null,
+
+    serverStoreDisplayField: 'url',
+
+    capabilitiesParams: {},
+
+    defaultCapabilitiesParams: {
+       'service': "WMS",
+       'request': "GetCapabilities",
+       'version': '1.1.1'
+    },
+
+    gridPanelOptions: {
+        'height': 200
+    },
+
     /** private: method[constructor]
      */
     constructor: function(config) {
+        this.serverStore = config.serverStore || null;
+        
+        OpenLayers.Util.applyDefaults(
+            this.capabilitiesParams, this.defaultCapabilitiesParams);
+
+        this.initMyItems();
+
         arguments.callee.superclass.constructor.call(this, config);
-    }
+    },
+
+    initMyItems: function() {
+        var oItems;
+
+        oItems = [];
+
+        // Top panel
+        oTopPanel = {
+            style:'padding:0px;margin:0px;',
+            region: 'north',
+            id: "wms_field_group",
+            xtype: 'fieldset',
+            //title: OpenLayers.i18n('WMS server information'),
+            layout: 'form',
+            border: false,
+            collapsible: false,
+            autoHeight: true,
+            autoWidth: true,
+            defaults: {width: '100%', /*hideLabel: true*/},
+            defaultType: 'textfield',
+            buttonAlign:'center',
+            items: [],
+            buttons: []
+        };
+
+        // URL panel
+        var oURLField;
+        if(this.serverStore) {
+            oURLField = {
+                columnWidth: 0.85,
+                layout: 'fit',
+                'name': 'wms_url',
+                'id': 'wms_url',
+                xtype: 'combo',
+                store: this.serverStore,
+                displayField: this.serverStoreDisplayField,
+                typeAhead: true,
+                mode: 'local',
+                fieldLabel: 'hello',
+                labelAlign: 'top',
+                forceSelection: false,
+                triggerAction: 'all',
+                emptyText:OpenLayers.i18n('Select or input a server address (URL)'),
+                selectOnFocus:true
+            };
+        } else {
+            oURLField = {
+                columnWidth: 0.85,
+                layout: 'fit',
+                'name': 'wms_url',
+                'id': 'wms_url',
+                'emptyText': OpenLayers.i18n('Input the server address (URL)')
+            };
+        }
+
+        // Top panel - URL and Connect
+        oTopPanel.items.push({
+            style:'padding:2px;margin:2px;',
+            xtype: 'fieldset',
+            layout: 'column',
+            border: false,
+            collapsible: false,
+            collapsed: false,
+            autoHeight: true,
+            autoWidth: true,
+            items: [
+                oURLField,
+                {
+                    columnWidth: 0.15,
+                    layout: 'fit',
+                    border: false,
+                    items: [{
+                        xtype: 'button',
+                        text:  OpenLayers.i18n('Connect'),
+                        scope: this,
+                        handler: function(b, e){this.triggerGetCapabilities();}
+                    }]
+                }
+            ]
+        });
+
+
+        // Top panel - Username and Password
+        oTopPanel.items.push({
+            style:'padding:10px;margin:2px;',
+            xtype: 'fieldset',
+            title: OpenLayers.i18n('Login information (optional)'),
+            layout: 'form',
+            collapsible: true,
+            collapsed: true,
+            autoHeight: true,
+            autoWidth: true,
+            defaults: {width: '100%'},
+            defaultType: 'textfield',
+            items: [{
+                name: 'wms_username',
+                id: 'wms_username',
+                fieldLabel: OpenLayers.i18n('Username')
+            },{
+                name: 'wms_password',
+                id: 'wms_password',
+                inputType: 'password',
+                fieldLabel: OpenLayers.i18n('Password')
+            }]
+        });
+        oItems.push(oTopPanel);
+
+
+        // Center Panel
+        oCenterPanel = {
+            region: 'center',
+            id: "wms_capabilities_panel",
+            layout: 'column',
+            border: false,
+            collapsible: false,
+            autoHeight: true,
+            autoWidth: true,
+            width: 'auto',
+            height: 'auto',
+            defaults: {width: '100%', hideLabel: true},
+            defaultType: 'textfield',
+            buttonAlign:'center',
+            items: []
+        };
+        
+        oItems.push(oCenterPanel);
+
+        Ext.apply(this, {items: oItems});
+    },
+
+    triggerGetCapabilities: function() {
+        var url = Ext.getCmp('wms_url').value;
+
+        if(!url) {
+            alert(OpenLayers.i18n('Please, enter an url in the textbox above'));
+            return;
+        }
+
+        var params = OpenLayers.Util.getParameterString(this.capabilitiesParams);        
+        url = OpenLayers.Util.urlAppend(url, params);
+
+        if (OpenLayers.ProxyHost && OpenLayers.String.startsWith(url, "http")) {
+            url = OpenLayers.ProxyHost + encodeURIComponent(url);
+        }
+
+        this.createWMSCapabilitiesStore(url);
+        this.removeAllItemsFromObject(Ext.getCmp('wms_capabilities_panel'));
+        Ext.getCmp('wms_capabilities_panel').add(this.createGridPanel());
+        Ext.getCmp('wms_capabilities_panel').add(this.createFormPanel());
+        Ext.getCmp('wms_capabilities_panel').doLayout();
+    },
+
+    removeAllItemsFromObject: function(object){
+        while(object.items.length != 0){
+            var oItem = object.items.items[0];
+            object.remove(oItem, true);
+        }
+    },
+
+    createWMSCapabilitiesStore: function(url) {
+        this.WMSCapabilitiesStore = 
+            new GeoExt.data.WMSCapabilitiesStore({'url': url});
+        this.WMSCapabilitiesStore.load();
+    },
+
+    createGridPanel: function() {
+
+        // In order to have a scrollbar, a GridPanel must have a 'height' set,
+        // it can't be left with 'autoHeight': true...
+        var options = {
+            columnWidth: 0.5,
+            layout: 'fit',
+            store: this.WMSCapabilitiesStore,
+            columns: [
+                {header: "Title", dataIndex: "title", sortable: true},
+                {header: "Name", dataIndex: "name", sortable: true},
+                {header: "Queryable", dataIndex: "queryable", sortable: true, width: 70},
+                {id: "description", header: "Description", dataIndex: "abstract"}
+            ],
+            autoExpandColumn: "description",
+            width: 'auto',
+            autoWidth: true,
+            //height: 'auto',
+            //autoHeight: true,
+            listeners: {
+                rowdblclick: this.mapPreview
+            }
+        };
+
+        options = OpenLayers.Util.applyDefaults(this.gridPanelOptions, options);
+
+        return new Ext.grid.GridPanel(options);
+    },
+
+    createFormPanel: function() {
+        var options = {
+            style:'padding:0px;margin:0px;',
+            columnWidth: 0.5,
+            xtype: 'fieldset',
+            labelWidth: 80,
+            defaults: {width: '100%', border:false},
+            defaultType: 'textfield',
+            autoHeight: true,
+            bodyStyle: Ext.isIE ? 'padding:0 0 0px 0px;' : 'padding:5px 0px;',
+            border: false,
+            style: {
+                "margin-left": "10px",
+                "margin-right": Ext.isIE6 ? (Ext.isStrict ? "-10px" : "-13px") : "0"
+            },
+            items: [{
+                fieldLabel: 'Title',
+                name: 'title'
+            },{
+                fieldLabel: 'Name',
+                name: 'name'
+            },{
+                fieldLabel: 'Queryable',
+                name: 'queryable'
+            },{
+                xtype: 'textarea',
+                fieldLabel: 'Abstract',
+                name: 'abstract',
+                anchor: '100% 0'
+            }]
+        };
+
+        return options;
+
+    },
+
+    mapPreview: function() {
+            alert(1);
+    },
 });



More information about the Commits mailing list