[Commits] r2590 - in sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux: data widgets widgets/grid widgets/tree

commits at geoext.org commits at geoext.org
Wed Feb 2 15:53:42 CET 2011


Author: adube
Date: 2011-02-02 15:53:42 +0100 (Wed, 02 Feb 2011)
New Revision: 2590

Modified:
   sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/data/WMSBrowserWMSCapabilitiesStore.js
   sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/WMSBrowser.js
   sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/grid/WMSBrowserGridPanel.js
   sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/tree/WMSBrowserRootNode.js
   sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/tree/WMSBrowserTreePanel.js
Log:
WMSBrowser, small code cleanup, comments added

Modified: sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/data/WMSBrowserWMSCapabilitiesStore.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/data/WMSBrowserWMSCapabilitiesStore.js	2011-02-01 17:39:05 UTC (rev 2589)
+++ sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/data/WMSBrowserWMSCapabilitiesStore.js	2011-02-02 14:53:42 UTC (rev 2590)
@@ -1,41 +1,68 @@
+/**
+ * Copyright (c) 2008-2010 The Open Source Geospatial Foundation
+ * 
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
 Ext.namespace("GeoExt.ux.data");
 
+/*
+ * @requires GeoExt.ux/widgets/WMSBrowser.js
+ */
+
+/** api: (define)
+ *  module = GeoExt.ux.data
+ *  class = WMSBrowserWMSCapabilitiesStore
+ */
+
+/** api: constructor
+ *  .. class:: WMSBrowserWMSCapabilitiesStore
+ */
 GeoExt.ux.data.WMSBrowserWMSCapabilitiesStore = Ext.extend(GeoExt.data.WMSCapabilitiesStore, {
 
+    /** api: config[url]
+     * ``String`` The url of the WMSGetCapabilities request
+     */
     url: null,
 
+    /** api: config[layerOptions]
+     * ``Object`` Optional object passed as default options to the
+     * :class:`OpenLayers.Layer.WMS` constructor.
+     */
     layerOptions: null,
 
+    /** api: config[wmsbrowser]
+     * :class:`GeoExt.ux.data.WMSBrowser` A reference to the main browser object
+     */
     wmsbrowser: null,
 
+    /** api: config[gridPanel]
+     * :class:`Ext.grid.GridPanel` A reference to the grid panel containing the
+     * layer records
+     */
     gridPanel: null,
 
+    /** private: property[map]
+     * :class:`OpenLayers.Map` A reference to the map object.  Taken from the
+     * wmsbrowser object.
+     */
     map: null,
 
     /** private: method[constructor]
      */
     constructor: function(config) {
         Ext.apply(this, config);
-
         this.map = this.wmsbrowser.layerStore.map;
-
         arguments.callee.superclass.constructor.call(this, config);
-
         // event registration
-        this.on(
-            'load',
-            this.onCapabilitiesLoad,
-            this
-        );
-        this.on(
-            'loadexception',
-            this.onCapabilitiesLoadException,
-            this
-        );
+        this.on('load', this.onCapabilitiesLoad, this);
+        this.on('loadexception', this.onCapabilitiesLoadException, this);
     },
 
     /** private: method[onCapabilitiesLoad]
-     *  :param store: ``GeoExt.data.WMSGetCapabilitiesStore``
+     *  :param store: :class:`GeoExt.data.WMSGetCapabilitiesStore`
      *  :param records: ``Array(GeoExt.data.LayerRecord)``
      *  :param options: ``Object``
      *
@@ -120,6 +147,11 @@
         }
     },
 
+    /** private: method[onCapabilitiesLoadException]
+     *
+     *  Called after a GetCapabilities request failure.  Fires the according
+     *  failure event.
+     */
     onCapabilitiesLoadException: function() {
         this.wmsbrowser.fireEvent('getcapabilitiesfail');
     }

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	2011-02-01 17:39:05 UTC (rev 2589)
+++ sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/WMSBrowser.js	2011-02-02 14:53:42 UTC (rev 2590)
@@ -473,6 +473,13 @@
         Ext.apply(this, {items: [northPanel, centerPanel]});
     },
 
+    /** private: method[createCapStore]
+     *  :return:  :class:`GeoExt.ux.data.WMSBrowserWMSCapabilitiesStore`
+     *
+     *  Creates and returns a
+     *  :class:`GeoExt.ux.data.WMSBrowserWMSCapabilitiesStore` binded to this
+     *  widget.  Used to query and hold the layer records.
+     */
     createCapStore: function() {
         return new GeoExt.ux.data.WMSBrowserWMSCapabilitiesStore({
             'url': "",
@@ -482,9 +489,10 @@
     },
 
     /** private: method[createGridPanel]
-     *  :return:  ``Ext.grid.GridPanel``
+     *  :return:  ``GeoExt.ux.grid.WMSBrowserGridPanel``
      *
-     * Creates and returns the grid panel used to display the layer records.
+     * Creates and returns :class:`GeoExt.ux.grid.WMSBrowserGridPanel` binded
+     * to this widget to display and select the layer records.
      */
     createGridPanel: function() {
         return new GeoExt.ux.grid.WMSBrowserGridPanel({
@@ -493,6 +501,12 @@
         });
     },
 
+   /** private: method[createTreePanel]
+     *  :return:  ``GeoExt.ux.tree.WMSBrowserTreePanel``
+     *
+     * Creates and returns :class:`GeoExt.ux.tree.WMSBrowserTreePanel` binded
+     * to this widget to display and select the layers from nodes in a tree.
+     */
     createTreePanel: function() {
         var options = {'wmsbrowser': this};
         return new GeoExt.ux.tree.WMSBrowserTreePanel(options);
@@ -633,6 +647,11 @@
         }
     },
 
+    /** private: method[addLayer]
+     *  Called when the user clicks the 'add layer' button.  Call the
+     *  according layerBrowser 'addLayer' method.  If a layer was added, close
+     *  the parent :class: `Ext.Window` if closeOnLayerAdded is set to true.
+     */
     addLayer: function() {
         if(this.layerBrowser.addLayer()) {
             if(this.closeOnLayerAdded && 
@@ -787,6 +806,9 @@
         this.layerNameField.reset();
     },
 
+    /** private: method[resetAll]
+     *  Reset the layer preview, layer name and center form panel.
+     */
     resetAll: function() {
         this.resetLayerPreview();
         this.resetLayerName();

Modified: sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/grid/WMSBrowserGridPanel.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/grid/WMSBrowserGridPanel.js	2011-02-01 17:39:05 UTC (rev 2589)
+++ sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/grid/WMSBrowserGridPanel.js	2011-02-02 14:53:42 UTC (rev 2590)
@@ -1,5 +1,25 @@
+/**
+ * Copyright (c) 2008-2010 The Open Source Geospatial Foundation
+ * 
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
 Ext.namespace("GeoExt.ux.grid");
 
+/*
+ * @requires GeoExt.ux/widgets/WMSBrowser.js
+ */
+
+/** api: (define)
+ *  module = GeoExt.ux.grid
+ *  class = WMSBrowserWMSCapabilitiesStore
+ */
+
+/** api: constructor
+ *  .. class:: WMSBrowserWMSCapabilitiesStore
+ */
 GeoExt.ux.grid.WMSBrowserGridPanel = Ext.extend(Ext.grid.GridPanel, {
 
     layout: 'absolute',
@@ -26,10 +46,21 @@
 
     border: true,
 
+    /** api: config[wmsbrowser]
+     * :class:`GeoExt.ux.data.WMSBrowser` A reference to the main browser object
+     */
     wmsbrowser: null,
 
+    /** private: property[map]
+     * :class:`OpenLayers.Map` A reference to the map object.  Taken from the
+     * wmsbrowser object.
+     */
     map: null,
 
+    /** private: property[layerStore]
+     * :class:`GeoExt.data.LayerStore` A reference to the layer store object.
+     * Taken from the wmsbrowser object.
+     */
     layerStore: null,
 
     /** private: method[constructor]

Modified: sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/tree/WMSBrowserRootNode.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/tree/WMSBrowserRootNode.js	2011-02-01 17:39:05 UTC (rev 2589)
+++ sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/tree/WMSBrowserRootNode.js	2011-02-02 14:53:42 UTC (rev 2590)
@@ -1,60 +1,100 @@
+
+/**
+ * Copyright (c) 2008-2010 The Open Source Geospatial Foundation
+ * 
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
 Ext.namespace("GeoExt.ux.tree");
 
+/*
+ * @requires GeoExt.ux/widgets/WMSBrowser.js
+ * @requires GeoExt.ux/widgets/tree/WMSBrowserTreePanel.js
+ */
+
+/** api: (define)
+ *  module = GeoExt.ux.tree
+ *  class = WMSBrowserRootNode
+ */
+
+/** api: constructor
+ *  .. class:: WMSBrowserRootNode
+ */
 GeoExt.ux.tree.WMSBrowserRootNode = Ext.extend(Ext.tree.AsyncTreeNode, {
 
+    /** private: property[INIT_URL]
+     *  ``String`` The url used on first load.  This is a hack to allow the tree
+     *  to be rendered.
+     */
     INIT_URL: "__foo__",
 
-    text: 'Root node',
-
+    /** api: config[wmsbrowser]
+     * :class:`GeoExt.ux.data.WMSBrowser` A reference to the main browser object
+     */
     wmsbrowser: null,
 
-    loader: new GeoExt.tree.WMSCapabilitiesLoader({
-        //url: './data/dev4g.mapgears.com_cgi-bin_mswms_gmap.xml',
-        url: "__foo__",
-        layerOptions: {buffer: 0, ratio: 1},
-        layerParams: {'TRANSPARENT': 'TRUE'},
-        // customize the createNode method to add a checkbox to nodes
-        createNode: function(attr) {
-            attr.checked = attr.leaf ? false : undefined;
-            return GeoExt.tree.WMSCapabilitiesLoader.prototype.createNode.apply(this, [attr]);
-        }
-    }),
+    /** private: config[loader]
+     * :class:`GeoExt.tree.WMSCapabilitiesLoader`
+     */
+    loader: null,
 
     /** private: method[constructor]
      */
     constructor: function(config) {
         Ext.apply(this, config);
+        Ext.apply(this, {loader: new GeoExt.tree.WMSCapabilitiesLoader({
+            url: "__foo__",
+            layerOptions: {buffer: 0, ratio: 1},
+            layerParams: {'TRANSPARENT': 'TRUE'},
+            // customize the createNode method to add a checkbox to nodes
+            createNode: function(attr) {
+                attr.checked = attr.leaf ? false : undefined;
+                return GeoExt.tree.WMSCapabilitiesLoader.prototype.createNode.apply(this, [attr]);
+            }
+        })});
 
         arguments.callee.superclass.constructor.call(this, config);
 
+        // events registration
         this.on('load', this.onWMSCapabilitiesLoad, this);
         this.on('loadexception', this.onWMSCapabilitiesLoadException, this);
     },
 
+    /** private: method[setLoaderURL]
+     *  :param url: ``String``
+     *
+     *  Set the loader url to the given url and reload.
+     */
     setLoaderURL: function(url) {
         this.loader.url = url;
         this.reload();
     },
 
+    /** private: method[onWMSCapabilitiesLoad]
+     *  Called on "load" event.  Fires any "success" or "failure" events/methods
+     */
     onWMSCapabilitiesLoad: function() {
         if (this.hasChildNodes()) {
             this.wmsbrowser.fireEvent('getcapabilitiessuccess');
-            //this.expandFirstNodes();
         } else if (this.loader.url != this.INIT_URL) {
             this.onWMSCapabilitiesStoreLoadException();
         }
     },
 
+    /** private: method[onWMSCapabilitiesStoreLoadException]
+     *  Called on load failure.  Fires the according event.
+     */
     onWMSCapabilitiesStoreLoadException: function() {
         this.wmsbrowser.fireEvent('getcapabilitiesfail');
     },
 
-    expandFirstNodes: function() {
-        Ext.each(this.childNodes, function(childNode, index) {
-            childNode.expand();
-        });
-    },
-
+    /** private: method[getLayerNameFromCheckedNodes]
+     *  :return:  ``String``
+     *  Collect and return all checked node layer title or name into a single
+     *  string separated by ','.
+     */
     getLayerNameFromCheckedNodes: function() {
         var layerName = [];
 
@@ -76,7 +116,15 @@
         return layerName.join(', ');
     },
 
-    // doesn't set the layer name
+    /** private: method[getNewLayerFromCheckedNodes]
+     *  :return:  :class:`OpenLayers.Layer.WMS`
+     *
+     *  From all currently checked nodes, create and return a new
+     *  :class:`OpenLayers.Layer.WMS` object.  All 'layers' parameters are
+     *  merged together.
+     *
+     *  Note: this method doesn't set the layer name using the textbox.
+     */
     getNewLayerFromCheckedNodes: function() {
         var newLayer;
 

Modified: sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/tree/WMSBrowserTreePanel.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/tree/WMSBrowserTreePanel.js	2011-02-01 17:39:05 UTC (rev 2589)
+++ sandbox/mapgears/geoext.ux/ux/WMSBrowser/lib/GeoExt.ux/widgets/tree/WMSBrowserTreePanel.js	2011-02-02 14:53:42 UTC (rev 2590)
@@ -1,5 +1,26 @@
+/**
+ * Copyright (c) 2008-2010 The Open Source Geospatial Foundation
+ * 
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
 Ext.namespace("GeoExt.ux.tree");
 
+/*
+ * @requires GeoExt.ux/widgets/WMSBrowser.js
+ * @requires GeoExt.ux/widgets/tree/WMSBrowserRootNode.js
+ */
+
+/** api: (define)
+ *  module = GeoExt.ux.tree
+ *  class = WMSBrowserTreePanel
+ */
+
+/** api: constructor
+ *  .. class:: WMSBrowserTreePanel
+ */
 GeoExt.ux.tree.WMSBrowserTreePanel = Ext.extend(Ext.tree.TreePanel, {
 
     rootVisible: false,
@@ -24,43 +45,54 @@
 
     root: null,
 
+    /** api: config[wmsbrowser]
+     * :class:`GeoExt.ux.data.WMSBrowser` A reference to the main browser object
+     */
     wmsbrowser: null,
 
-    listeners: {
-        'checkchange': function(node, checked) {
-            if (checked === true) {
-                if (!this.isLayerCompatible(node.attributes.layer)) {
-                    node.getUI().checkbox.checked = false;
+    /** private: method[constructor]
+     */
+    constructor: function(config) {
+        Ext.apply(this, config);
+        Ext.apply(this, {listeners: {
+            'checkchange': function(node, checked) {
+                if (checked === true) {
+                    if (!this.isLayerCompatible(node.attributes.layer)) {
+                        node.getUI().checkbox.checked = false;
+                    } else {
+                        this.addLayerToPreview(node.attributes.layer);
+                        this.setLayerNameFromCheckedNodes();
+                        this.loadLayerMetadata(node.attributes.layer);
+                    }
                 } else {
-                    this.addLayerToPreview(node.attributes.layer);
+                    this.removeLayerFromPreview(node.attributes.layer);
                     this.setLayerNameFromCheckedNodes();
-                    this.loadLayerMetadata(node.attributes.layer);
+                    this.wmsbrowser.resetCenterFormPanel();
                 }
-            } else {
-                this.removeLayerFromPreview(node.attributes.layer);
-                this.setLayerNameFromCheckedNodes();
-                this.wmsbrowser.resetCenterFormPanel();
             }
-        }
-    },
+        }});
 
-    /** private: method[constructor]
-     */
-    constructor: function(config) {
-        Ext.apply(this, config);
-
         this.root = new GeoExt.ux.tree.WMSBrowserRootNode(config);
         this.layerStore = this.wmsbrowser.layerStore;
         this.map = this.layerStore.map;
 
         arguments.callee.superclass.constructor.call(this, config);
-
     },
 
+    /** private: method[loadURL]
+     *  :param url: ``String``
+     *
+     *  Set the root loader url to given url.
+     */
     loadURL: function(url) {
         this.getRootNode().setLoaderURL(url);
     },
 
+    /** private: method[addLayerToPreview]
+     *  :param layer: :class:`OpenLayers.Layer.WMS`
+     *
+     *  Add the layer to the preview map.
+     */
     addLayerToPreview: function(layer) {
         var layerPreview = this.wmsbrowser.layerPreview;
         var mapPanelPreview = this.wmsbrowser.mapPanelPreview;
@@ -97,6 +129,11 @@
         }
     },
 
+    /** private: method[removeLayerFromPreview]
+     *  :param layer: :class:`OpenLayers.Layer.WMS`
+     *
+     *  Remove the layer from the preview map.
+     */
     removeLayerFromPreview: function(layer) {
         var layerPreview = this.wmsbrowser.layerPreview;
 
@@ -120,12 +157,23 @@
         }
     },
 
+    /** private: method[setLayerNameFromCheckedNodes]
+     *  Set the textfield used for the layer name value to the collection of
+     *  the currently checked node layer titles and names.
+     */
     setLayerNameFromCheckedNodes: function() {
         this.wmsbrowser.layerNameField.setValue(
             this.root.getLayerNameFromCheckedNodes()
         );
     },
 
+    /** private: method[addLayer]
+     *  :return: ``Boolean`` Whether the layer was added or not due to an
+     *                       error.
+     *
+     *  Create a new :class:`OpenLayers.Layer.WMS` object from the currently
+     *  checked nodes and add it to the map.
+     */
     addLayer: function() {
         var layerAdded = false;
         var layerPreview = this.wmsbrowser.layerPreview;
@@ -165,6 +213,12 @@
         return layerAdded;
     },
 
+    /** private: method[loadLayerMetadata]
+     *  :param layer: :class:`OpenLayers.Layer.WMS`
+     *
+     *  Load the layer metadata in a specific form.  Currently loads 'abstract'
+     *  metadata only.
+     */
     loadLayerMetadata: function(layer) {
         if (layer && layer.metadata.abstract) {
             this.wmsbrowser.descriptionField.setValue(layer.metadata.abstract);
@@ -173,6 +227,15 @@
         }
     },
 
+    /** private: method[isLayerCompatible]
+     *  :return: ``Boolean`` Whether the layer is compatible with the current
+     *                       map
+     *
+     *  Checks if a specific :class:`OpenLayers.Layer.WMS` object can be added
+     *  to the map.  To be compatible, it must :
+     *    - support the current map projection
+     *    - must at least intersects the map maxextent
+     */
     isLayerCompatible: function(layer) {
         var compatible = true;
         var reasons = [];
@@ -227,6 +290,4 @@
 
         return compatible;
     }
-
 });
-



More information about the Commits mailing list