[Commits] r617 - in sandbox/opengeo/geoexplorer/lib: . GeoExt/widgets/tree

commits at geoext.org commits at geoext.org
Thu May 7 00:07:26 CEST 2009


Author: ahocevar
Date: 2009-05-07 00:07:26 +0200 (Thu, 07 May 2009)
New Revision: 617

Modified:
   sandbox/opengeo/geoexplorer/lib/GeoExt.js
   sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerContainer.js
   sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerNode.js
Log:
updated tree node code to match latest patch for #22


Modified: sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerContainer.js
===================================================================
--- sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerContainer.js	2009-05-06 21:37:14 UTC (rev 616)
+++ sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerContainer.js	2009-05-06 22:07:26 UTC (rev 617)
@@ -1,6 +1,10 @@
 /**
  * Copyright (c) 2008 The Open Planning Project
  */
+
+/**
+ * @requires GeoExt/widgets/tree/LayerNode.js
+ */
 Ext.namespace("GeoExt.tree");
 
 /**
@@ -19,14 +23,14 @@
 GeoExt.tree.LayerContainer = Ext.extend(Ext.tree.TreeNode, {
     
     /**
-     * ConfigProperty: layerStore
+     * APIProperty: layerStore
      * {<GeoExt.data.LayerStore>} The layer store containing layers to be
      *     displayed in the container.
      */
     layerStore: null,
     
     /**
-     * ConfigProperty: defaults
+     * APIProperty: defaults
      * {Object} a configuration object passed to all nodes that this
      *     LayerContainer creates.
      */
@@ -101,14 +105,14 @@
     },
 
     /**
-     * Method: destroy
+     * Method: onDestroy
      */
-    destroy: function() {
+    onDestroy: function() {
         if(this.layerStore) {
             this.layerStore.un("add", this.onStoreAdd, this);
             this.layerStore.un("remove", this.onStoreRemove, this);
         }
-        GeoExt.tree.LayerContainer.superclass.render.apply(this, arguments);
+        GeoExt.tree.LayerContainer.superclass.onDestroy.apply(this, arguments);
     },
     
     /**
@@ -172,7 +176,7 @@
     addLayerNode: function(layerRecord, index) {
         index = index || 0;
         var layer = layerRecord.get("layer");
-        if (layer.displayInLayerSwitcher == true) {
+        if (layer.displayInLayerSwitcher === true) {
             var node = new GeoExt.tree.LayerNode(Ext.applyIf({
                 iconCls: layer.isBayeLayer ? 'baselayer-icon' : 'layer-icon',
                 layer: layer,

Modified: sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerNode.js
===================================================================
--- sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerNode.js	2009-05-06 21:37:14 UTC (rev 616)
+++ sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerNode.js	2009-05-06 22:07:26 UTC (rev 617)
@@ -9,7 +9,7 @@
  * Inherits from:
  * - <GeoExt.tree.TristateCheckboxNodeUI>
  */
-GeoExt.tree.LayerNodeUI = Ext.extend(GeoExt.tree.TristateCheckboxNodeUI, {
+GeoExt.tree.LayerNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
     
     /**
      * Property: radio
@@ -36,10 +36,10 @@
     render: function(bulkRender) {
         GeoExt.tree.LayerNodeUI.superclass.render.call(this, bulkRender);
         var a = this.node.attributes;
-        if (a.radioGroup && !this.radio) {
+        if (a.radioGroup && this.radio !== undefined) {
             this.radio = Ext.DomHelper.insertAfter(this.checkbox,
-                ['<input type="radio" class="x-tree-node-cb" name="',
-                a.radioGroup, '_querylayer"></input>'].join(""));
+                ['<input type="radio" class="x-tree-node-radio" name="',
+                a.radioGroup, '_radio"></input>'].join(""));
         }
     },
     
@@ -51,7 +51,7 @@
      */
     onClick: function(e) {
         if (e.getTarget('input[type=radio]', 1)) {
-            this.fireEvent("querylayerchange", this.node.layer);
+            this.fireEvent("radiochange", this.node);
         } else {
             GeoExt.tree.LayerNodeUI.superclass.onClick.call(this, e);
         }
@@ -75,11 +75,11 @@
     },
     
     /**
-     * Method: destroy
+     * Method: onDestroy
      */
-    destroy: function() {
-        GeoExt.tree.LayerNodeUI.superclass.destroy.call(this);
+    onDestroy: function() {
         delete this.radio;
+        GeoExt.tree.LayerNodeUI.superclass.onDestroy.call(this);
     }
 });
 
@@ -93,28 +93,26 @@
  * vice versa. The default iconCls for this node's icon is "layer-icon",
  * unless it has children.
  * 
- * This node can contain children, e.g. filter nodes.
- * 
  * Setting the node's layer property to a layer name instead of an object
  * will also work. As soon as a layer is found, it will be stored as layer
  * property in the attributes hash.
  * 
  * The node's text property defaults to the layer name.
  * 
- * If the layer has a queryable property set to true, the node will render a
- * radio button to select the query layer. Clicking on the radio button will
- * fire the querychange event, with the layer as argument. A queryGroup
- * attribute, set to the map's id, will be added to the attributes hash.
+ * If the node has a radioGroup attribute configured, the node will be
+ * rendered with a radio button. This works like the checkbox with the
+ * checked attribute, but radioGroup is a string that identifies the options
+ * group. Clicking the radio button will fire a radioChange event.
  * 
- * To use this node type in a JSON config, set nodeType to "olLayer".
+ * To use this node type in a JSON config, set nodeType to "gx_layer".
  * 
  * Inherits from:
- * - <GeoExt.tree.TristateCheckboxNode>
+ * - Ext.tree.TreeNode
  */
-GeoExt.tree.LayerNode = Ext.extend(GeoExt.tree.TristateCheckboxNode, {
+GeoExt.tree.LayerNode = Ext.extend(Ext.tree.TreeNode, {
     
     /**
-     * ConfigProperty: layer
+     * APIProperty: layer
      * {OpenLayers.Layer|String} The layer that this layer node will
      *     be bound to, or the name of the layer (has to match the layer's
      *     name property). If a layer name is provided, <layerStore> also has
@@ -123,23 +121,21 @@
     layer: null,
     
     /**
-     * ConfigProperty: layerStore
+     * APIProperty: layerStore
      * {<GeoExt.data.LayerStore|"auto"} The layer store containing the layer
      *     that this node represents. If set to "auto", the node will query
      *     the ComponentManager for a <GeoExt.MapPanel>, take the first one it
-     *     finds and takes its layer store. This property is only required
+     *     finds and take its layer store. This property is only required
      *     if <layer> is provided as a string.
      */
     layerStore: null,
     
     /**
-     * ConfigProperty: childNodeType
+     * APIProperty: childNodeType
      * {Ext.tree.Node|String} node class or nodeType of childnodes for this
      *     node. A node type provided here needs to have an add method, with
      *     a scope argument. This method will be run by this node in the
-     *     context of this node, to create child nodes. See
-     *     {<GeoExt.tree.LayerParamsNode>} for an example implementation that
-     *     adds nodes based on a layer's params object. 
+     *     context of this node, to create child nodes.
      */
     childNodeType: null,
     
@@ -169,11 +165,11 @@
         this.defaultUI = this.defaultUI || GeoExt.tree.LayerNodeUI;
         this.addEvents(
             /**
-             * Event: querylayerchange
-             * Notifies listener when the query layer has changed. Will be
-             *     called with the new query layer as argument.
+             * Event: radiochange
+             * Notifies listener when a differnt radio button was selected.
+             * Will be called with the currently selected node as argument.
              */
-            "querylayerchange"
+            "radiochange"
         );
         
         Ext.apply(this, {
@@ -251,7 +247,7 @@
         });
         this.on({
             "checkchange": function(node, checked) {
-                if (checked && this.layer.isBaseLayer) {
+                if (checked && this.layer.isBaseLayer && this.layer.map) {
                     this.layer.map.setBaseLayer(this.layer);
                 }
                 this.layer.setVisibility(checked);
@@ -293,28 +289,16 @@
     
     /**
      * Method: addChildNodes
-     * If the layer's layers param is an array of layer names, a subnode for
-     * each name will be created.
+     * Calls the add method of a node type configured as <childNodeType>
+     * to add children.
      */
     addChildNodes: function() {
         if(typeof this.childNodeType == "string") {
             Ext.tree.TreePanel.nodeTypes[this.childNodeType].add(this);
-        } else if(this.childNodeType.add) {
+        } else if(typeof this.childNodeType.add === "function") {
             this.childNodeType.add(this);
         }
-    },
-
-    /**
-     * Method: updateCheckedChildNodes
-     * 
-     * Parameters:
-     * node - {Ext.tree.node}
-     * checked - {Boolean}
-     */
-    updateCheckedChildNodes: function(node, checked) {
-        GeoExt.tree.LayerNode.superclass.updateCheckedChildNodes.call(this,
-            node, checked);
-    }    
+    }
 });
 
 /**

Modified: sandbox/opengeo/geoexplorer/lib/GeoExt.js
===================================================================
--- sandbox/opengeo/geoexplorer/lib/GeoExt.js	2009-05-06 21:37:14 UTC (rev 616)
+++ sandbox/opengeo/geoexplorer/lib/GeoExt.js	2009-05-06 22:07:26 UTC (rev 617)
@@ -75,7 +75,6 @@
             "GeoExt/widgets/ScaleSlider.js",
             "GeoExt/widgets/tips/SliderTip.js",
             "GeoExt/widgets/tips/ScaleSliderTip.js",
-            "GeoExt/widgets/tree/TristateCheckboxNode.js",
             "GeoExt/widgets/tree/LayerNode.js",
             "GeoExt/widgets/tree/LayerContainer.js"
         );



More information about the Commits mailing list