[Commits] r827 - in sandbox/opengeo/geoexplorer: examples lib lib/GeoExt/data lib/GeoExt/widgets lib/GeoExt/widgets/tree tests tests/lib/GeoExt/data tests/lib/GeoExt/widgets tests/lib/GeoExt/widgets/tree

commits at geoext.org commits at geoext.org
Wed May 20 01:30:53 CEST 2009


Author: tschaub
Date: 2009-05-20 01:30:53 +0200 (Wed, 20 May 2009)
New Revision: 827

Added:
   sandbox/opengeo/geoexplorer/examples/layercontainer.html
   sandbox/opengeo/geoexplorer/examples/layercontainer.js
   sandbox/opengeo/geoexplorer/examples/tree.html
   sandbox/opengeo/geoexplorer/examples/tree.js
   sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/BaseLayerContainer.js
   sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/OverlayLayerContainer.js
   sandbox/opengeo/geoexplorer/tests/lib/GeoExt/widgets/tree/LayerNode.html
Modified:
   sandbox/opengeo/geoexplorer/lib/GeoExt.js
   sandbox/opengeo/geoexplorer/lib/GeoExt/data/FeatureRecord.js
   sandbox/opengeo/geoexplorer/lib/GeoExt/data/LayerRecord.js
   sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/MapPanel.js
   sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/Popup.js
   sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerContainer.js
   sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerNode.js
   sandbox/opengeo/geoexplorer/tests/lib/GeoExt/data/FeatureRecord.html
   sandbox/opengeo/geoexplorer/tests/lib/GeoExt/data/LayerRecord.html
   sandbox/opengeo/geoexplorer/tests/lib/GeoExt/data/LayerStore.html
   sandbox/opengeo/geoexplorer/tests/lib/GeoExt/widgets/MapPanel.html
   sandbox/opengeo/geoexplorer/tests/lib/GeoExt/widgets/tree/LayerContainer.html
   sandbox/opengeo/geoexplorer/tests/list-tests.html
Log:
merge up to r825 from trunk

Added: sandbox/opengeo/geoexplorer/examples/layercontainer.html
===================================================================
--- sandbox/opengeo/geoexplorer/examples/layercontainer.html	                        (rev 0)
+++ sandbox/opengeo/geoexplorer/examples/layercontainer.html	2009-05-19 23:30:53 UTC (rev 827)
@@ -0,0 +1,30 @@
+<html>
+    <head>
+        <title>GeoExt Layer Tree</title>
+
+        <script type="text/javascript" src="http://extjs.cachefly.net/builds/ext-cdn-771.js"></script>
+        <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/resources/css/ext-all.css" />
+        <link rel="stylesheet" type="text/css" href="http://extjs.com/deploy/dev/examples/shared/examples.css"></link>
+        <script src="http://openlayers.org/api/2.8-rc2/OpenLayers.js"></script>
+        <script type="text/javascript" src="../lib/GeoExt.js"></script>
+
+        <script type="text/javascript" src="layercontainer.js"></script>
+
+    </head>
+    <body>
+        <h1>Layer Tree Example</h1>
+        <p>This is example that shows how create a TreePanel with layers
+        from a map.  GeoExt does not provide a LayerTree component.  Instead,
+        to create a tree with nodes that represent layers, create a tree with
+        a LayerContainer at the root, or add LayerNodes directly.</p>
+
+        <p>Note that the js is not minified so it is readable.
+        See <a href="layercontainer.js">layercontainer.js</a>.</p>
+
+        <div style="position: relative;">
+            <div id="capgrid"></div>
+            <div id="tree"></div>
+            <div id="mappanel"></div>
+        </div>
+    </body>
+</html>

Added: sandbox/opengeo/geoexplorer/examples/layercontainer.js
===================================================================
--- sandbox/opengeo/geoexplorer/examples/layercontainer.js	                        (rev 0)
+++ sandbox/opengeo/geoexplorer/examples/layercontainer.js	2009-05-19 23:30:53 UTC (rev 827)
@@ -0,0 +1,74 @@
+var store, tree, panel;
+Ext.onReady(function() {
+    
+    // create a new WMS capabilities store
+    store = new GeoExt.data.WMSCapabilitiesStore({
+        url: "data/wmscap.xml"
+    });
+    // load the store with records derived from the doc at the above url
+    store.load();
+
+    // create a grid to display records from the store
+    var grid = new Ext.grid.GridPanel({
+        title: "WMS Capabilities",
+        store: store,
+        cm: new Ext.grid.ColumnModel([
+            {header: "Name", dataIndex: "name", sortable: true},
+            {id: "title", header: "Title", dataIndex: "title", sortable: true}
+        ]),
+        sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
+        autoExpandColumn: "title",
+        renderTo: "capgrid",
+        height: 300,
+        width: 350,
+        floating: true,
+        x: 10,
+        y: 0,
+        bbar: ["->", {
+            text: "Add Layer",
+            handler: function() {
+                var record = grid.getSelectionModel().getSelected();
+                if(record) {
+                    var copy = record.copy();
+                    copy.set("layer", record.get("layer"));
+                    copy.get("layer").mergeNewParams({
+                        format: "image/png",
+                        transparent: "true"
+                    });
+                    panel.layers.add(copy);
+                    panel.map.zoomToExtent(
+                        OpenLayers.Bounds.fromArray(copy.get("llbbox"))
+                    );
+                }
+            }
+        }]
+    });
+    
+    // create a map panel
+    panel = new GeoExt.MapPanel({
+        renderTo: "mappanel",
+        width: 350,
+        height: 300,
+        floating: true,
+        x: 570,
+        y: 0
+    });
+    
+    tree = new Ext.tree.TreePanel({
+        renderTo: "tree",
+        root: new GeoExt.tree.LayerContainer({
+            text: 'Map Layers',
+            layerStore: panel.layers,
+            leaf: false,
+            expanded: true
+        }),
+        enableDD: true,
+        width: 170,
+        height: 300,
+        floating: true,
+        x: 380,
+        y: 0
+    });
+    
+
+});

Added: sandbox/opengeo/geoexplorer/examples/tree.html
===================================================================
--- sandbox/opengeo/geoexplorer/examples/tree.html	                        (rev 0)
+++ sandbox/opengeo/geoexplorer/examples/tree.html	2009-05-19 23:30:53 UTC (rev 827)
@@ -0,0 +1,27 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+    <head>
+        <title>GeoExt Tree Components</title>
+        
+        <script type="text/javascript" src="http://extjs.cachefly.net/builds/ext-cdn-771.js"></script>
+        <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/resources/css/ext-all.css" />
+        <link rel="stylesheet" type="text/css" href="http://extjs.com/deploy/dev/examples/shared/examples.css"></link>
+        <script type="text/javascript" src="../lib/GeoExt.js"></script>
+        <script src="http://openlayers.org/api/2.8-rc2/OpenLayers.js"></script>
+
+        <script type="text/javascript" src="tree.js"></script>
+
+    </head>
+    <body>
+        <div id="desc">
+            <h1>GeoExt.tree Components</h1>
+            <p>This example shows how to work with layer tree.  The basic
+            component for building layer trees is the LayerNode, and there are
+            differnt types of containers for automatically adding a map's
+            layers to the tree. The tree configuration of this example is pure
+            JSON and can be edited live by clicking on the "Show/Edit Tree Config"
+            button below the layers panel.<p>
+            <p>The js is not minified so it is readable. See
+            <a href="tree.js">tree.js</a>.</p>
+        </div>
+    </body>
+</html>
\ No newline at end of file

Added: sandbox/opengeo/geoexplorer/examples/tree.js
===================================================================
--- sandbox/opengeo/geoexplorer/examples/tree.js	                        (rev 0)
+++ sandbox/opengeo/geoexplorer/examples/tree.js	2009-05-19 23:30:53 UTC (rev 827)
@@ -0,0 +1,175 @@
+var mapPanel;
+Ext.onReady(function() {
+    // using OpenLayers.Format.JSON to create a nice formatted string of the
+    // configuration for editing it in the UI
+    var treeConfig = new OpenLayers.Format.JSON().write([{
+        nodeType: "gx_baselayercontainer"
+    }, {
+        nodeType: "gx_overlaylayercontainer",
+        // render the nodes inside this container with a radio button,
+        // and assign them the group "foo"
+        defaults: {
+            radioGroup: "foo"
+        }
+    }, {
+        nodeType: "gx_layer",
+        layer: "Tasmania Roads"
+    }], true);
+
+    mapPanel = new GeoExt.MapPanel({
+        border: true,
+        region: "center",
+        // we do not want all overlays, to try the OverlayLayerContainer
+        map: new OpenLayers.Map({allOverlays: false}),
+        center: [146.1569825, -41.6109735],
+        zoom: 6,
+        layers: [
+            new OpenLayers.Layer.WMS("Blue Marble",
+                "http://sigma.openplans.org/geoserver/wms", {
+                    layers: "bluemarble"
+                }, {
+                    buffer: 0,
+                    visibility: false
+                }),
+            new OpenLayers.Layer.WMS("Tasmania State Boundaries",
+                "http://demo.opengeo.org/geoserver/wms", {
+                    layers: "topp:tasmania_state_boundaries"
+                }, {
+                    buffer: 0
+               }),
+            new OpenLayers.Layer.WMS("Water",
+                "http://demo.opengeo.org/geoserver/wms", {
+                    layers: "topp:tasmania_water_bodies",
+                    transparent: true,
+                    format: "image/gif"
+                }, {
+                    isBaseLayer: false,
+                    buffer: 0
+                }),
+            new OpenLayers.Layer.WMS("Cities",
+                "http://demo.opengeo.org/geoserver/wms", {
+                    layers: "topp:tasmania_cities",
+                    transparent: true,
+                    format: "image/gif"
+                }, {
+                    isBaseLayer: false,
+                    buffer: 0
+                }),
+            new OpenLayers.Layer.WMS("Tasmania Roads",
+                "http://demo.opengeo.org/geoserver/wms", {
+                    layers: "topp:tasmania_roads",
+                    transparent: true,
+                    format: "image/gif"
+                }, {
+                    isBaseLayer: false,
+                    buffer: 0,
+                    // exclude this layer from layer container nodes
+                    displayInLayerSwitcher: false
+                })
+        ]
+    });
+    
+    // dialog for editing the tree configuration
+    var treeConfigWin = new Ext.Window({
+        layout: "fit",
+        hideBorders: true,
+        closeAction: "hide",
+        width: 300,
+        height: 400,
+        title: "Tree Configuration",
+        items: [{
+            xtype: "form",
+            layout: "fit",
+            items: [{
+                id: "treeconfig",
+                xtype: "textarea"
+            }],
+            buttons: [{
+                text: "Save",
+                handler: function() {
+                    var value = Ext.getCmp("treeconfig").getValue()
+                    try {
+                        var root = tree.getRootNode();
+                        root.attributes.children = Ext.decode(value);
+                        tree.getLoader().load(root);
+                    } catch(e) {
+                        alert("Invalid JSON");
+                        return;
+                    }
+                    treeConfig = value;
+                    treeConfigWin.hide();
+                }
+            }, {
+                text: "Cancel",
+                handler: function() {
+                    treeConfigWin.hide();
+                }
+            }]
+        }]
+    });
+    
+    var toolbar = new Ext.Toolbar({
+        items: [{
+            text: "Show/Edit Tree Config",
+            handler: function() {
+                treeConfigWin.show();
+                Ext.getCmp("treeconfig").setValue(treeConfig);
+            }
+        }]
+    });
+    
+    var tree = new Ext.tree.TreePanel({
+        border: true,
+        region: "west",
+        title: "Layers",
+        width: 200,
+        split: true,
+        collapsible: true,
+        collapseMode: "mini",
+        autoScroll: true,
+        loader: new Ext.tree.TreeLoader({
+            clearOnLoad: true
+        }),
+        root: {
+            nodeType: "async",
+            children: Ext.decode(treeConfig)
+        },
+        rootVisible: false,
+        lines: false,
+        bbar: toolbar
+    });
+    
+    // the layer node's radio button with its radiochange event can be used
+    // to set an active layer.
+    var registerRadio = function(node){
+        if(!node.hasListener("radiochange")) {
+            node.on("radiochange", function(node){
+                alert(node.layer.name + " is now the the active layer.");
+            });
+        }
+    }
+    tree.on({
+        "insert": registerRadio,
+        "append": registerRadio,
+        scope: this
+    });
+    
+    new Ext.Viewport({
+        layout: "fit",
+        hideBorders: true,
+        items: {
+            layout: "border",
+            deferredRender: false,
+            items: [mapPanel, tree, {
+                contentEl: "desc",
+                region: "east",
+                bodyStyle: {"padding": "5px"},
+                collapsible: true,
+                collapseMode: "mini",
+                split: true,
+                width: 200,
+                title: "Description"
+            }]
+        }
+    });
+});

Modified: sandbox/opengeo/geoexplorer/lib/GeoExt/data/FeatureRecord.js
===================================================================
--- sandbox/opengeo/geoexplorer/lib/GeoExt/data/FeatureRecord.js	2009-05-19 23:27:21 UTC (rev 826)
+++ sandbox/opengeo/geoexplorer/lib/GeoExt/data/FeatureRecord.js	2009-05-19 23:30:53 UTC (rev 827)
@@ -28,24 +28,6 @@
 ]);
 
 /**
- * APIMethod: copy
- * Creates a copy of this Record.
- * 
- * Paremters:
- * id - {String} (optional) A new Record id.
- *
- * Returns:
- * {GeoExt.data.LayerRecord} A new layer record.
- */
-GeoExt.data.FeatureRecord.prototype.copy = function(id) {
-    var feature = this.get("feature") && this.get("feature").clone();
-    return new this.constructor(
-        Ext.applyIf({feature: feature}, this.data),
-        id || this.id
-    );
-};
-
-/**
  * APIFunction: GeoExt.data.FeatureRecord.create
  * Creates a constructor for a FeatureRecord, optionally with additional
  * fields.

Modified: sandbox/opengeo/geoexplorer/lib/GeoExt/data/LayerRecord.js
===================================================================
--- sandbox/opengeo/geoexplorer/lib/GeoExt/data/LayerRecord.js	2009-05-19 23:27:21 UTC (rev 826)
+++ sandbox/opengeo/geoexplorer/lib/GeoExt/data/LayerRecord.js	2009-05-19 23:30:53 UTC (rev 827)
@@ -30,24 +30,6 @@
 ]);
 
 /**
- * APIMethod: copy
- * Creates a copy of this Record.
- * 
- * Paremters:
- * id - {String} (optional) A new Record id.
- *
- * Returns:
- * {GeoExt.data.LayerRecord} A new layer record.
- */
-GeoExt.data.LayerRecord.prototype.copy = function(id) {
-    var layer = this.get("layer") && this.get("layer").clone();
-    return new this.constructor(
-        Ext.applyIf({layer: layer}, this.data),
-        id || this.id
-    );
-};
-
-/**
  * APIFunction: GeoExt.data.LayerRecord.create
  * Creates a constructor for a LayerRecord, optionally with additional
  * fields.

Modified: sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/MapPanel.js
===================================================================
--- sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/MapPanel.js	2009-05-19 23:27:21 UTC (rev 826)
+++ sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/MapPanel.js	2009-05-19 23:30:53 UTC (rev 827)
@@ -202,20 +202,19 @@
     }
 });
 
-/**
- * APIFunction GeoExt.MapPanel.guess
- * Convenience function for guessing the map panel of an application. This can
- * reliably be used for all applications that just have one map panel in the
- * viewport.
- * 
- * Returns:
- * {<GeoExt.MapPanel>} The first map panel found by the Ext component manager.
+/** api: function[guess]
+ *  :return: ``GeoExt.MapPanel`` The first map panel found by the Ext
+ *      component manager.
+ *  
+ *  Convenience function for guessing the map panel of an application. This
+ *     can reliably be used for all applications that just have one map panel
+ *     in the viewport.
  */
 GeoExt.MapPanel.guess = function() {
     return Ext.ComponentMgr.all.find(function(o) { 
- 	    return o instanceof GeoExt.MapPanel; 
- 	}); 
-}
+        return o instanceof GeoExt.MapPanel; 
+    }); 
+};
 
 /** api: xtype = gx_mappanel */
 Ext.reg('gx_mappanel', GeoExt.MapPanel); 

Modified: sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/Popup.js
===================================================================
--- sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/Popup.js	2009-05-19 23:27:21 UTC (rev 826)
+++ sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/Popup.js	2009-05-19 23:30:53 UTC (rev 827)
@@ -1,120 +1,112 @@
-Ext.namespace("GeoExt.popup");
-/**
- * Class: GeoExt.Popup
- * Popups are a specialized Window that supports anchoring
- *     to a particular feature in a MapPanel.  When a popup
- *     is anchored to a feature, that means that the popup
- *     will visibly point to the feature on the map, and move
- *     accordingly when the map is panned or zoomed.
- *
- * Usage example:
- * (start code)
- *
- * var popup = new GeoExt.Popup({
- *   title: 'My Popup',
- *   feature: feature,
- *   width: 200,
- *   html: "<div>Popup content</div>",
- *   collapsible: true
- * })
- *
- * (end)
- *
- * Inherits from:
- * - {Ext.Window}
+/* Copyright (C) 2008-2009 The Open Source Geospatial Foundation [1]
+ * Published under the BSD license.
+ * See http://geoext.org/svn/geoext/core/trunk/license.txt for the full text
+ * of the license.
+ * 
+ * [1] pending approval
  */
 
-/**
- * Constructor: GeoExt.Popup
+/** api: (define)
+ *  module = GeoExt
+ *  class = Popup
+ *  base_link = `Ext.Window <http://extjs.com/deploy/dev/docs/?class=Ext.Window>`_
+ */
+Ext.namespace("GeoExt");
+
+/** api: example
+ *  Sample code to create a popup anchored to a feature:
  * 
- * Parameters:
- * config - {Object} A config object. In addition to the config options
- *     of its parent class, this object can receive specific options,
- *     see the API properties to know about these specific options.
+ *  .. code-block:: javascript
+ *     
+ *      var popup = new GeoExt.Popup({
+ *          title: "My Popup",
+ *          feature: feature,
+ *          width: 200,
+ *          html: "<div>Popup content</div>",
+ *          collapsible: true
+ *      });
  */
+
+/** api: constructor
+ *  .. class:: Popup(config)
+ *   
+ *      Popups are a specialized Window that supports anchoring
+ *      to a particular feature in a MapPanel.  When a popup
+ *      is anchored to a feature, that means that the popup
+ *      will visibly point to the feature on the map, and move
+ *      accordingly when the map is panned or zoomed.
+ */
 GeoExt.Popup = Ext.extend(Ext.Window, {
 
-    /**
-     * APIProperty: anchored
-     * {Boolean} True if this popup begins anchored to
-     * its feature.  Defaults to true.
+    /** api: config[anchored]
+     *  ``Boolean``  The popup begins anchored to its feature.  Default is
+     *  ``true``.
      */
     anchored: true,
 
-    /**
-     * APIProperty: panIn
-     * {Boolean} True if the popup should pan the map so
-     * that the popup is fully in view when it is rendered.  Default is true.
+    /** api: config[panIn]
+     *  ``Boolean`` The popup should pan the map so that the popup is
+     *  fully in view when it is rendered.  Default is ``true``.
      */
     panIn: true,
 
-    /**
-     * APIProperty: unpinnable
-     * {Boolean} True if the popup should have a
-     * "unpin" tool that unanchors it from its feature.
-     * Default is true.
+    /** api: config[unpinnable]
+     *  ``Boolean`` The popup should have a "unpin" tool that unanchors it from
+     *  its feature.  Default is ``true``.
      */
     unpinnable: true,
 
-    /**
-     * APIProperty: feature
-     * {OpenLayers.Feature} An OpenLayers feature that is this
-     * popup's anchor. Either this or <lonlat> has to be provided.
+    /** api: config[feature]
+     *  ``OpenLayers.Feature`` A location for this popup's anchor.  One of
+     *  ``feature`` or ``lonlat`` must be provided.
      */
     feature: null,
 
-    /**
-     * APIProperty: lonlat
-     * {OpenLayers.LonLat} An OpenLayers lonlat from which an
-     * anchor feature's geometry is made if no feature is provided.
+    /** api: config[lonlat]
+     *  ``OpenLayers.LonLat`` A location for this popup's anchor.  One of
+     *  ``feature`` or ``lonlat`` must be provided.
      */
     lonlat: null,
 
-    /*
+    /**
      * Some Ext.Window defaults need to be overriden here
      * because some Ext.Window behavior is not currently supported.
      */    
 
-    /**
-     * Property: animCollapse
-     * {Boolean} True to animate the transition when the panel is 
-     * collapsed, false to skip the animation.
-     * Collapsing animation is not supported yet for popups.
+    /** private: config[animCollapse]
+     *  ``Boolean`` Animate the transition when the panel is collapsed.
+     *  Default is ``false``.  Collapsing animation is not supported yet for
+     *  popups.
      */
     animCollapse: false,
 
-    /**
-     * Property: draggable
-     * {Boolean} True to enable dragging of this Panel.
-     * Defaults to false because the popup defaults to being
-     * anchored, and anchored popups should not be draggable.
+    /** private: config[draggable]
+     *  ``Boolean`` Enable dragging of this Panel.  Defaults to ``false``
+     *  because the popup defaults to being anchored, and anchored popups
+     *  should not be draggable.
      */
     draggable: false,
 
-    /**
-     * Property: shadow
-     * {Boolean} True to give the popup window a shadow.
-     * Defaults to false because shadows are not supported 
-     * yet for popups (the shadow does not look good with 
-     * the anchor).
+    /** private: config[shadow]
+     *  ``Boolean`` Give the popup window a shadow.  Defaults to ``false``
+     *  because shadows are not supported yet for popups (the shadow does
+     *  not look good with the anchor).
      */
     shadow: false,
 
-    /**
-     * Property: popupCls
-     * {String} CSS class name for the popup DOM elements.
+    /** api: config[popupCls]
+     *  ``String`` CSS class name for the popup DOM elements.  Default is
+     *  "gx-popup".
      */
     popupCls: "gx-popup",
 
-    /**
-     * Property: ancCls
-     * {String} CSS class name for the popup's anchor.
+    /** api: config[ancCls
+     *  ``String``  CSS class name for the popup's anchor.
      */
     ancCls: null,
 
-    /**
-     * Method: initComponent
-     *     Initializes the popup.
+    /** private: method[initComponent]
+     *  Initializes the popup.
      */
     initComponent: function() {        
         if (!this.feature && this.lonlat) {
@@ -128,9 +120,8 @@
         GeoExt.Popup.superclass.initComponent.call(this);
     },
 
-    /**
-     * Method: onRender
-     *     Executes when the popup is rendered.
+    /** private: method[onRender]
+     *  Executes when the popup is rendered.
      */
     onRender: function(ct, position) {
         GeoExt.Popup.superclass.onRender.call(this, ct, position);
@@ -140,10 +131,9 @@
         this.createElement("anc", this.el);
     },
 
-    /**
-     * Method: initTools
-     *     Initializes the tools on the popup.  In particular,
-     *     it adds the 'unpin' tool if the popup is unpinnable.
+    /** private: method[initTools]
+     *  Initializes the tools on the popup.  In particular,
+     *  it adds the 'unpin' tool if the popup is unpinnable.
      */
     initTools : function() {
         if(this.unpinnable) {
@@ -156,15 +146,13 @@
         GeoExt.Popup.superclass.initTools.call(this);
     },
 
-    /**
-     * APIMethod: addToMapPanel
-     *      Adds this popup to a MapPanel.  Assumes that the
-     *      MapPanel's map is already initialized and that the
-     *      Popup's feature is on the map.
-     * 
-     * Parameters:
-     * mapPanel - {<GeoExt.MapPanel>} a MapPanel to which to
-     *     add this popup.
+    /** api: method[addToMapPanel]
+     *  :param mapPanel: :class:`MapPanel` The panel to which this popup should
+     *      be added.
+     *  
+     *  Adds this popup to a :class:`MapPanel`.  Assumes that the
+     *  MapPanel's map is already initialized and that the
+     *  Popup's feature is on the map.
      */
     addToMapPanel: function(mapPanel) {
         this.mapPanel = mapPanel;
@@ -188,14 +176,11 @@
         }
     },
 
-    /**
-     * Method: setSize
-     *     Sets the size of the popup, taking into account
-     *     the size of the anchor.
-     *     
-     * Parameters:
-     * w - {Integer}
-     * h - {Integer}
+    /** api: method[setSize]
+     *  :param w: ``Integer``
+     *  :param h: ``Integer``
+     *  
+     *  Sets the size of the popup, taking into account the size of the anchor.
      */
     setSize: function(w, h) {
         if(this.anc) {
@@ -210,9 +195,8 @@
         GeoExt.Popup.superclass.setSize.call(this, w, h);
     },
 
-    /**
-     * Method: position
-     *     Positions the popup relative to its feature
+    /** private: method[position]
+     *  Positions the popup relative to its feature
      */
     position: function() {
         var centerLonLat = this.feature.geometry.getBounds().getCenterLonLat();
@@ -233,12 +217,8 @@
         this.setPosition(centerPx.x - dx, centerPx.y - dy);
     },
 
-    /**
-     * Method: getAnchorElement
-     *     Returns the anchor element of the popup
-     *
-     * Returns:
-     * {Ext.Element}
+    /** private: method[getAnchorElement]
+     *  :returns: ``Ext.Element``  The anchor element of the popup.
      */
     getAnchorElement: function() {
         var anchorSelector = "div." + this.ancCls;
@@ -246,11 +226,9 @@
         return anc;
     },
 
-    /**
-     * Method: anchorPopup
-     *     Anchors a popup to its feature
-     *     by registering listeners that reposition the popup
-     *     when the map is moved.
+    /** private: method[anchorPopup]
+     *  Anchors a popup to its feature by registering listeners that reposition
+     *  the popup when the map is moved.
      */
     anchorPopup: function() {
         this.map.events.on({
@@ -266,11 +244,9 @@
         });
     },
 
-    /**
-     * APIMethod: unanchorPopup
-     *     Unanchors a popup from its feature.
-     *     Currently, this removes the popup from its MapPanel
-     *     and adds it to the page body.
+    /** private: method[unanchorPopup]
+     *  Unanchors a popup from its feature.  This removes the popup from its
+     *  MapPanel and adds it to the page body.
      */
     unanchorPopup: function() {
         this.unbindFromMapPanel();
@@ -308,9 +284,8 @@
         }
     },
 
-    /** Method: unbindFromMapPanel
-     *      Utility method for unbinding events that call for
-     *      popup repositioning.
+    /** private: method[unbindFromMapPanel]
+     *  Utility method for unbinding events that call for popup repositioning.
      */
     unbindFromMapPanel: function() {
         //stop position with feature
@@ -324,11 +299,10 @@
         this.un("expand", this.position);
     },
 
-    /**
-     *  APIMethod: panIntoView
-     *      Pans the MapPanel's map so that an anchored popup
-     *      can come entirely into view, with padding specified
-     *      as per normal OpenLayers.Map popup padding.
+    /** private: method[panIntoView]
+     *  Pans the MapPanel's map so that an anchored popup can come entirely
+     *  into view, with padding specified as per normal OpenLayers.Map popup
+     *  padding.
      */ 
     panIntoView: function() {
         if(!this.anchored) {
@@ -374,9 +348,8 @@
         this.map.pan(dx, dy);
     },
 
-    /**
-     * Method: beforeDestroy
-     *     Cleanup events before destroying the popup.
+    /** private: method[beforeDestroy]
+     *  Cleanup events before destroying the popup.
      */
     beforeDestroy: function() {
         this.unbindFromMapPanel();
@@ -384,4 +357,5 @@
     }
 });
 
+/** api: xtype = gx_mappanel */
 Ext.reg('gx_popup', GeoExt.Popup); 

Added: sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/BaseLayerContainer.js
===================================================================
--- sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/BaseLayerContainer.js	                        (rev 0)
+++ sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/BaseLayerContainer.js	2009-05-19 23:30:53 UTC (rev 827)
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2008 The Open Planning Project
+ */
+
+/**
+ * @requires GeoExt/widgets/tree/LayerContainer.js
+ */
+Ext.namespace("GeoExt.tree");
+
+/**
+ * Class: GeoExt.tree.BaseLayerContainer
+ * 
+ * A layer container that will collect all base layers of an OpenLayers map.
+ * Only layers that have displayInLayerSwitcher set to true will be included.
+ * 
+ * To use this node type in JSON config, set nodeType to
+ * "olBaseLayerContainer".
+ * 
+ * Inherits from:
+ * - <GeoExt.tree.LayerContainer>
+ */
+GeoExt.tree.BaseLayerContainer = Ext.extend(GeoExt.tree.LayerContainer, {
+
+    /**
+     * Constructor: GeoExt.tree.BaseLayerContainer
+     * 
+     * Parameters:
+     * config - {Object}
+     */
+    constructor: function(config) {
+        config.text = config.text || "Base Layer";
+        GeoExt.tree.BaseLayerContainer.superclass.constructor.apply(this, arguments);
+    },
+
+    /**
+     * Method: addLayerNode
+     * Adds a child node representing a base layer of the map
+     * 
+     * Parameters:
+     * layerRecord - {Ext.data.Record} the layer record to add a node for
+     */
+    addLayerNode: function(layerRecord) {
+        var layer = layerRecord.get("layer");
+        if (layer.isBaseLayer == true) {
+            GeoExt.tree.BaseLayerContainer.superclass.addLayerNode.call(this,
+                layerRecord);
+        }
+    },
+    
+    /**
+     * Method: removeLayerNode
+     * Removes a child node representing a base layer of the map
+     * 
+     * Parameters:
+     * layerRecord - {Ext.data.Record} the layer record to remove the node for
+     */
+    removeLayerNode: function(layerRecord) {
+        var layer = layerRecord.get("layer");
+        if (layer.isBaseLayer == true) {
+            GeoExt.tree.BaseLayerContainer.superclass.removeLayerNode.call(this,
+                layerRecord);
+    	}
+    }
+});
+
+/**
+ * NodeType: gx_baselayercontainer
+ */
+Ext.tree.TreePanel.nodeTypes.gx_baselayercontainer = GeoExt.tree.BaseLayerContainer;

Modified: sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerContainer.js
===================================================================
--- sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerContainer.js	2009-05-19 23:27:21 UTC (rev 826)
+++ sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerContainer.js	2009-05-19 23:30:53 UTC (rev 827)
@@ -3,7 +3,7 @@
  */
 
 /**
- * @requires GeoExt/widgets/tree/LayerNode.js
+ * @include GeoExt/widgets/tree/LayerNode.js
  */
 Ext.namespace("GeoExt.tree");
 


Property changes on: sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerContainer.js
___________________________________________________________________
Name: svn:keywords
   + Id Author Date Revision
Name: svn:eol-style
   + native

Modified: sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerNode.js
===================================================================
--- sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerNode.js	2009-05-19 23:27:21 UTC (rev 826)
+++ sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerNode.js	2009-05-19 23:30:53 UTC (rev 827)
@@ -7,7 +7,7 @@
  * Class: GeoExt.tree.LayerNodeUI
  * 
  * Inherits from:
- * - <GeoExt.tree.TristateCheckboxNodeUI>
+ * - Ext.tree.TreeNodeUI
  */
 GeoExt.tree.LayerNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
     


Property changes on: sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/LayerNode.js
___________________________________________________________________
Name: svn:keywords
   + Id Author Date Revision
Name: svn:eol-style
   + native

Added: sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/OverlayLayerContainer.js
===================================================================
--- sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/OverlayLayerContainer.js	                        (rev 0)
+++ sandbox/opengeo/geoexplorer/lib/GeoExt/widgets/tree/OverlayLayerContainer.js	2009-05-19 23:30:53 UTC (rev 827)
@@ -0,0 +1,70 @@
+/**
+ * Copyright (c) 2008 The Open Planning Project
+ */
+
+/**
+ * @requires GeoExt/widgets/tree/LayerContainer.js
+ */
+Ext.namespace("GeoExt.tree");
+
+/**
+ * Class: GeoExt.tree.OverlayLayerContainer
+ * 
+ * A layer container that will collect all overlay layers of an OpenLayers map.
+ * Only layers that have displayInLayerSwitcher set to true will be included.
+ * 
+ * To use this node type in JSON config, set nodeType to
+ * "olOverlayLayerContainer".
+ * 
+ * Inherits from:
+ * - <GeoExt.tree.LayerContainer>
+ */
+GeoExt.tree.OverlayLayerContainer = Ext.extend(GeoExt.tree.LayerContainer, {
+
+    /**
+     * Constructor: GeoExt.tree.OverlayLayerContainer
+     * 
+     * Parameters:
+     * config - {Object}
+     */
+    constructor: function(config) {
+        config.text = config.text || "Overlays";
+        GeoExt.tree.OverlayLayerContainer.superclass.constructor.apply(this,
+            arguments);
+    },
+
+    /**
+     * Method: addLayerNode
+     * Adds a child node representing a overlay layer of the map
+     * 
+     * Parameters:
+     * layerRecord - {Ext.data.Record} the layer record to add a node for
+     */
+    addLayerNode: function(layerRecord) {
+        var layer = layerRecord.get("layer");
+        if (layer.isBaseLayer == false) {
+            GeoExt.tree.OverlayLayerContainer.superclass.addLayerNode.call(this,
+                layerRecord);
+        }
+    },
+    
+    /**
+     * Method: removeLayerNode
+     * Removes a child node representing an overlay layer of the map
+     * 
+     * Parameters:
+     * layerRecord - {Ext.data.Record} the layer record to remove the node for
+     */
+    removeLayerNode: function(layerRecord) {
+        var layer = layerRecord.get("layer");
+        if (layer.isBaseLayer == false) {
+            GeoExt.tree.OverlayLayerContainer.superclass.removeLayerNode.call(
+                this, layerRecord);
+    	}
+    }
+});
+
+/**
+ * NodeType: gx_overlaylayercontainer
+ */
+Ext.tree.TreePanel.nodeTypes.gx_overlaylayercontainer = GeoExt.tree.OverlayLayerContainer;

Modified: sandbox/opengeo/geoexplorer/lib/GeoExt.js
===================================================================
--- sandbox/opengeo/geoexplorer/lib/GeoExt.js	2009-05-19 23:27:21 UTC (rev 826)
+++ sandbox/opengeo/geoexplorer/lib/GeoExt.js	2009-05-19 23:30:53 UTC (rev 827)
@@ -85,6 +85,10 @@
             "GeoExt/widgets/legend/Image.js",
             "GeoExt/widgets/legend/WMS.js",
             "GeoExt/widgets/LegendPanel.js"
+            "GeoExt/widgets/tree/LayerNode.js",
+            "GeoExt/widgets/tree/LayerContainer.js",
+            "GeoExt/widgets/tree/BaseLayerContainer.js",
+            "GeoExt/widgets/tree/OverlayLayerContainer.js"
         );
 
         var agent = navigator.userAgent;

Modified: sandbox/opengeo/geoexplorer/tests/lib/GeoExt/data/FeatureRecord.html
===================================================================
--- sandbox/opengeo/geoexplorer/tests/lib/GeoExt/data/FeatureRecord.html	2009-05-19 23:27:21 UTC (rev 826)
+++ sandbox/opengeo/geoexplorer/tests/lib/GeoExt/data/FeatureRecord.html	2009-05-19 23:30:53 UTC (rev 827)
@@ -50,24 +50,6 @@
             t.eq(record.get("foo"), "bar", "foo data row set correctly");
         }
 
-        function test_copy(t) {
-            
-            t.plan(2);
-            
-            var feature = new OpenLayers.Feature.Vector();
-            feature.fid = "foo";
-            var recordType = GeoExt.data.FeatureRecord.create();
-            
-            var record = new recordType({feature: feature, fid: feature.fid});
-            var copy = record.copy();
-            
-            record.set("fid", "bar");
-            t.ok(copy.get("fid") === "foo", "setting a property on original doesn't modify copy");
-            
-            t.ok(copy.get("feature") !== feature, "copy does not have original feature");
-            
-        }
-
     </script>
   <body>
     <div id="mappanel"></div>

Modified: sandbox/opengeo/geoexplorer/tests/lib/GeoExt/data/LayerRecord.html
===================================================================
--- sandbox/opengeo/geoexplorer/tests/lib/GeoExt/data/LayerRecord.html	2009-05-19 23:27:21 UTC (rev 826)
+++ sandbox/opengeo/geoexplorer/tests/lib/GeoExt/data/LayerRecord.html	2009-05-19 23:30:53 UTC (rev 827)
@@ -44,23 +44,6 @@
             t.eq(record.get("foo"), "bar", "foo data row set correctly");
         }
         
-        function test_copy(t) {
-            
-            t.plan(2);
-            
-            var layer = new OpenLayers.Layer();
-            var recordType = GeoExt.data.LayerRecord.create();
-            
-            var record = new recordType({layer: layer, title: layer.name});
-            var copy = record.copy();
-            
-            record.set("title", "foo");
-            t.ok(copy.get("title") !== "foo", "setting a property on original doesn't modify copy");
-            
-            t.ok(copy.get("layer") !== layer, "copy does not have original layer");
-            
-        }
-        
     </script>
   <body>
     <div id="mappanel"></div>

Modified: sandbox/opengeo/geoexplorer/tests/lib/GeoExt/data/LayerStore.html
===================================================================
--- sandbox/opengeo/geoexplorer/tests/lib/GeoExt/data/LayerStore.html	2009-05-19 23:27:21 UTC (rev 826)
+++ sandbox/opengeo/geoexplorer/tests/lib/GeoExt/data/LayerStore.html	2009-05-19 23:30:53 UTC (rev 827)
@@ -169,7 +169,7 @@
 
         function test_add_remove(t) {
             
-            t.plan(3);
+            t.plan(6);
             
             var map = new OpenLayers.Map("mappanel");
             var store = new GeoExt.data.LayerStore({
@@ -185,12 +185,18 @@
             store.remove(record);
             t.eq(store.getCount(), 0, "removing a single record from the store removes one record");
 
-            //test adding a record with the same id
-            store.add([record]);
-            store.add(store.getAt(0).copy());
-            t.eq(map.layers.length,store.getCount(),"number of OpenLayers map layers equals number of records after adding record with same id");
+            // add back the original and prepare to add copy
+            store.add([record]);            
+            t.eq(store.getCount(), 1, "store has a single record before adding copy");
+            t.eq(map.layers.length, 1, "map has a single layer before adding copy");
             
 
+            // create a copy of the record with the same layer
+            var copy = record.copy(); // record with same id will replace original
+            copy.set("layer", record.get("layer")); // force records to have same layer            
+            store.add(copy);
+            t.eq(store.getCount(), 1, "store has a single record after adding copy");
+            t.eq(map.layers.length, 1, "map has a single layer after adding copy");
             
         }
         

Modified: sandbox/opengeo/geoexplorer/tests/lib/GeoExt/widgets/MapPanel.html
===================================================================
--- sandbox/opengeo/geoexplorer/tests/lib/GeoExt/widgets/MapPanel.html	2009-05-19 23:27:21 UTC (rev 826)
+++ sandbox/opengeo/geoexplorer/tests/lib/GeoExt/widgets/MapPanel.html	2009-05-19 23:30:53 UTC (rev 827)
@@ -35,11 +35,12 @@
         }
 
         function test_mappanel(t) {
-            t.plan(2)
+            t.plan(3)
             
             loadMapPanel();
             t.eq(mapPanel.map.getCenter().toString(), "lon=5,lat=45", "Map center set correctly");
             t.eq(mapPanel.map.getZoom(), 4, "Zoom set correctly");
+            t.eq(GeoExt.MapPanel.guess().id, mapPanel.id, "MapPanel guessed correctly");
         }
         
         function test_allOverlays(t) {

Modified: sandbox/opengeo/geoexplorer/tests/lib/GeoExt/widgets/tree/LayerContainer.html
===================================================================
--- sandbox/opengeo/geoexplorer/tests/lib/GeoExt/widgets/tree/LayerContainer.html	2009-05-19 23:27:21 UTC (rev 826)
+++ sandbox/opengeo/geoexplorer/tests/lib/GeoExt/widgets/tree/LayerContainer.html	2009-05-19 23:30:53 UTC (rev 827)
@@ -22,8 +22,7 @@
             t.ok(node.layerStore === store, "layerStore set");
             t.ok(node.defaults === defaults, "defaults set");
             
-            // TODO: this fails, confirm that it is on the Ext side only
-            //node.destroy();
+            node.destroy();
             
         }
         
@@ -63,4 +62,5 @@
     <body>
         <div id="map" style="width: 100px; height: 100px;"></div>
     </body>
-</html>
\ No newline at end of file
+</html>
+


Property changes on: sandbox/opengeo/geoexplorer/tests/lib/GeoExt/widgets/tree/LayerContainer.html
___________________________________________________________________
Name: svn:keywords
   + Id Author Date Revision
Name: svn:eol-style
   + native

Added: sandbox/opengeo/geoexplorer/tests/lib/GeoExt/widgets/tree/LayerNode.html
===================================================================
--- sandbox/opengeo/geoexplorer/tests/lib/GeoExt/widgets/tree/LayerNode.html	                        (rev 0)
+++ sandbox/opengeo/geoexplorer/tests/lib/GeoExt/widgets/tree/LayerNode.html	2009-05-19 23:30:53 UTC (rev 827)
@@ -0,0 +1,78 @@
+<html>
+    <head>
+        <script src="../../../../../../openlayers/lib/OpenLayers.js"></script>
+        <script src="../../../../../../ext/adapter/ext/ext-base.js"></script>
+        <script src="../../../../../../ext/ext-all-debug.js"></script>
+        <script src="../../../../../lib/GeoExt.js"></script>
+    
+        <script>
+        
+        function test_constructor(t) {
+            
+            t.plan(1);
+            
+            var store = new GeoExt.data.LayerStore();
+            
+            var node = new GeoExt.tree.LayerNode({
+                layer: "foo",
+                layerStore: store
+            });
+            
+            t.ok(node.layerStore === store, "layerStore set");
+            
+            node.destroy();
+            
+        }
+        
+        function test_render(t) {
+            
+            t.plan(5);
+            
+            var layer = new OpenLayers.Layer("foo");
+            
+            var mapPanel = new GeoExt.MapPanel({
+                layers: [layer],
+                allOverlays: true
+            });
+            
+            var node = new GeoExt.tree.LayerNode({
+                layer: "foo",
+                radioGroup: "group",
+                childNodeType: {
+                    add: function() {
+                        t.ok(true, "add function of childNodeType called");
+                    }
+                }
+            });
+            
+            node.on("radiochange", function() {
+                t.ok(arguments[0] === node, "radiochange event triggered with the selected node as first argument");
+            });
+                        
+            var panel = new Ext.tree.TreePanel({
+                renderTo: "tree",
+                root: node
+            });
+            
+            mapPanel.on("render", function() {
+                t.ok(node.layer === layer, "layer found on detected map panel");
+                
+                t.ok(node.ui.radio, "node has a radio button");
+                // simulate a click event for testing the radiochange event
+                node.ui.onClick({getTarget: function() {return true}});
+                
+                node.ui.toggleCheck();
+                t.eq(layer.visibility, false, "unchecking node hides layer");
+            });
+
+            mapPanel.render("map");
+            
+        }
+        
+        </script>
+    </head>
+    <body>
+        <div id="map" style="width: 100px; height: 100px;"></div>
+        <div id="tree" style="width: 100px; height: 100px;"></div>
+    </body>
+</html>
\ No newline at end of file

Modified: sandbox/opengeo/geoexplorer/tests/list-tests.html
===================================================================
--- sandbox/opengeo/geoexplorer/tests/list-tests.html	2009-05-19 23:27:21 UTC (rev 826)
+++ sandbox/opengeo/geoexplorer/tests/list-tests.html	2009-05-19 23:30:53 UTC (rev 827)
@@ -16,4 +16,6 @@
   <li>lib/GeoExt/widgets/form/BasicForm.html</li>
   <li>lib/GeoExt/widgets/form/FormPanel.html</li>
   <li>lib/GeoExt/widgets/LegendPanel.html</li>
+  <li>lib/GeoExt/widgets/tree/LayerNode.html</li>
+  <li>lib/GeoExt/widgets/tree/LayerContainer.html</li>
 </ul>



More information about the Commits mailing list