[Commits] r943 - in sandbox/camptocamp/geobretagne: build examples lib lib/GeoExt/data lib/GeoExt/widgets lib/GeoExt/widgets/tree tests tests/lib/GeoExt/widgets
commits at geoext.org
commits at geoext.org
Tue Jun 2 14:41:29 CEST 2009
Author: elemoine
Date: 2009-06-02 14:41:29 +0200 (Tue, 02 Jun 2009)
New Revision: 943
Added:
sandbox/camptocamp/geobretagne/examples/legendpanel.html
sandbox/camptocamp/geobretagne/examples/legendpanel.js
sandbox/camptocamp/geobretagne/examples/mappanel-viewport.html
sandbox/camptocamp/geobretagne/examples/mappanel-viewport.js
sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendImage.js
sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendPanel.js
sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendWMS.js
sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/LegendPanel.html
Removed:
sandbox/camptocamp/geobretagne/build/apidoc_config/
Modified:
sandbox/camptocamp/geobretagne/examples/toolbar.html
sandbox/camptocamp/geobretagne/examples/toolbar.js
sandbox/camptocamp/geobretagne/lib/GeoExt.js
sandbox/camptocamp/geobretagne/lib/GeoExt/data/FeatureRecord.js
sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerReader.js
sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerRecord.js
sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerStore.js
sandbox/camptocamp/geobretagne/lib/GeoExt/data/ProtocolProxy.js
sandbox/camptocamp/geobretagne/lib/GeoExt/data/ScaleStore.js
sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesReader.js
sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesStore.js
sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/Action.js
sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/MapPanel.js
sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/BaseLayerContainer.js
sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/LayerContainer.js
sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/LayerNode.js
sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/OverlayLayerContainer.js
sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/Action.html
sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/MapPanel.html
sandbox/camptocamp/geobretagne/tests/list-tests.html
Log:
svn merge -r865:HEAD http://svn.geoext.org/core/trunk/geoext .
Copied: sandbox/camptocamp/geobretagne/examples/legendpanel.html (from rev 942, core/trunk/geoext/examples/legendpanel.html)
===================================================================
--- sandbox/camptocamp/geobretagne/examples/legendpanel.html (rev 0)
+++ sandbox/camptocamp/geobretagne/examples/legendpanel.html 2009-06-02 12:41:29 UTC (rev 943)
@@ -0,0 +1,26 @@
+<html>
+ <head>
+ <script type="text/javascript" src="http://dev.geoext.org/trunk/ext/adapter/ext/ext-base.js"></script>
+ <script type="text/javascript" src="http://dev.geoext.org/trunk/ext/ext-all.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="legendpanel.js"></script>
+
+ <style type="text/css">
+ .mylabel {
+ font-weight: bold;
+ color: red;
+ }
+ </style>
+ </head>
+ <body>
+ <h1>GeoExt.LegendPanel</h1>
+ <p>This example shows the how to create a LegendPanel that autopopulates with legends from a map
+ that has already been created.</p>
+ <p>The js is not minified so it is readable. See <a href="legendpanel.js">legendpanel.js</a>.</p>
+ <div id="view"></div>
+ </body>
+</html>
\ No newline at end of file
Copied: sandbox/camptocamp/geobretagne/examples/legendpanel.js (from rev 942, core/trunk/geoext/examples/legendpanel.js)
===================================================================
--- sandbox/camptocamp/geobretagne/examples/legendpanel.js (rev 0)
+++ sandbox/camptocamp/geobretagne/examples/legendpanel.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -0,0 +1,91 @@
+
+var mapPanel;
+
+Ext.onReady(function() {
+ var map = new OpenLayers.Map({allOverlays: true});
+ map.addLayers([
+ new OpenLayers.Layer.WMS(
+ "Tasmania",
+ "http://publicus.opengeo.org/geoserver/wms?",
+ {layers: 'topp:tasmania_state_boundaries', format: 'image/png', transparent: true},
+ {singleTile: true}),
+ new OpenLayers.Layer.WMS(
+ "Cities and Roads",
+ "http://publicus.opengeo.org/geoserver/wms?",
+ {layers: 'topp:tasmania_cities,topp:tasmania_roads', format: 'image/png', transparent: true},
+ {singleTile: true}),
+ new OpenLayers.Layer.Vector('Polygons', {styleMap: new OpenLayers.StyleMap({
+ "default": new OpenLayers.Style({
+ pointRadius: 8,
+ fillColor: "#00ffee",
+ strokeColor: "#000000",
+ strokeWidth: 2
+ }) }) })
+ ]);
+ map.addControl(new OpenLayers.Control.LayerSwitcher());
+
+ var addLayer = function() {
+ var wmslayer = new OpenLayers.Layer.WMS("Bodies of Water",
+ "http://publicus.opengeo.org/geoserver/wms?",
+ {layers: 'topp:tasmania_water_bodies', format: 'image/png', transparent: true},
+ {singleTile: true});
+ mapPanel.map.addLayer(wmslayer);
+ };
+
+ var removeLayer = function() {
+ mapPanel.map.removeLayer(mapPanel.map.layers[1]);
+ };
+
+ var moveLayer = function(idx) {
+ mapPanel.map.setLayerIndex(mapPanel.map.layers[0], idx);
+ };
+
+ var toggleVisibility = function() {
+ mapPanel.map.layers[1].setVisibility(!mapPanel.map.layers[1].getVisibility());
+ };
+
+ var updateHideInLegend = function() {
+ mapPanel.layers.getAt(1).set("hideInLegend", true);
+ };
+
+ var updateLegendUrl = function() {
+ mapPanel.layers.getAt(0).set("legendURL", "http://www.geoext.org/trac/geoext/chrome/site/img/GeoExt.png");
+ };
+
+ var mapPanel = new GeoExt.MapPanel({
+ region: 'center',
+ height: 400,
+ width: 600,
+ map: map,
+ center: new OpenLayers.LonLat(146.4, -41.6),
+ zoom: 7
+ });
+
+ var legendPanel = new GeoExt.LegendPanel({
+ labelCls: 'mylabel',
+ bodyStyle: 'padding:5px',
+ width: 350,
+ autoScroll: true,
+ region: 'west'
+ });
+
+ new Ext.Panel({
+ title: "GeoExt LegendPanel Demo",
+ layout: 'border',
+ renderTo: 'view',
+ height: 400,
+ width: 800,
+ tbar: new Ext.Toolbar({
+ items: [
+ {text: 'add', handler: addLayer},
+ {text: 'remove', handler: removeLayer},
+ {text: 'movetotop', handler: function() { moveLayer(10); } },
+ {text: 'moveup', handler: function() { moveLayer(1); } },
+ {text: 'togglevis', handler: toggleVisibility},
+ {text: 'hide', handler: updateHideInLegend},
+ {text: 'legendurl', handler: updateLegendUrl}
+ ]
+ }),
+ items: [legendPanel, mapPanel]
+ });
+});
Copied: sandbox/camptocamp/geobretagne/examples/mappanel-viewport.html (from rev 942, core/trunk/geoext/examples/mappanel-viewport.html)
===================================================================
--- sandbox/camptocamp/geobretagne/examples/mappanel-viewport.html (rev 0)
+++ sandbox/camptocamp/geobretagne/examples/mappanel-viewport.html 2009-06-02 12:41:29 UTC (rev 943)
@@ -0,0 +1,40 @@
+<html>
+ <head>
+ <title>GeoExt MapPanel in an Ext Viewport</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>
+
+ <!-- Google Maps API for "localhost" -->
+ <!--
+ <script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
+ -->
+ <!-- Google Maps API for "dev.geoext.org" -->
+ <script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA_5ak-hsiH4j5bQQn7-k66xTWxvN8zH6Ta_pgIhhU0TB7bG8iAhS99ituPif4lG-2CHXoZ3qenLnK1g'></script>
+
+ <script src="http://openlayers.org/api/2.8-rc4/OpenLayers.js"></script>
+ <!--
+ <script type="text/javascript" src="../../openlayers/lib/OpenLayers.js"></script>
+ -->
+
+ <script type="text/javascript" src="../lib/GeoExt.js"></script>
+
+ <script type="text/javascript" src="mappanel-viewport.js"></script>
+
+ </head>
+ <body>
+ <div id="title">
+ <h1>GeoExt.MapPanel in an Ext.Viewport</h1>
+ </div>
+
+ <div id="description">
+ <p>This example shows how to place a MapPanel as a region in a
+ container using a border layout, the container is a Viewport in
+ this example.</p>
+
+ <p>The js is not minified so it is readable. See <a
+ href="mappanel-viewport.js">mappanel-viewport.js</a>.</p>
+ </div>
+ </body>
+</html>
Copied: sandbox/camptocamp/geobretagne/examples/mappanel-viewport.js (from rev 942, core/trunk/geoext/examples/mappanel-viewport.js)
===================================================================
--- sandbox/camptocamp/geobretagne/examples/mappanel-viewport.js (rev 0)
+++ sandbox/camptocamp/geobretagne/examples/mappanel-viewport.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -0,0 +1,68 @@
+var mapPanel;
+
+Ext.onReady(function() {
+
+ // if true a google layer is used, if false
+ // the bluemarble WMS layer is used
+ var google = false;
+
+ var options, layer;
+ var extent = new OpenLayers.Bounds(-5, 35, 15, 55);
+
+ if (google) {
+
+ options = {
+ projection: new OpenLayers.Projection("EPSG:900913"),
+ units: "m",
+ numZoomLevels: 18,
+ maxResolution: 156543.0339,
+ maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
+ 20037508, 20037508.34)
+ };
+
+ layer = new OpenLayers.Layer.Google(
+ "Google Satellite",
+ {type: G_SATELLITE_MAP, sphericalMercator: true}
+ );
+
+ extent.transform(
+ new OpenLayers.Projection("EPSG:4326"), options.projection
+ );
+
+ } else {
+ layer = new OpenLayers.Layer.WMS(
+ "bluemarble",
+ "http://sigma.openplans.org/geoserver/wms?",
+ {layers: 'bluemarble'},
+ {isBaseLayer: true}
+ );
+ }
+
+ var map = new OpenLayers.Map(options);
+
+ new Ext.Viewport({
+ layout: "border",
+ items: [{
+ region: "north",
+ contentEl: "title",
+ height: 50
+ }, {
+ region: "center",
+ id: "mappanel",
+ title: "Map",
+ xtype: "gx_mappanel",
+ map: map,
+ layers: [layer],
+ extent: extent,
+ split: true
+ }, {
+ region: "east",
+ title: "Description",
+ contentEl: "description",
+ width: 200,
+ split: true
+ }]
+ });
+
+ mapPanel = Ext.getCmp("mappanel");
+});
Modified: sandbox/camptocamp/geobretagne/examples/toolbar.html
===================================================================
--- sandbox/camptocamp/geobretagne/examples/toolbar.html 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/examples/toolbar.html 2009-06-02 12:41:29 UTC (rev 943)
@@ -19,14 +19,29 @@
<script type="text/javascript" src="toolbar.js"></script>
+ <style type="text/css">
+ /* work around an Ext bug that makes the rendering
+ of menu items not as one would expect */
+ .ext-ie .x-menu-item-icon {
+ left: -24px;
+ }
+ .ext-strict .x-menu-item-icon {
+ left: 3px;
+ }
+ .ext-ie6 .x-menu-item-icon {
+ left: -24px;
+ }
+ .ext-ie7 .x-menu-item-icon {
+ left: -24px;
+ }
+ </style>
</head>
<body>
<h1>OpenLayers controls in an Ext toolbar</h1>
<p>This example shows how to add OpenLayers controls in an Ext toolbar.
- GeoExt provides the GeoExt.Action.fromControl method for adapating a
- control to an object that can be inserted in a toolbar or in a
- menu.</p>
+ GeoExt provides the GeoExt.Action class for adapating a control to an
+ object that can be inserted in a toolbar or in a menu.</p>
<p>The js is not minified so it is readable. See <a
href="toolbar.js">toolbar.js</a>.</p>
Modified: sandbox/camptocamp/geobretagne/examples/toolbar.js
===================================================================
--- sandbox/camptocamp/geobretagne/examples/toolbar.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/examples/toolbar.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -12,21 +12,21 @@
var ctrl, toolbarItems = [], action, actions = {};
// ZoomToMaxExtent control, a "button" control
- ctrl = new OpenLayers.Control.ZoomToMaxExtent();
- map.addControl(ctrl);
- action = GeoExt.Action.fromControl(ctrl, {
+ action = new GeoExt.Action({
+ control: new OpenLayers.Control.ZoomToMaxExtent(),
+ map: map,
text: "max extent"
- })
+ });
actions["max_extent"] = action;
toolbarItems.push(action);
toolbarItems.push("-");
// Navigation control and DrawFeature controls
// in the same toggle group
- ctrl = new OpenLayers.Control.Navigation();
- map.addControl(ctrl);
- action = GeoExt.Action.fromControl(ctrl, {
+ action = new GeoExt.Action({
text: "nav",
+ control: new OpenLayers.Control.Navigation(),
+ map: map,
// button options
toggleGroup: "draw",
allowDepress: false,
@@ -37,12 +37,13 @@
});
actions["nav"] = action;
toolbarItems.push(action);
- ctrl = new OpenLayers.Control.DrawFeature(
- vector, OpenLayers.Handler.Polygon
- );
- map.addControl(ctrl);
- action = GeoExt.Action.fromControl(ctrl, {
+
+ action = new GeoExt.Action({
text: "draw poly",
+ control: new OpenLayers.Control.DrawFeature(
+ vector, OpenLayers.Handler.Polygon
+ ),
+ map: map,
// button options
toggleGroup: "draw",
allowDepress: false,
@@ -51,12 +52,13 @@
});
actions["draw_poly"] = action;
toolbarItems.push(action);
- ctrl = new OpenLayers.Control.DrawFeature(
- vector, OpenLayers.Handler.Path
- );
- map.addControl(ctrl);
- action = GeoExt.Action.fromControl(ctrl, {
+
+ action = new GeoExt.Action({
text: "draw line",
+ control: new OpenLayers.Control.DrawFeature(
+ vector, OpenLayers.Handler.Path
+ ),
+ map: map,
// button options
toggleGroup: "draw",
allowDepress: false,
@@ -68,13 +70,13 @@
toolbarItems.push("-");
// SelectFeature control, a "toggle" control
- ctrl = new OpenLayers.Control.SelectFeature(vector, {
- type: OpenLayers.Control.TYPE_TOGGLE,
- hover: true
- });
- map.addControl(ctrl);
- action = GeoExt.Action.fromControl(ctrl, {
+ action = new GeoExt.Action({
text: "select",
+ control: new OpenLayers.Control.SelectFeature(vector, {
+ type: OpenLayers.Control.TYPE_TOGGLE,
+ hover: true
+ }),
+ map: map,
// button options
enableToggle: true
});
@@ -85,14 +87,18 @@
// Navigation history - two "button" controls
ctrl = new OpenLayers.Control.NavigationHistory();
map.addControl(ctrl);
- action = GeoExt.Action.fromControl(ctrl.previous, {
+
+ action = new GeoExt.Action({
text: "previous",
+ control: ctrl.previous,
disabled: true
});
actions["previous"] = action;
toolbarItems.push(action);
- action = GeoExt.Action.fromControl(ctrl.next, {
+
+ action = new GeoExt.Action({
text: "next",
+ control: ctrl.next,
disabled: true
});
actions["next"] = action;
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/data/FeatureRecord.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/data/FeatureRecord.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/data/FeatureRecord.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -27,18 +27,14 @@
{name: "feature"}, {name: "state"}, {name: "fid"}
]);
-/**
- * APIFunction: GeoExt.data.FeatureRecord.create
- * Creates a constructor for a FeatureRecord, optionally with additional
- * fields.
- *
- * Parameters:
- * o - {Array} Field definition as in {Ext.data.Record.create}. Can be omitted
- * if no additional fields are required (records will always have fields
- * {OpenLayers.Feature} "feature", {String} "state" and {String} "fid".
- *
- * Returns:
- * {Function} A specialized {<GeoExt.data.FeatureRecord>} constructor.
+/** api: classmethod[create]
+ * :param o: ``Array`` Field definition as in ``Ext.data.Record.create``. Can
+ * be omitted if no additional fields are required.
+ * :return: ``Function`` A specialized :class:`GeoExt.data.FeatureRecord`
+ * constructor.
+ *
+ * Creates a constructor for a :class:`GeoExt.data.FeatureRecord`, optionally
+ * with additional fields.
*/
GeoExt.data.FeatureRecord.create = function(o) {
var f = Ext.extend(GeoExt.data.FeatureRecord, {});
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerReader.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerReader.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerReader.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -9,30 +9,31 @@
* @include GeoExt/data/LayerRecord.js
*/
+/** api: (define)
+ * module = GeoExt.data
+ * class = LayerReader
+ * base_link = `Ext.data.DataReader <http://extjs.com/deploy/dev/docs/?class=Ext.data.DataReader>`_
+ */
Ext.namespace("GeoExt", "GeoExt.data");
-/**
- * Class: GeoExt.data.LayerReader
- * LayerReader is a specific Ext.data.DataReader for converting
- * layers into layer records, i.e. {OpenLayers.Layer} objects
- * into {GeoExt.data.LayerRecor} objects.
- *
- * Usage example:
- * (start code)
- * var reader = new GeoExt.data.LayerReader();
- * var layerData = reader.readRecords(map.layers);
- * var numRecords = layerData.totalRecords;
- * var layerRecords = layerData.records;
- * (end)
- *
- * Inherits from:
- * - {Ext.data.DataReader}
+/** api: example
+ * Sample using a reader to create records from an array of layers:
+ *
+ * .. code-block:: javascript
+ *
+ * var reader = new GeoExt.data.LayerReader();
+ * var layerData = reader.readRecords(map.layers);
+ * var numRecords = layerData.totalRecords;
+ * var layerRecords = layerData.records;
*/
-/**
- * Constructor: GeoExt.data.LayerReader
- * Create a layer reader. The arguments passed are similar to those
- * passed to {Ext.data.DataReader} constructor.
+/** api: constructor
+ * .. class:: LayerReader(meta, recordType)
+ *
+ * Data reader class to create an array of
+ * :class:`GeoExt.data.LayerRecord` objects from an array of
+ * ``OpenLayers.Layer`` objects for use in a
+ * :class:`GeoExt.data.LayerStore` object.
*/
GeoExt.data.LayerReader = function(meta, recordType) {
meta = meta || {};
@@ -46,24 +47,19 @@
Ext.extend(GeoExt.data.LayerReader, Ext.data.DataReader, {
- /**
- * APIProperty: totalRecords
- * {Integer}
+ /** private: property[totalRecords]
+ * ``Integer``
*/
totalRecords: null,
- /**
- * APIMethod: readRecords
- * From an array of {OpenLayers.Layer} objects create a data block
- * containing {<GeoExt.data.LayerRecord>} objects.
- *
- * Parameters:
- * layers - {Array({OpenLayers.Layer})} Array of layers.
- *
- * Returns:
- * {Object} An object with two properties. The value of the property "records"
- * is the array of layer records. The value of the property "totalRecords"
- * is the number of records in the array.
+ /** api: method[readRecords]
+ * :param layers: ``Array(OpenLayers.Layer)`` List of layers for creating
+ * records.
+ * :return: ``Object`` An object with ``records`` and ``totalRecords``
+ * properties.
+ *
+ * From an array of {OpenLayers.Layer} objects create a data block
+ * containing :class:`GeoExt.data.LayerRecord` objects.
*/
readRecords : function(layers) {
var records = [];
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerRecord.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerRecord.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerRecord.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -5,42 +5,35 @@
*
* pending approval */
+/** api: (define)
+ * module = GeoExt.data
+ * class = LayerRecord
+ * base_link = `Ext.data.Record <http://extjs.com/deploy/dev/docs/?class=Ext.data.Record>`_
+ */
Ext.namespace("GeoExt.data");
-/**
- * Class: GeoExt.data.LayerRecord
- * A subclass of {Ext.data.Record} which provides a special record that
- * represents an {OpenLayers.Layer}. This record will always have at least a
- * layer and a title field in its data. The id of this record will be the same
- * as the id of the layer it represents.
- *
- * Inherits from
- * - {Ext.data.Record}
+/** api: constructor
+ * .. class:: LayerRecord
+ *
+ * A record that represents an ``OpenLayers.Layer``. This record
+ * will always have at least the following fields:
+ *
+ * * layer ``OpenLayers.Layer``
+ * * title ``String``
*/
-/**
- * Constructor: GeoExt.data.LayerRecord
- *
- * Parameters:
- * data - {Object} data object for the record
- * id - {String} id of the record
- */
GeoExt.data.LayerRecord = Ext.data.Record.create([
{name: "layer"},
{name: "title", type: "string", mapping: "name"}
]);
-/**
- * APIFunction: GeoExt.data.LayerRecord.create
- * Creates a constructor for a LayerRecord, optionally with additional
- * fields.
- *
- * Parameters:
- * o - {Array} Field definition as in {Ext.data.Record.create}. Can be omitted
- * if no additional fields are required (records will always have a
- * {OpenLayers.Layer} layer and a {String} title field).
- *
- * Returns:
- * {Function} A specialized {<GeoExt.data.LayerRecord>} constructor.
+/** api: classmethod[create]
+ * :param o: ``Array`` Field definition as in ``Ext.data.Record.create``. Can
+ * be omitted if no additional fields are required.
+ * :return: ``Function`` A specialized :class:`GeoExt.data.LayerRecord`
+ * constructor.
+ *
+ * Creates a constructor for a :class:`GeoExt.data.LayerRecord`, optionally
+ * with additional fields.
*/
GeoExt.data.LayerRecord.create = function(o) {
var f = Ext.extend(GeoExt.data.LayerRecord, {});
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerStore.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerStore.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/data/LayerStore.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -9,69 +9,82 @@
* @include GeoExt/data/LayerReader.js
*/
+/** api: (define)
+ * module = GeoExt.data
+ * class = LayerStore
+ * base_link = `Ext.data.DataStore <http://extjs.com/deploy/dev/docs/?class=Ext.data.DataStore>`_
+ */
Ext.namespace("GeoExt.data");
-/**
- * Class: GeoExt.data.LayerStoreMixin
- * A store that synchronizes a layers array of an {OpenLayers.Map} with a
- * layer store holding {<GeoExt.data.LayerRecord>} entries.
+/** private: constructor
+ * .. class:: LayerStoreMixin
+ * A store that synchronizes a layers array of an {OpenLayers.Map} with a
+ * layer store holding {<GeoExt.data.LayerRecord>} entries.
*
- * This class can not be instantiated directly. Instead, it is meant to extend
- * {Ext.data.Store} or a subclass of it:
- * (start code)
- * var store = new (Ext.extend(Ext.data.Store, GeoExt.data.LayerStoreMixin))({
- * map: myMap,
- * layers: myLayers
- * });
- * (end)
+ * This class can not be instantiated directly. Instead, it is meant to
+ * extend ``Ext.data.Store`` or a subclass of it.
+ */
+
+/** private: example
+ * Sample code to extend a store with the LayerStoreMixin.
+ *
+ * .. code-block:: javascript
+ *
+ * var store = new (Ext.extend(Ext.data.Store, GeoExt.data.LayerStoreMixin))({
+ * map: myMap,
+ * layers: myLayers
+ * });
*
- * For convenience, a {<GeoExt.data.LayerStore>} class is available as a
- * shortcut to the Ext.extend sequence in the above code snippet. The above
- * is equivalent to:
- * (start code)
- * var store = new GeoExt.data.LayerStore({
- * map: myMap,
- * layers: myLayers
- * });
- * (end)
+ * For convenience, a :class:`GeoExt.data.LayerStore` class is available as a
+ * shortcut to the ``Ext.extend`` sequence in the above code snippet.
*/
+
GeoExt.data.LayerStoreMixin = {
- /**
- * APIProperty: map
- * {OpenLayers.Map} Map that this store will be in sync with.
+
+ /** api: config[map]
+ * ``OpenLayers.Map``
+ * Map that this store will be in sync with.
*/
+
+ /** api: property[map]
+ * ``OpenLayers.Map``
+ * Map that the store is synchronized with.
+ */
map: null,
+
+ /** api: config[layers]
+ * ``Array(OpenLayers.Layer)``
+ * Layers that will be added to the store (and the map, depending on the
+ * value of the ``initDir`` option.
+ */
+
+ /** api: config[initDir]
+ * ``Number``
+ * Bitfields specifying the direction to use for the initial sync between
+ * the map and the store, if set to 0 then no initial sync is done.
+ * Defaults to ``GeoExt.data.LayerStore.MAP_TO_STORE|GeoExt.data.LayerStore.STORE_TO_MAP``
+ */
- /**
- * APIProperty: reader
- * {<GeoExt.data.LayerReader>} The reader used to get
- * <GeoExt.data.LayerRecord> objects from {OpenLayers.Layer}
- * objects.
+ /** api: config[fields]
+ * ``Array``
+ * If provided a custom layer record type with additional fields will be
+ * used. Default fields for every layer record are `layer`
+ * (``OpenLayers.Layer``) `title` (``String``). The value of this option is
+ * either a field definition objects as passed to the
+ * :meth:`GeoExt.data.LayerRecord.create` function or a
+ * :class:`GeoExt.data.LayerRecord` constructor created using
+ * :meth:`GeoExt.data.LayerRecord.create`.
*/
+
+ /** api: config[reader]
+ * ``Ext.data.DataReader`` The reader used to produce
+ * :class:`GeoExt.data.LayerRecord` objects from ``OpenLayers.Layer``
+ * objects. If not provided, a :class:`GeoExt.data.LayerReader` will be
+ * used.
+ */
reader: null,
- /**
- * Constructor: GeoExt.data.LayerStoreMixin
- *
- * Parameters:
- * config - {Object}
- *
- * Valid config options:
- * map - {OpenLayers.Map|<GeoExt.MapPanel>} map to sync the layer store
- * with.
- * layers - {Array(OpenLayers.Layer)} Layers that will be added to the
- * store (and the map, depending on the value of the initDir option).
- * fields - {Array} If provided a custom layer record type with additional
- * fields will be used. Default fields for every layer record are
- * {OpenLayers.Layer} layer and {String} title. The value of this
- * option is either a field definition objects as passed to the
- * GeoExt.data.LayerRecord.create function or a
- * {<GeoExt.data.LayerRecord>} constructor created using
- * GeoExt.data.LayerRecord.create.
- * initDir - {Number} Bitfields specifying the direction to use for the
- * initial sync between the map and the store, if set to 0 then no
- * initial sync is done. Defaults to
- * <GeoExt.data.LayerStore.MAP_TO_STORE>|<GeoExt.data.LayerStore.STORE_TO_MAP>.
+ /** private: method[constructor]
*/
constructor: function(config) {
config = config || {};
@@ -96,20 +109,12 @@
}
},
- /**
- * APIMethod: bind
- * Bind this store to a map instance, once bound the store
- * is synchronized with the map and vice-versa.
- *
- * Parameters:
- * map - {OpenLayers.Map} The map instance.
- * options - {Object}
- *
- * Valid config options:
- * initDir - {Number} Bitfields specifying the direction to use for the
- * initial sync between the map and the store, if set to 0 then no
- * initial sync is done. Defaults to
- * <GeoExt.data.LayerStore.MAP_TO_STORE>|<GeoExt.data.LayerStore.STORE_TO_MAP>.
+ /** private: method[bind]
+ * :param map: ``OpenLayers.Map`` The map instance.
+ * :param options: ``Object``
+ *
+ * Bind this store to a map instance, once bound the store
+ * is synchronized with the map and vice-versa.
*/
bind: function(map, options) {
if(this.map) {
@@ -157,9 +162,8 @@
});
},
- /**
- * APIMethod: unbind
- * Unbind this store from the map it is currently bound.
+ /** private: method[unbind]
+ * Unbind this store from the map it is currently bound.
*/
unbind: function() {
if(this.map) {
@@ -180,13 +184,11 @@
}
},
- /**
- * Method: onChangeLayer
- * Handler for layer changes. When layer order changes, this moves the
- * appropriate record within the store.
- *
- * Parameters:
- * evt - {Object}
+ /** private: method[onChangeLayer]
+ * :param evt: ``Object``
+ *
+ * Handler for layer changes. When layer order changes, this moves the
+ * appropriate record within the store.
*/
onChangeLayer: function(evt) {
var layer = evt.layer;
@@ -213,12 +215,10 @@
}
},
- /**
- * Method: onAddLayer
- * Handler for a map's addlayer event
- *
- * Parameters:
- * evt - {Object}
+ /** private: method[onAddLayer]
+ * :param evt: ``Object``
+ *
+ * Handler for a map's addlayer event
*/
onAddLayer: function(evt) {
if(!this._adding) {
@@ -229,12 +229,10 @@
}
},
- /**
- * Method: onRemoveLayer
- * Handler for a map's removelayer event
+ /** private: method[onRemoveLayer]
+ * :param evt: ``Object``
*
- * Parameters:
- * evt - {Object}
+ * Handler for a map's removelayer event
*/
onRemoveLayer: function(evt){
if(!this._removing) {
@@ -245,14 +243,12 @@
}
},
- /**
- * Method: onLoad
- * Handler for a store's load event
+ /** private: method[onLoad]
+ * :param store: ``Ext.data.Store``
+ * :param records: ``Array(Ext.data.Record)``
+ * :param options: ``Object``
*
- * Parameters:
- * store - {<Ext.data.Store>}
- * records - {Array(Ext.data.Record)}
- * options - {Object}
+ * Handler for a store's load event
*/
onLoad: function(store, records, options) {
if (!Ext.isArray(records)) {
@@ -279,12 +275,10 @@
}
},
- /**
- * Method: onClear
- * Handler for a store's clear event
+ /** private: method[onClear]
+ * :param store: ``Ext.data.Store``
*
- * Parameters:
- * store - {<Ext.data.Store>}
+ * Handler for a store's clear event
*/
onClear: function(store) {
this._removing = true;
@@ -294,14 +288,12 @@
delete this._removing;
},
- /**
- * Method: onAdd
- * Handler for a store's add event
+ /** private: method[onAdd]
+ * :param store: ``Ext.data.Store``
+ * :param records: ``Array(Ext.data.Record)``
+ * :param index: ``Number``
*
- * Parameters:
- * store - {<Ext.data.Store>}
- * records - {Array(Ext.data.Record)}
- * index - {Number}
+ * Handler for a store's add event
*/
onAdd: function(store, records, index) {
if(!this._adding) {
@@ -318,14 +310,12 @@
}
},
- /**
- * Method: onRemove
- * Handler for a store's remove event
+ /** private: method[onRemove]
+ * :param store: ``Ext.data.Store``
+ * :param record: ``Ext.data.Record``
+ * :param index: ``Number``
*
- * Parameters:
- * store - {<Ext.data.Store>}
- * records - {Array(Ext.data.Record)}
- * index - {Number}
+ * Handler for a store's remove event
*/
onRemove: function(store, record, index){
if(!this._removing) {
@@ -338,47 +328,46 @@
}
},
- /**
- * Method: removeMapLayers
- * Removes a record's layer from the bound map.
- *
- * Parameters:
- * record - {<Ext.data.Record>}
+ /** private: method[removeMapLayer]
+ * :param record: ``Ext.data.Record``
+ *
+ * Removes a record's layer from the bound map.
*/
removeMapLayer: function(record){
this.map.removeLayer(record.get("layer"));
},
- /**
- * Method: onReplace
- * Handler for a store's data collections' replace event
- *
- * Parameters:
- * key - {String}
- * oldRecord - {Object} In this case, a record that has been replaced.
- * newRecord - {Object} In this case, a record that is replacing oldRecord.
+ /** private: method[onReplace]
+ * :param key: ``String``
+ * :param oldRecord: ``Object`` In this case, a record that has been
+ * replaced.
+ * :param newRecord: ``Object`` In this case, a record that is replacing
+ * oldRecord.
+
+ * Handler for a store's data collections' replace event
*/
onReplace: function(key, oldRecord, newRecord){
this.removeMapLayer(oldRecord);
}
};
-/**
- * Class: GeoExt.data.LayerStore
- * Default implementation of an {Ext.data.Store} extended with
- * {<GeoExt.data.LayerStoreMixin>}
- *
- * Inherits from:
- * - {Ext.data.Store}
- * - {<GeoExt.data.LayerStoreMixin>}
+/** api: example
+ * Sample to create a new store containing a cache of
+ * :class:`GeoExt.data.LayerRecord` instances derived from map layers.
+ *
+ * .. code-block:: javascript
+ *
+ * var store = new GeoExt.data.LayerStore({
+ * map: myMap,
+ * layers: myLayers
+ * });
*/
-/**
- * Constructor: GeoExt.data.LayerStore
- *
- * Parameters:
- * config - {Object} See {<GeoExt.data.LayerStoreMixin>} and
- * http://extjs.com/deploy/dev/docs/?class=Ext.data.Store for valid config
- * options.
+
+/** api: constructor
+ * .. class:: LayerStore
+ *
+ * A store that contains a cache of :class:`GeoExt.data.LayerRecord`
+ * objects.
*/
GeoExt.data.LayerStore = Ext.extend(
Ext.data.Store,
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/data/ProtocolProxy.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/data/ProtocolProxy.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/data/ProtocolProxy.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -17,59 +17,57 @@
* along with GeoExt. If not, see <http://www.gnu.org/licenses/>.
*/
+/** api: (define)
+ * module = GeoExt.data
+ * class = ProtocolProxy
+ * base_link = `Ext.data.DataProxy <http://extjs.com/deploy/dev/docs/?class=Ext.data.DataProxy>`_
+ */
Ext.namespace('GeoExt', 'GeoExt.data');
-/**
- * Class: GeoExt.data.ProtocolProxy
- */
-
-/**
- * Constructor: GeoExt.data.ProtocolProxy
- *
- * Parameters:
- * config - {Object} Config object
- */
GeoExt.data.ProtocolProxy = function(config) {
GeoExt.data.ProtocolProxy.superclass.constructor.call(this);
Ext.apply(this, config);
};
+/** api: constructor
+ * .. class:: ProtocolProxy
+ *
+ * A data proxy for use with ``OpenLayers.Proxy`` objects.
+ */
Ext.extend(GeoExt.data.ProtocolProxy, Ext.data.DataProxy, {
- /**
- * APIProperty: protocol
- * {<OpenLayers.Protocol>} The protocol used to fetch features.
+
+ /** api: config[protocol]
+ * ``OpenLayers.Protocol``
+ * The protocol used to fetch features.
*/
protocol: null,
- /**
- * APIProperty: abortPrevious
- * {Boolean} Whether to abort the previous request or not, defaults
- * to true.
+ /** api: config[abortPrevious]
+ * ``Boolean``
+ * Abort any previous request before issuing another. Default is ``true``.
*/
abortPrevious: true,
- /**
- * Property: response
- * {<OpenLayers.Protocol.Response>} The response returned by
- * the read call on the protocol.
+ /** private: property[response]
+ * ``OpenLayers.Protocol.Response``
+ * The response returned by the read call on the protocol.
*/
response: null,
- /**
- * Method: load
+ /** private: method[load]
+ * :param params: ``Object`` An object containing properties which are to
+ * be used as HTTP parameters for the request to the remote server.
+ * :param reader: ``Ext.data.DataReader`` The Reader object which converts
+ * the data object into a block of ``Ext.data.Records``.
+ * :param callback: ``Function`` The function into which to pass the block
+ * of ``Ext.data.Records``. The function is passed the Record block
+ * object, the ``args`` argument passed to the load function, and a
+ * boolean success indicator.
+ * :param scope: ``Object`` The scope in which to call the callback.
+ * :param arg: ``Object`` An optional argument which is passed to the
+ * callback as its second parameter.
*
- * Parameters:
- * params - {Object} An object containing properties which are to be used
- * as HTTP parameters for the request to the remote server.
- * reader - {Ext.data.DataReader} The Reader object which converts the data
- * object into a block of Ext.data.Records.
- * callback - {Function} The function into which to pass the block of
- * Ext.data.Records. The function is passed the Record block object,
- * the "args" argument passed to the load function, and a boolean
- * success indicator
- * scope - {Object} The scope in which to call the callback
- * arg - {Object} An optional argument which is passed to the callback
- * as its second parameter.
+ * Calls ``read`` on the protocol.
*/
load: function(params, reader, callback, scope, arg) {
if (this.fireEvent("beforeload", this, params) !== false) {
@@ -98,9 +96,8 @@
}
},
- /**
- * Method: abortRequest
- * Called to abort any ongoing request.
+ /** private: method[abortRequest]
+ * Called to abort any ongoing request.
*/
abortRequest: function() {
// FIXME really we should rely on the protocol itself to
@@ -116,13 +113,11 @@
}
},
- /**
- * Method: loadResponse
- * Handle response from the protocol
- *
- * Parameters:
- * o - {Object}
- * response - {<OpenLayers.Protocol.Response>}
+ /** private: method[loadResponse]
+ * :param o: ``Object``
+ * :param response: ``OpenLayers.Protocol.Response``
+ *
+ * Handle response from the protocol
*/
loadResponse: function(o, response) {
if (response.success()) {
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/data/ScaleStore.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/data/ScaleStore.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/data/ScaleStore.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -5,29 +5,37 @@
*
* ¹ pending approval */
+/** api: (define)
+ * module = GeoExt.data
+ * class = ScaleStore
+ * base_link = `Ext.data.DataStore <http://extjs.com/deploy/dev/docs/?class=Ext.data.DataStore>`_
+ */
Ext.namespace("GeoExt.data");
-/**
- * Class: GeoExt.data.ScaleStore
- * This store maintains a list of available zoom levels, optionally keeping it synchronized with
- * a Map or MapPanel instance. The entries in the list have the following fields:
- * zoom - the number of the zoom level
- * scale - the scale denominator for the zoom level
- * resolution - the map resolution when the zoom level is active.
+/** api: constructor
+ * .. class:: ScaleStore
+ *
+ * A store that contains a cache of available zoom levels. The store can
+ * optionally be kept synchronized with an ``OpenLayers.Map`` or
+ * :class:`GeoExt.MapPanel` object.
+ *
+ * Records have the following fields:
+ *
+ * * zoom - ``Number`` The zoom level.
+ * * scale - ``Number`` The scale denominator.
+ * * resolution - ``Number`` The map units per pixel.
*/
GeoExt.data.ScaleStore = Ext.extend(Ext.data.Store, {
- /**
- * Property: map
- * The OpenLayers.Map instance to which the store is bound, if any.
+
+ /** api: config[map]
+ * ``OpenLayers.Map`` or :class:`GeoExt.MapPanel`
+ * Optional map or map panel from which to derive scale values.
*/
map: null,
- /**
- * Constructor: GeoExt.data.ScaleStore
- * Construct a ScaleStore from a configuration. The ScaleStore accepts some custom parameters
- * addition to the fields accepted by Ext.Store.
- * Additional options:
- * map - the GeoExt.MapPanel or OpenLayers.Map instance the store should stay sync'ed with
+ /** private: method[constructor]
+ * Construct a ScaleStore from a configuration. The ScaleStore accepts
+ * some custom parameters addition to the fields accepted by Ext.Store.
*/
constructor: function(config) {
var map = (config.map instanceof GeoExt.MapPanel ? config.map.map : config.map);
@@ -43,15 +51,14 @@
if (map) this.bind(map);
},
- /**
- * APIMethod: bind
- * Bind this store to a map; that is, maintain the zoom list in sync with the map's current
- * configuration. If the map does not currently have a set scale list, then the store will
- * remain empty until the map is configured with one.
- *
- * Parameters:
- * map - the GeoExt.MapPanel or OpenLayers.Map to which we should bind
- * options - additional parameters for the bind operation (optional, currently unused)
+ /** api: method[bind]
+ * :param map: :class`GeoExt.MapPanel` or ``OpenLayers.Map`` Panel or map
+ * to which we should bind.
+ *
+ * Bind this store to a map; that is, maintain the zoom list in sync with
+ * the map's current configuration. If the map does not currently have a
+ * set scale list, then the store will remain empty until the map is
+ * configured with one.
*/
bind: function(map, options) {
this.map = (map instanceof GeoExt.MapPanel ? map.map : map);
@@ -63,10 +70,10 @@
}
},
- /**
- * APIMethod: unbind
- * Un-bind this store from the map to which it is currently bound. The currently stored zoom
- * levels will remain, but no further changes from the map will affect it.
+ /** api: method[unbind]
+ * Un-bind this store from the map to which it is currently bound. The
+ * currently stored zoom levels will remain, but no further changes from
+ * the map will affect it.
*/
unbind: function() {
if (this.map) {
@@ -76,13 +83,12 @@
}
},
- /**
- * Method: populateOnAdd
- * This method handles the case where we have bind() called on a not-fully-configured map so
- * that the zoom levels can be detected when a baselayer is finally added.
- *
- * Parameters:
- * evt - the OpenLayers event
+ /** private: method[populateOnAdd]
+ * :param evt: ``Object``
+ *
+ * This method handles the case where we have bind() called on a
+ * not-fully-configured map so that the zoom levels can be detected when a
+ * baselayer is finally added.
*/
populateOnAdd: function(evt) {
if (evt.layer.isBaseLayer) {
@@ -91,10 +97,9 @@
}
},
- /**
- * Method: populateFromMap
- * This method actually loads the zoom level information from the OpenLayers.Map and converts
- * it to Ext Records.
+ /** private: method[populateFromMap]
+ * This method actually loads the zoom level information from the
+ * OpenLayers.Map and converts it to Ext Records.
*/
populateFromMap: function() {
var zooms = [];
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesReader.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesReader.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesReader.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -2,32 +2,25 @@
* Copyright (c) 2008 The Open Planning Project
*/
+/** api: (define)
+ * module = GeoExt.data
+ * class = WMSCapabilitiesReader
+ * base_link = `Ext.data.DataReader <http://extjs.com/deploy/dev/docs/?class=Ext.data.DataReader>`_
+ */
Ext.namespace("GeoExt.data");
-/**
- * Class: GeoExt.data.WMSCapabilitiesReader
- * Data reader class to provide an array of {Ext.data.Record} objects given
- * a WMS GetCapabilities response for use by an {Ext.data.Store}
- * object.
- *
- * Extends:
- * - Ext.data.DataReader
+/** api: constructor
+ * .. class:: WMSCapabilitiesReader(meta, recordType)
+ *
+ * :param meta: ``Object`` Reader configuration.
+ * :param recordType: ``Array | Ext.data.Record`` An array of field
+ * configuration objects or a record object. Default is
+ * :class:`GeoExt.data.LayerRecord`.
+ *
+ * Data reader class to create an array of
+ * :class:`GeoExt.data.LayerRecord` objects from a WMS GetCapabilities
+ * response.
*/
-
-/**
- * Constructor: GeoExt.data.WMSCapabilitiesReader
- * Create a new attributes reader object.
- *
- * Parameters:
- * meta - {Object} Reader configuration.
- * recordType - {Array | Ext.data.Record} An array of field configuration
- * objects or a record object. Default is <GeoExt.data.LayerRecord>.
- *
- * Configuration options (meta properties):
- * format - {OpenLayers.Format} A parser for transforming the XHR response
- * into an array of objects representing attributes. Defaults to
- * an {OpenLayers.Format.WMSCapabilities} parser.
- */
GeoExt.data.WMSCapabilitiesReader = function(meta, recordType) {
meta = meta || {};
if(!meta.format) {
@@ -55,18 +48,11 @@
Ext.extend(GeoExt.data.WMSCapabilitiesReader, Ext.data.DataReader, {
- /**
- * Method: read
- * This method is only used by a DataProxy which has retrieved data from a
- * remote server.
- *
- * Parameters:
- * request - {Object} The XHR object which contains the parsed XML
- * document.
- *
- * Returns:
- * {Object} A data block which is used by an {Ext.data.Store} as a cache
- * of Ext.data.Records.
+ /** private: method[read]
+ * :param request: ``Object`` The XHR object which contains the parsed XML
+ * document.
+ * :return: ``Object`` A data block which is used by an ``Ext.data.Store``
+ * as a cache of ``Ext.data.Record`` objects.
*/
read: function(request) {
var data = request.responseXML;
@@ -76,19 +62,16 @@
return this.readRecords(data);
},
- /**
- * Method: readRecords
- * Create a data block containing Ext.data.Records from an XML document.
- *
- * Parameters:
- * data - {DOMElement | Strint | Object} A document element or XHR response
- * string. As an alternative to fetching capabilities data from a remote
- * source, an object representing the capabilities can be provided given
- * that the structure mirrors that returned from the capabilities parser.
- *
- * Returns:
- * {Object} A data block which is used by an {Ext.data.Store} as a cache of
- * Ext.data.Records.
+ /** private: method[readRecords]
+ * :param data: ``DOMElement | Strint | Object`` A document element or XHR
+ * response string. As an alternative to fetching capabilities data
+ * from a remote source, an object representing the capabilities can
+ * be provided given that the structure mirrors that returned from the
+ * capabilities parser.
+ * :return: ``Object`` A data block which is used by an ``Ext.data.Store``
+ * as a cache of ``Ext.data.Record`` objects.
+ *
+ * Create a data block containing Ext.data.Records from an XML document.
*/
readRecords: function(data) {
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesStore.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesStore.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesStore.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -6,36 +6,39 @@
* @include GeoExt/data/WMSCapabilitiesReader.js
*/
+/** api: (define)
+ * module = GeoExt.data
+ * class = WMSCapabilitiesStore
+ * base_link = `Ext.data.DataStore <http://extjs.com/deploy/dev/docs/?class=Ext.data.DataStore>`_
+ */
Ext.namespace("GeoExt.data");
-/**
- * Class: GeoExt.data.WMSCapabilitiesStore
- * Small helper class to make creating stores for remote WMS layer data easier.
- * WMSCapabilitiesStore is pre-configured with a built-in
- * {Ext.data.HttpProxy} and {GeoExt.data.WMSCapabilitiesReader}. The
- * HttpProxy is configured to allow caching (disableCaching: false) and uses
- * GET. If you require some other proxy/reader combination then you'll have
- * to configure this with your own proxy or create a basic
- * GeoExt.data.LayerStore and configure as needed.
- *
- * Extends:
- * - GeoExt.data.Store
+
+/** api: constructor
+ * .. class:: WMSCapabilitiesStore
+ *
+ * Small helper class to make creating stores for remote WMS layer data
+ * easier. The store is pre-configured with a built-in
+ * ``Ext.data.HttpProxy`` and :class:`GeoExt.data.WMSCapabilitiesReader`.
+ * The proxy is configured to allow caching and issues requests via GET.
+ * If you require some other proxy/reader combination then you'll have to
+ * configure this with your own proxy or create a basic
+ * :class:`GeoExt.data.LayerStore` and configure as needed.
*/
-/**
- * Constructor: GeoExt.data.WMSCapabilitiesStore
- * Create a new WMS capabilities store object.
- *
- * Parameters:
- * config - {Object} Store configuration.
- *
- * Configuration options:
- * format - {OpenLayers.Format} A parser for transforming the XHR response into
- * an array of objects representing attributes. Defaults to an
- * {OpenLayers.Format.WMSCapabilities} parser.
- * fields - {Array | Function} Either an Array of field definition objects as
- * passed to Ext.data.Record.create, or a Record constructor created using
- * Ext.data.Record.create. Defaults to ["name", "type"].
+/** api: config[format]
+ * ``OpenLayers.Format``
+ * A parser for transforming the XHR response into an array of objects
+ * representing attributes. Defaults to an ``OpenLayers.Format.WMSCapabilities``
+ * parser.
*/
+
+/** api: config[fields]
+ * ``Array | Function``
+ * Either an Array of field definition objects as passed to
+ * ``Ext.data.Record.create``, or a record constructor created using
+ * ``Ext.data.Record.create``. Defaults to ``["name", "type"]``.
+ */
+
GeoExt.data.WMSCapabilitiesStore = function(c) {
GeoExt.data.WMSCapabilitiesStore.superclass.constructor.call(
this,
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/Action.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/Action.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/Action.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -18,11 +18,11 @@
* .. code-block:: javascript
*
* var ctrl = new OpenLayers.Control.ZoomToMaxExtent();
- * map.addControl(ctrl);
- * var action = GeoExt.Action.fromControl(ctrl, {
+ * var action = new GeoExt.Action(ctrl, {
* text: "max extent"
+ * control: ctrl,
+ * map: map
* });
- *
* var toolbar = new Ext.Toolbar([action]);
*/
@@ -88,6 +88,10 @@
// register "activate" and "deactivate" listeners
// on the control
if(ctrl) {
+ // If map is provided in config, add control to map.
+ if(config.map) {
+ config.map.addControl(ctrl);
+ }
ctrl.events.on({
activate: this.onCtrlActivate,
deactivate: this.onCtrlDeactivate,
@@ -205,12 +209,3 @@
}
}
});
-
-GeoExt.Action.fromControl = function(control, cfg) {
- cfg = cfg || {};
- if(cfg instanceof Ext.Action) {
- cfg = cfg.initialConfig;
- }
- cfg.control = control;
- return new GeoExt.Action(cfg);
-};
Copied: sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendImage.js (from rev 942, core/trunk/geoext/lib/GeoExt/widgets/LegendImage.js)
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendImage.js (rev 0)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendImage.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -0,0 +1,80 @@
+/* Copyright (C) 2008-2009 The Open Source Geospatial Foundation
+ * Published under the BSD license.
+ * See http://geoext.org/svn/geoext/core/trunk/license.txt for the full text
+ * of the license.
+ *
+ * pending approval */
+
+/** api: (define)
+ * module = GeoExt
+ * class = LegendImage
+ */
+
+Ext.namespace('GeoExt');
+
+/** api: constructor
+ * .. class:: LegendImage(config)
+ *
+ * Show a legend image in a BoxComponent and make sure load errors are dealt
+ * with.
+ */
+GeoExt.LegendImage = Ext.extend(Ext.BoxComponent, {
+
+ /** api: config[url]
+ * ``String`` The url of the image to load
+ */
+ url: null,
+
+ /** api: config[imgCls]
+ * ``String`` Optional css class to apply to img tag
+ */
+ imgCls: null,
+
+ /** private: method[initComponent]
+ * Initializes the legend image component.
+ */
+ initComponent: function() {
+ GeoExt.LegendImage.superclass.initComponent.call(this);
+ this.autoEl = {tag: 'img',
+ 'class': (this.imgCls ? this.imgCls : ''), src: this.url};
+ },
+
+ /** api: method[setUrl]
+ * :param url: ``String`` The new url of the image.
+ *
+ * Sets the url of the image.
+ */
+ setUrl: function(url) {
+ var el = this.getEl();
+ if (el) {
+ el.dom.src = url;
+ }
+ },
+
+ /** private: method[onRender]
+ * Private method called when the legend image component is being
+ * rendered.
+ */
+ onRender: function(ct, position) {
+ GeoExt.LegendImage.superclass.onRender.call(this, ct, position);
+ this.getEl().on('error', this.onImageLoadError, this);
+ },
+
+ /** private: method[onDestroy]
+ * Private method called during the destroy sequence.
+ */
+ onDestroy: function() {
+ this.getEl().un('error', this.onImageLoadError, this);
+ GeoExt.LegendImage.superclass.onDestroy.apply(this, arguments);
+ },
+
+ /** private: method[onImageLoadError]
+ * Private method called if the legend image fails loading.
+ */
+ onImageLoadError: function() {
+ this.getEl().dom.src = Ext.BLANK_IMAGE_URL;
+ }
+
+});
+
+Ext.reg('gx_legendimage', GeoExt.LegendImage);
Copied: sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendPanel.js (from rev 942, core/trunk/geoext/lib/GeoExt/widgets/LegendPanel.js)
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendPanel.js (rev 0)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendPanel.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -0,0 +1,281 @@
+/* Copyright (C) 2008-2009 The Open Source Geospatial Foundation
+ * Published under the BSD license.
+ * See http://geoext.org/svn/geoext/core/trunk/license.txt for the full text
+ * of the license.
+ *
+ * pending approval */
+
+/** api: (define)
+ * module = GeoExt
+ * class = LegendPanel
+ */
+
+Ext.namespace('GeoExt');
+
+/** api: constructor
+ * .. class:: LegendPanel(config)
+ *
+ * A panel showing legends of all layers in a layer store.
+ * Depending on the layer type, a legend renderer will be chosen.
+ */
+GeoExt.LegendPanel = Ext.extend(Ext.Panel, {
+
+ /** api: config[dynamic]
+ * ``Boolean``
+ * If false the LegendPanel will not listen to the add, remove and change
+ * events of the LayerStore. So it will load with the initial state of
+ * the LayerStore and not change anymore.
+ */
+ dynamic: true,
+
+ /** api: config[showTitle]
+ * ``Boolean``
+ * Whether or not to show the title of a layer. This can be a global
+ * setting for the whole panel, or it can be overridden on the LayerStore
+ * record using the hideInLegend property.
+ */
+ showTitle: true,
+
+ /** api: config[labelCls]
+ * ``String``
+ * Optional css class to use for the layer title labels.
+ */
+ labelCls: null,
+
+ /** api: config[bodyStyle]
+ * ``String``
+ * Optional style to apply to the body of the legend panels.
+ */
+ bodyStyle: '',
+
+ /** api: config[layerStore]
+ * ``GeoExt.data.LayerStore``
+ * The layer store containing layers to be displayed in the legend
+ * container. If not provided it will be taken from the MapPanel.
+ */
+ layerStore: null,
+
+ /** private: method[initComponent]
+ * Initializes the legend panel.
+ */
+ initComponent: function() {
+ GeoExt.LegendPanel.superclass.initComponent.call(this);
+ },
+
+ /** private: method[onRender]
+ * Private method called when the legend panel is being rendered.
+ */
+ onRender: function() {
+ GeoExt.LegendPanel.superclass.onRender.apply(this, arguments);
+ if(!this.layerStore) {
+ this.layerStore = GeoExt.MapPanel.guess().layers;
+ }
+ this.layerStore.each(function(record) {
+ this.addLegend(record);
+ }, this);
+ if (this.dynamic) {
+ this.layerStore.on({
+ "add": this.onStoreAdd,
+ "remove": this.onStoreRemove,
+ "update": this.onStoreUpdate,
+ scope: this
+ });
+ }
+ this.doLayout();
+ },
+
+ /** private: method[recordIndexToPanelIndex]
+ * Private method to get the panel index for a layer represented by a
+ * record.
+ *
+ * :param index ``Integer`` The index of the record in the store.
+ *
+ * :return: ``Integer`` The index of the sub panel in this panel.
+ */
+ recordIndexToPanelIndex: function(index) {
+ var store = this.layerStore;
+ var count = store.getCount();
+ var panelIndex = -1;
+ for(var i=count-1; i>=0; --i) {
+ var layer = store.getAt(i).get("layer");
+ var legendGenerator = GeoExt[
+ "Legend" + layer.CLASS_NAME.split(".").pop()
+ ];
+ if(layer.displayInLayerSwitcher && legendGenerator &&
+ (store.getAt(i).get("hideInLegend") !== true)) {
+ ++panelIndex;
+ if(index === i) {
+ break;
+ }
+ }
+ }
+ return panelIndex;
+ },
+
+ /** private: method[onStoreUpdate]
+ * Update a layer within the legend panel. Gets called when the store
+ * fires the update event. This usually means the visibility of the layer
+ * has changed.
+ *
+ * :param store: ``Ext.data.Store`` The store in which the record was
+ * changed.
+ * :param record: ``Ext.data.Record`` The record object corresponding
+ * to the updated layer.
+ * :param operation: ``String`` The type of operation.
+ */
+ onStoreUpdate: function(store, record, operation) {
+ var layer = record.get('layer');
+ var legend = this.getComponent(layer.id);
+ if (legend) {
+ legend.setVisible(layer.getVisibility() &&
+ layer.displayInLayerSwitcher && !record.get('hideInLegend'));
+ if (record.get('legendURL')) {
+ var items = legend.findByType('gx_legendimage');
+ for (var i=0, len=items.length; i<len; i++) {
+ items[i].setUrl(record.get('legendURL'));
+ }
+ }
+ }
+ },
+
+ /** private: method[onStoreAdd]
+ * Private method called when a layer is added to the store.
+ *
+ * :param store: ``Ext.data.Store`` The store to which the record(s) was
+ * added.
+ * :param record: ``Ext.data.Record`` The record object(s) corresponding
+ * to the added layers.
+ * :param index: ``Integer`` The index of the inserted record.
+ */
+ onStoreAdd: function(store, records, index) {
+ var panelIndex = this.recordIndexToPanelIndex(index);
+ for (var i=0, len=records.length; i<len; i++) {
+ this.addLegend(records[i], panelIndex);
+ }
+ this.doLayout();
+ },
+
+ /** private: method[onStoreRemove]
+ * Private method called when a layer is removed from the store.
+ *
+ * :param store: ``Ext.data.Store`` The store from which the record(s) was
+ * removed.
+ * :param record: ``Ext.data.Record`` The record object(s) corresponding
+ * to the removed layers.
+ * :param index: ``Integer`` The index of the removed record.
+ */
+ onStoreRemove: function(store, record, index) {
+ this.removeLegend(record);
+ },
+
+ /** private: method[removeLegend]
+ * Remove the legend of a layer.
+ * :param record: ``Ext.data.Record`` The record object from the layer
+ * store to remove.
+ */
+ removeLegend: function(record) {
+ var legend = this.getComponent(record.get('layer').id);
+ if (legend) {
+ this.remove(legend, true);
+ this.doLayout();
+ }
+ },
+
+ /** private: method[createLegendSubpanel]
+ * Create a legend sub panel for the layer.
+ *
+ * :param record: ``Ext.data.Record`` The record object from the layer
+ * store.
+ *
+ * :return: ``Ext.Panel`` The created panel per layer
+ */
+ createLegendSubpanel: function(record) {
+ var layer = record.get('layer');
+ var mainPanel = this.createMainPanel(record);
+ if (mainPanel !== null) {
+ // the default legend can be overridden by specifying a
+ // legendURL property
+ var legend;
+ if (record.get('legendURL')) {
+ legend = new GeoExt.LegendImage({url: record.get('legendURL')});
+ mainPanel.add(legend);
+ } else {
+ var legendGenerator = GeoExt[
+ "Legend" + layer.CLASS_NAME.split(".").pop()
+ ];
+ if (legendGenerator) {
+ legend = new legendGenerator({layer: layer});
+ mainPanel.add(legend);
+ }
+ }
+ }
+ return mainPanel;
+ },
+
+ /** private: method[addLegend]
+ * Add a legend for the layer.
+ *
+ * :param record: ``Ext.data.Record`` The record object from the layer
+ * store.
+ * :param index: ``Integer`` The position at which to add the legend.
+ */
+ addLegend: function(record, index) {
+ index = index || 0;
+ var layer = record.get('layer');
+ var legendSubpanel = this.createLegendSubpanel(record);
+ if (legendSubpanel !== null) {
+ legendSubpanel.setVisible(layer.getVisibility());
+ this.insert(index, legendSubpanel);
+ }
+ },
+
+ /** private: method[createMainPanel]
+ * Creates the main panel with a title for the layer.
+ *
+ * :param record: ``Ext.data.Record`` The record object from the layer
+ * store.
+ *
+ * :return: ``Ext.Panel`` The created main panel with a label.
+ */
+ createMainPanel: function(record) {
+ var layer = record.get('layer');
+ var panel = null;
+ var legendGenerator = GeoExt[
+ "Legend" + layer.CLASS_NAME.split(".").pop()
+ ];
+ if (layer.displayInLayerSwitcher && !record.get('hideInLegend') &&
+ legendGenerator) {
+ var panelConfig = {
+ id: layer.id,
+ border: false,
+ bodyBorder: false,
+ bodyStyle: this.bodyStyle,
+ items: [
+ new Ext.form.Label({
+ text: (this.showTitle && !record.get('hideTitle')) ?
+ layer.name : '',
+ cls: 'x-form-item x-form-item-label' +
+ (this.labelCls ? ' ' + this.labelCls : '')
+ })
+ ]
+ };
+ panel = new Ext.Panel(panelConfig);
+ }
+ return panel;
+ },
+
+ /** private: method[onDestroy]
+ * Private method called during the destroy sequence.
+ */
+ onDestroy: function() {
+ if(this.layerStore) {
+ this.layerStore.un("add", this.onStoreAdd, this);
+ this.layerStore.un("remove", this.onStoreRemove, this);
+ this.layerStore.un("update", this.onStoreUpdate, this);
+ }
+ GeoExt.LegendPanel.superclass.onDestroy.apply(this, arguments);
+ }
+
+});
+
+Ext.reg('gx_legendpanel', GeoExt.LegendPanel);
\ No newline at end of file
Copied: sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendWMS.js (from rev 942, core/trunk/geoext/lib/GeoExt/widgets/LegendWMS.js)
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendWMS.js (rev 0)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/LegendWMS.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -0,0 +1,87 @@
+/* Copyright (C) 2008-2009 The Open Source Geospatial Foundation
+ * Published under the BSD license.
+ * See http://geoext.org/svn/geoext/core/trunk/license.txt for the full text
+ * of the license.
+ *
+ * pending approval */
+
+/**
+ * @include GeoExt/widgets/LegendImage.js
+ */
+
+/** api: (define)
+ * module = GeoExt
+ * class = LegendWMS
+ */
+Ext.namespace('GeoExt');
+
+/** api: constructor
+ * .. class:: LegendWMS(config)
+ *
+ * Show a legend image for a WMS layer.
+ */
+GeoExt.LegendWMS = Ext.extend(Ext.Panel, {
+
+ /** api: config[imageFormat]
+ * ``String``
+ * The image format to request the legend image in.
+ * Defaults to image/png.
+ */
+ imageFormat: "image/gif",
+
+ /** api: config[layer]
+ * ``OpenLayers.Layer.WMS``
+ * The WMS layer to request the legend for.
+ */
+ layer: null,
+
+ /** api: config[bodyBorder]
+ * ``Boolean``
+ * Show a border around the legend image or not. Default is false.
+ */
+ bodyBorder: false,
+
+ /** private: method[initComponent]
+ * Initializes the WMS legend. For group layers it will create multiple
+ * image box components.
+ */
+ initComponent: function() {
+ GeoExt.LegendWMS.superclass.initComponent.call(this);
+ this.createLegend();
+ },
+
+ /** private: method[getLegendUrl]
+ * :param layer: ``OpenLayers.Layer.WMS`` The OpenLayers WMS layer object
+ * :param layerName: ``String`` The name of the layer
+ * (used in the LAYERS parameter)
+ * :return: ``String`` The url of the SLD WMS GetLegendGraphic request.
+ *
+ * Get the url for the SLD WMS GetLegendGraphic request.
+ */
+ getLegendUrl: function(layerName) {
+ return this.layer.getFullRequestString({
+ REQUEST: "GetLegendGraphic",
+ WIDTH: null,
+ HEIGHT: null,
+ EXCEPTIONS: "application/vnd.ogc.se_xml",
+ LAYER: layerName,
+ LAYERS: null,
+ SRS: null,
+ FORMAT: this.imageFormat
+ });
+ },
+
+ /** private: method[createLegend]
+ * Add one BoxComponent per sublayer to this panel.
+ */
+ createLegend: function() {
+ var layers = this.layer.params.LAYERS.split(",");
+ for (var i = 0, len = layers.length; i < len; i++){
+ var layerName = layers[i];
+ var legend = new GeoExt.LegendImage({url:
+ this.getLegendUrl(layerName)});
+ this.add(legend);
+ }
+ }
+
+});
\ No newline at end of file
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/MapPanel.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/MapPanel.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/MapPanel.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -125,29 +125,38 @@
},
/** private: method[updateMapSize]
- * Tell the map that it needs to recaculate its size and position.
+ * Tell the map that it needs to recalculate its size and position.
*/
updateMapSize: function() {
if(this.map) {
this.map.updateSize();
}
},
-
- /** private: method[onRender]
- * Private method called after the panel has been
- * rendered.
+
+ /** private: method[renderMap]
+ * Private method called after the panel has been rendered or after it
+ * has been laid out by its parent's layout.
*/
- onRender: function() {
- GeoExt.MapPanel.superclass.onRender.apply(this, arguments);
- this.map.render(this.body.dom);
- if(this.map.layers.length > 0) {
- if(this.center) {
- // zoom does not have to be defined
- this.map.setCenter(this.center, this.zoom);
- } else if(this.extent) {
- this.map.zoomToExtent(this.extent);
+ renderMap: function() {
+ var map = this.map;
+
+ // hack: prevent map.updateSize (called from within map.render) from
+ // zooming to the map extent. This hack is a workaround for
+ // <http://trac.openlayers.org/ticket/2105> and must be
+ // removed once this ticket is closed.
+ var setCenter = map.setCenter;
+ map.setCenter = function() {};
+ map.render(this.body.dom);
+ map.setCenter = setCenter;
+
+ if(map.layers.length > 0) {
+ if(this.center || this.zoom != null) {
+ // both do not have to be defined
+ map.setCenter(this.center, this.zoom);
+ } else if(this.extent) {
+ map.zoomToExtent(this.extent);
} else {
- this.map.zoomToMaxExtent();
+ map.zoomToMaxExtent();
}
}
},
@@ -157,10 +166,19 @@
*/
afterRender: function() {
GeoExt.MapPanel.superclass.afterRender.apply(this, arguments);
- if(this.ownerCt) {
+ if(!this.ownerCt) {
+ this.renderMap();
+ } else {
this.ownerCt.on("move", this.updateMapSize, this);
+ this.ownerCt.on({
+ "afterlayout": {
+ fn: this.renderMap,
+ scope: this,
+ single: true
+ }
+ });
}
- },
+ },
/** private: method[onResize]
* Private method called after the panel has been resized.
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/BaseLayerContainer.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/BaseLayerContainer.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/BaseLayerContainer.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -1,43 +1,49 @@
-/**
- * Copyright (c) 2008 The Open Planning Project
- */
+/* Copyright (C) 2008-2009 The Open Source Geospatial Foundation ¹
+ * Published under the BSD license.
+ * See http://geoext.org/svn/geoext/core/trunk/license.txt for the full text
+ * of the license.
+ *
+ * ¹ pending approval */
/**
* @requires GeoExt/widgets/tree/LayerContainer.js
*/
Ext.namespace("GeoExt.tree");
-/**
- * Class: GeoExt.tree.BaseLayerContainer
+/** api: (define)
+ * module = GeoExt.tree
+ * class = BaseLayerContainer
+ */
+
+/** api: (extends)
+ * GeoExt/widgets/tree/LayerContainer.js
+ */
+
+/** api: constructor
+ * .. class:: 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.
+ * 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>
+ * To use this node type in ``TreePanel`` config, set nodeType to
+ * "gx_baselayercontainer".
*/
GeoExt.tree.BaseLayerContainer = Ext.extend(GeoExt.tree.LayerContainer, {
- /**
- * Constructor: GeoExt.tree.BaseLayerContainer
- *
- * Parameters:
- * config - {Object}
+ /** private: method[constructor]
+ * Private constructor override.
*/
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
+ /** private: method[addLayerNode]
+ * :param layerRecord: ``Ext.data.Record`` the layer record to add a node
+ * for
*
- * Parameters:
- * layerRecord - {Ext.data.Record} the layer record to add a node for
+ * Adds a child node representing a base layer of the map.
*/
addLayerNode: function(layerRecord) {
var layer = layerRecord.get("layer");
@@ -47,12 +53,11 @@
}
},
- /**
- * 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
+ /** private: method[removeLayerNode]
+ * :param layerRecord: ``Ext.data.Record`` the layer record to remove the
+ * node for
+ *
+ * Removes a child node representing a base layer of the map.
*/
removeLayerNode: function(layerRecord) {
var layer = layerRecord.get("layer");
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/LayerContainer.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/LayerContainer.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/LayerContainer.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -1,46 +1,48 @@
-/**
- * Copyright (c) 2008 The Open Planning Project
- */
+/* Copyright (C) 2008-2009 The Open Source Geospatial Foundation ¹
+ * Published under the BSD license.
+ * See http://geoext.org/svn/geoext/core/trunk/license.txt for the full text
+ * of the license.
+ *
+ * ¹ pending approval */
/**
* @include GeoExt/widgets/tree/LayerNode.js
*/
Ext.namespace("GeoExt.tree");
-/**
- * Class: GeoExt.tree.LayerContainer
+/** api: (define)
+ * module = GeoExt.tree
+ * class = LayerContainer
+ * base_link = `Ext.tree.TreeNode <http://extjs.com/deploy/dev/docs/?class=Ext.tree.TreeNode>`_
+ */
+
+/** api: constructor
+ * .. class:: LayerContainer
*
- * A subclass of {Ext.tree.TreeNode} that will collect all layers of an
- * OpenLayers map. Only layers that have displayInLayerSwitcher set to true
- * will be included. The childrens' iconCls will be set to "baselayer-icon"
- * for base layers, and to "layer-icon" for overlay layers.
+ * A subclass of ``Ext.tree.TreeNode`` that will collect all layers of an
+ * OpenLayers map. Only layers that have displayInLayerSwitcher set to true
+ * will be included. The childrens' iconCls will be set to "baselayer-icon"
+ * for base layers, and to "layer-icon" for overlay layers.
*
- * To use this node type in JSON config, set nodeType to "olLayerContainer".
- *
- * Inherits from:
- * - <Ext.tree.TreeNode>
+ * To use this node type in ``TreePanel`` config, set nodeType to
+ * "gx_layercontainer".
*/
GeoExt.tree.LayerContainer = Ext.extend(Ext.tree.TreeNode, {
- /**
- * APIProperty: layerStore
- * {<GeoExt.data.LayerStore>} The layer store containing layers to be
- * displayed in the container.
+ /** api: config[layerStore]
+ * :class:`GeoExt.data.LayerStore`
+ * The layer store containing layers to be displayed in the container.
*/
layerStore: null,
- /**
- * APIProperty: defaults
- * {Object} a configuration object passed to all nodes that this
- * LayerContainer creates.
+ /** api: config[defaults]
+ * ``Object``
+ * A configuration object passed to all nodes that this container creates.
*/
defaults: null,
- /**
- * Constructor: GeoExt.tree.LayerContainer
- *
- * Parameters:
- * config - {Object}
+ /** private: method[constructor]
+ * Private constructor override.
*/
constructor: function(config) {
this.layerStore = config.layerStore;
@@ -48,11 +50,8 @@
GeoExt.tree.LayerContainer.superclass.constructor.apply(this, arguments);
},
- /**
- * Method: render
- *
- * Parameters:
- * bulkRender - {Boolean}
+ /** private: method[render]
+ * :param bulkRender: ``Boolean``
*/
render: function(bulkRender) {
if (!this.rendered) {
@@ -71,14 +70,12 @@
GeoExt.tree.LayerContainer.superclass.render.call(this, bulkRender);
},
- /**
- * Method: onStoreAdd
- * Listener for the store's add event.
- *
- * Parameters:
- * store - {Ext.data.Store}
- * records - {Array(Ext.data.Record)}
- * index - {Number}
+ /** private: method[onStoreAdd]
+ * :param store: ``Ext.data.Store``
+ * :param records: ``Array(Ext.data.Record)``
+ * :param index: ``Number``
+ *
+ * Listener for the store's add event.
*/
onStoreAdd: function(store, records, index) {
if(!this._reordering) {
@@ -89,14 +86,12 @@
}
},
- /**
- * Method: onStoreRemove
- * Listener for the store's remove event.
- *
- * Parameters:
- * store - {Ext.data.Store}
- * record - {Ext.data.Record}
- * index - {Number}
+ /** private: method[onStoreRemove]
+ * :param store: ``Ext.data.Store``
+ * :param record: ``Ext.data.Record``
+ * :param index: ``Number``
+ *
+ * Listener for the store's remove event.
*/
onStoreRemove: function(store, record, index) {
if(!this._reordering) {
@@ -104,8 +99,7 @@
}
},
- /**
- * Method: onDestroy
+ /** private: method[onDestroy]
*/
onDestroy: function() {
if(this.layerStore) {
@@ -115,15 +109,9 @@
GeoExt.tree.LayerContainer.superclass.onDestroy.apply(this, arguments);
},
- /**
- * Method: recordIndexToNodeIndex
- * Convert a record index into a child node index.
- *
- * Parameters:
- * index - {Number} The record index in the layer store.
- *
- * Returns:
- * {Number} The appropriate child node index for the record.
+ /** private: method[recordIndexToNodeIndex]
+ * :param index: ``Number`` The record index in the layer store.
+ * :return: ``Number`` The appropriate child node index for the record.
*/
recordIndexToNodeIndex: function(index) {
var store = this.layerStore;
@@ -140,15 +128,11 @@
return nodeIndex;
},
- /**
- * Method: nodeIndexToRecordIndex
- * Convert a child node index to a record index.
- *
- * Parameters:
- * index - {Number} The child node index.
- *
- * Returns:
- * {Number} The appropriate record index for the node.
+ /** private: method[nodeIndexToRecordIndex]
+ * :param index: ``Number`` The child node index.
+ * :return: ``Number`` The appropriate record index for the node.
+ *
+ * Convert a child node index to a record index.
*/
nodeIndexToRecordIndex: function(index) {
var store = this.layerStore;
@@ -165,13 +149,12 @@
return i;
},
- /**
- * Method: addLayerNode
- * Adds a child node representing a layer of the map
- *
- * Parameters:
- * layerRecord - {Ext.data.Record} the layer record to add the layer for
- * index - {Number} Optional index for the new layer. Default is 0.
+ /** private: method[addLayerNode]
+ * :param layerRecord: ``Ext.data.Record`` The layer record containing the
+ * layer to be added.
+ * :param index: ``Number`` Optional index for the new layer. Default is 0.
+ *
+ * Adds a child node representing a layer of the map
*/
addLayerNode: function(layerRecord, index) {
index = index || 0;
@@ -192,12 +175,11 @@
}
},
- /**
- * Method: removeLayerNode
- * Removes a child node representing a layer of the map
+ /** private: method[removeLayerNode]
+ * :param layerRecord: ``Ext.data.Record`` The layer record containing the
+ * layer to be removed.
*
- * Parameters:
- * layerRecord - {Ext.data.Record} the layer record to remove the node for
+ * Removes a child node representing a layer of the map
*/
removeLayerNode: function(layerRecord) {
var layer = layerRecord.get("layer");
@@ -212,18 +194,16 @@
}
},
- /**
- * Method: onChildMove
- * Listener for child node "move" events. This updates the order of
- * records in the store based on new node order if the node has not
- * changed parents.
- *
- * Parameters:
- * tree - {Ext.data.Tree}
- * node - {Ext.tree.TreeNode}
- * oldParent - {Ext.tree.TreeNode}
- * newParent - {Ext.tree.TreeNode}
- * index {Number}
+ /** private: method[onChildMove]
+ * :param tree: ``Ext.data.Tree``
+ * :param node: ``Ext.tree.TreeNode``
+ * :param oldParent: ``Ext.tree.TreeNode``
+ * :param newParent: ``Ext.tree.TreeNode``
+ * :param index: ``Number``
+ *
+ * Listener for child node "move" events. This updates the order of
+ * records in the store based on new node order if the node has not
+ * changed parents.
*/
onChildMove: function(tree, node, oldParent, newParent, index) {
if(oldParent === newParent) {
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/LayerNode.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/LayerNode.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/LayerNode.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -1,37 +1,32 @@
-/**
- * Copyright (c) 2008 The Open Planning Project
- */
+/* Copyright (C) 2008-2009 The Open Source Geospatial Foundation ¹
+ * Published under the BSD license.
+ * See http://geoext.org/svn/geoext/core/trunk/license.txt for the full text
+ * of the license.
+ *
+ * ¹ pending approval */
+
Ext.namespace("GeoExt.tree");
-/**
- * Class: GeoExt.tree.LayerNodeUI
- *
- * Inherits from:
- * - Ext.tree.TreeNodeUI
+/** private: constructor
+ * .. class:: LayerNodeUI
+ *
+ * Place in a separate file if this should be documented.
*/
GeoExt.tree.LayerNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
- /**
- * Property: radio
- * {Ext.Element}
+ /** private: property[radio]
+ * ``Ext.Element``
*/
radio: null,
- /**
- * Constructor: GeoExt.tree.LayerNodeUI
- *
- * Parameters:
- * config - {Object}
+ /** private: method[constructor]
*/
constructor: function(config) {
GeoExt.tree.LayerNodeUI.superclass.constructor.apply(this, arguments);
},
- /**
- * Method: render
- *
- * Parameters:
- * bulkRender - {Boolean}
+ /** private: method[render]
+ * :param bulkRender: ``Boolean``
*/
render: function(bulkRender) {
GeoExt.tree.LayerNodeUI.superclass.render.call(this, bulkRender);
@@ -43,11 +38,8 @@
}
},
- /**
- * Method: onClick
- *
- * Parameters:
- * e - {Object}
+ /** private: method[onClick]
+ * :param e: ``Object``
*/
onClick: function(e) {
if (e.getTarget('input[type=radio]', 1)) {
@@ -57,11 +49,8 @@
}
},
- /**
- * Method: toggleCheck
- *
- * Parameters:
- * value - {Boolean}
+ /** private: method[toggleCheck]
+ * :param value: ``Boolean``
*/
toggleCheck: function(value) {
GeoExt.tree.LayerNodeUI.superclass.toggleCheck.call(this, value);
@@ -74,8 +63,7 @@
node.visibilityChanging = false;
},
- /**
- * Method: onDestroy
+ /** private: method[onDestroy]
*/
onDestroy: function() {
delete this.radio;
@@ -109,7 +97,8 @@
* 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 "gx_layer".
+ * To use this node type in a ``TreePanel`` config, set ``nodeType`` to
+ * "gx_layer".
*/
GeoExt.tree.LayerNode = Ext.extend(Ext.tree.TreeNode, {
@@ -152,11 +141,8 @@
*/
visibilityChanging: false,
- /**
- * Constructor: GeoExt.tree.LayerNode
- *
- * Parameters:
- * config - {Object}
+ /** private: method[constructor]
+ * Private constructor override.
*/
constructor: function(config) {
config.leaf = config.leaf || !config.children;
@@ -169,10 +155,9 @@
this.defaultUI = this.defaultUI || GeoExt.tree.LayerNodeUI;
this.addEvents(
- /**
- * Event: radiochange
- * Notifies listener when a differnt radio button was selected.
- * Will be called with the currently selected node as argument.
+ /** api: event[radiochange]
+ * Notifies listener when a differnt radio button was selected.
+ * Will be called with the currently selected node as argument.
*/
"radiochange"
);
@@ -185,12 +170,8 @@
GeoExt.tree.LayerNode.superclass.constructor.apply(this, arguments);
},
- /**
- * Method: render
- *
- * Properties:
- * bulkRender {Boolean} - optional
- * layer {<OpenLayers.Layer>} - optional
+ /** private: method[render]
+ * :param bulkRender: ``Boolean``
*/
render: function(bulkRender) {
var layer = this.layer instanceof OpenLayers.Layer && this.layer;
@@ -238,10 +219,9 @@
GeoExt.tree.LayerNode.superclass.render.call(this, bulkRender);
},
- /**
- * Method: addVisibilityHandlers
- * Adds handlers that sync the checkbox state with the layer's visibility
- * state
+ /** private: method[addVisibilityHandlers]
+ * Adds handlers that sync the checkbox state with the layer's visibility
+ * state
*/
addVisibilityEventHandlers: function() {
this.layer.events.register("visibilitychanged", this, function() {
@@ -261,10 +241,9 @@
});
},
- /**
- * Method: addStoreEventHandlers
- * Adds handlers that make sure the node disappeares when the layer is
- * removed from the store, and appears when it is re-added.
+ /** private: method[addStoreEventHandlers]
+ * Adds handlers that make sure the node disappeares when the layer is
+ * removed from the store, and appears when it is re-added.
*/
addStoreEventHandlers: function() {
this.layerStore.on({
@@ -292,10 +271,9 @@
});
},
- /**
- * Method: addChildNodes
- * Calls the add method of a node type configured as <childNodeType>
- * to add children.
+ /** private: method[addChildNodes]
+ * Calls the add method of a node type configured as ``childNodeType``
+ * to add children.
*/
addChildNodes: function() {
if(typeof this.childNodeType == "string") {
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/OverlayLayerContainer.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/OverlayLayerContainer.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/widgets/tree/OverlayLayerContainer.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -1,31 +1,38 @@
-/**
- * Copyright (c) 2008 The Open Planning Project
- */
+/* Copyright (C) 2008-2009 The Open Source Geospatial Foundation ¹
+ * Published under the BSD license.
+ * See http://geoext.org/svn/geoext/core/trunk/license.txt for the full text
+ * of the license.
+ *
+ * ¹ pending approval */
/**
* @requires GeoExt/widgets/tree/LayerContainer.js
*/
Ext.namespace("GeoExt.tree");
-/**
- * Class: GeoExt.tree.OverlayLayerContainer
+/** api: (define)
+ * module = GeoExt.tree
+ * class = OverlayLayerContainer
+ */
+
+/** api: (extends)
+ * GeoExt/widgets/tree/LayerContainer.js
+ */
+
+/** api: constructor
+ * .. class:: 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.
+ * 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>
+ * To use this node type in ``TreePanel`` config, set nodeType to
+ * "gx_overlaylayerontainer".
*/
GeoExt.tree.OverlayLayerContainer = Ext.extend(GeoExt.tree.LayerContainer, {
- /**
- * Constructor: GeoExt.tree.OverlayLayerContainer
- *
- * Parameters:
- * config - {Object}
+ /** private: method[constructor]
+ * Private constructor override.
*/
constructor: function(config) {
config.text = config.text || "Overlays";
@@ -33,12 +40,11 @@
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
+ /** private: method[addLayerNode]
+ * :param layerRecord: ``Ext.data.Record`` the layer record to add a node
+ * for
+ *
+ * Adds a child node representing a overlay layer of the map.
*/
addLayerNode: function(layerRecord) {
var layer = layerRecord.get("layer");
@@ -48,12 +54,11 @@
}
},
- /**
- * 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
+ /** private: method[removeLayerNode]
+ * :param layerRecord: ``Ext.data.Record`` the layer record to remove the
+ * node for
+ *
+ * Removes a child node representing an overlay layer of the map.
*/
removeLayerNode: function(layerRecord) {
var layer = layerRecord.get("layer");
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt.js 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt.js 2009-06-02 12:41:29 UTC (rev 943)
@@ -79,7 +79,10 @@
"GeoExt/widgets/tree/LayerNode.js",
"GeoExt/widgets/tree/LayerContainer.js",
"GeoExt/widgets/tree/BaseLayerContainer.js",
- "GeoExt/widgets/tree/OverlayLayerContainer.js"
+ "GeoExt/widgets/tree/OverlayLayerContainer.js",
+ "GeoExt/widgets/LegendImage.js",
+ "GeoExt/widgets/LegendWMS.js",
+ "GeoExt/widgets/LegendPanel.js"
);
var agent = navigator.userAgent;
Modified: sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/Action.html
===================================================================
--- sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/Action.html 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/Action.html 2009-06-02 12:41:29 UTC (rev 943)
@@ -7,46 +7,21 @@
<script type="text/javascript" src="../../../../lib/GeoExt.js"></script>
<script type="text/javascript">
- function test_fromControl(t) {
- t.plan(4);
-
- var ctrl, action, cfg;
-
- ctrl = new OpenLayers.Control();
-
- // 2 tests
- action = GeoExt.Action.fromControl(ctrl);
- t.ok(action instanceof Ext.Action,
- "fromControl return an Ext.Action instance");
- t.ok(action.control == ctrl,
- "fromControl sets the control in the returned instance");
-
- // 1 test
- cfg = {text: "foo"};
- action = GeoExt.Action.fromControl(ctrl, cfg);
- t.ok(action.initialConfig == cfg,
- "fromControl sets the config in the instance's initial config");
-
- // 1 test
- var a = new Ext.Action({text: "foo"});
- action = GeoExt.Action.fromControl(ctrl, a);
- t.ok(action.initialConfig == a.initialConfig,
- "fromControl sets the passed action's initial config in the " +
- "instance's initial config");
- }
-
function test_constructor(t) {
- t.plan(10)
+ t.plan(11)
var ctrl, scope, handler, toggleHandler, checkHandler, cfg, action;
ctrl = new OpenLayers.Control();
+
+ var map = new OpenLayers.Map();
scope = {}, handler = function() {};
toggleHandler = function() {}, checkHandler = function() {};
cfg = {
control: ctrl,
+ map: map,
scope: scope,
handler: handler,
toggleHandler: toggleHandler,
@@ -57,6 +32,8 @@
t.ok(action.control == ctrl,
"constructor sets control in the instance");
+ t.ok(action.control.map === map,
+ "constructor adds control to map if provided");
t.ok(action.uScope == scope,
"constructor sets this.uScope to user-provided scope");
t.ok(action.uHandler == handler,
@@ -76,6 +53,8 @@
"constructor sets toggleHandler to this.ptoggleHandler in the initial config");
t.ok(action.initialConfig.checkHandler == action.pCheckHandler,
"constructor sets checkHandler to this.pCheckHandler in the initial config");
+
+ map.destroy();
}
function test_button(t) {
@@ -111,7 +90,8 @@
});
ctrl.activate();
- action = GeoExt.Action.fromControl(ctrl, {
+ action = new GeoExt.Action({
+ control: ctrl,
handler: function() {
handlerCnt++;
}
@@ -194,7 +174,8 @@
});
ctrl.activate();
- action = GeoExt.Action.fromControl(ctrl, {
+ action = new GeoExt.Action({
+ control: ctrl,
enableToggle: true,
toggleHandler: function() {
toggleHandlerCnt++;
@@ -318,11 +299,13 @@
ctrl2.activate();
// the actions
- action1 = GeoExt.Action.fromControl(ctrl1, {
+ action1 = new GeoExt.Action({
+ control: ctrl1,
toggleGroup: "ctrl",
pressed: false
});
- action2 = GeoExt.Action.fromControl(ctrl2, {
+ action2 = new GeoExt.Action({
+ control: ctrl2,
toggleGroup: "ctrl",
pressed: true
});
Copied: sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/LegendPanel.html (from rev 942, core/trunk/geoext/tests/lib/GeoExt/widgets/LegendPanel.html)
===================================================================
--- sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/LegendPanel.html (rev 0)
+++ sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/LegendPanel.html 2009-06-02 12:41:29 UTC (rev 943)
@@ -0,0 +1,155 @@
+<!DOCTYPE html>
+<html debug="true">
+ <head>
+ <script type="text/javascript" src="../../../../../openlayers/lib/OpenLayers.js"></script>
+ <script type="text/javascript" src="../../../../../ext/adapter/ext/ext-base.js"></script>
+ <script type="text/javascript" src="../../../../../ext/ext-all.js"></script>
+ <script type="text/javascript" src="../../../../lib/GeoExt.js"></script>
+
+ <script type="text/javascript">
+
+ function createMap() {
+ var map = new OpenLayers.Map({allOverlays: true});
+ var layer = new OpenLayers.Layer.WMS("test", '/ows', {layers: 'a'});
+ map.addLayer(layer);
+ return map;
+ }
+
+ function loadMapPanel() {
+ var map = createMap();
+
+ mapPanel = new GeoExt.MapPanel({
+ // panel options
+ id: "map-panel",
+ title: "GeoExt MapPanel",
+ renderTo: "mappanel",
+ height: 400,
+ width: 600,
+ // map panel-specific options
+ map: map,
+ center: new OpenLayers.LonLat(5, 45),
+ zoom: 4
+ });
+
+ return mapPanel;
+ }
+
+ function test_legendurl(t) {
+ t.plan(1);
+ var mapPanel = loadMapPanel();
+ var lp = new GeoExt.LegendPanel({
+ renderTo: 'legendpanel'});
+ lp.render();
+
+ var newUrl = "http://www.geoext.org//trac/geoext/chrome/site/img/GeoExt.png";
+ mapPanel.layers.getAt(0).set("legendURL", newUrl);
+
+ var item = lp.getComponent(mapPanel.map.layers[0].id);
+ var url = item.items.items[1].items.items[0].getEl().dom.src;
+ t.eq(url, newUrl, "Update the image with the provided legendURL");
+
+ lp.destroy();
+ mapPanel.destroy();
+ }
+
+ function test_togglevisibility(t) {
+ t.plan(2);
+ var mapPanel = loadMapPanel();
+ var lp = new GeoExt.LegendPanel({
+ renderTo: 'legendpanel'});
+ lp.render();
+
+ mapPanel.map.layers[0].setVisibility(false);
+ var id = mapPanel.layers.getAt(0).get('layer').id;
+ t.eq(lp.getComponent(id).hidden, true, "Layer has been hidden in legend");
+
+ mapPanel.map.layers[0].setVisibility(true);
+ t.eq(lp.getComponent(id).hidden, false, "Layer has been made visible again in legend");
+
+ lp.destroy();
+ mapPanel.destroy();
+ }
+
+ function test_hide(t) {
+ t.plan(1);
+ var mapPanel = loadMapPanel();
+ var lp = new GeoExt.LegendPanel({
+ renderTo: 'legendpanel'});
+ lp.render();
+
+ mapPanel.layers.getAt(0).set("hideInLegend", true);
+ var id = mapPanel.layers.getAt(0).get('layer').id;
+ t.eq(lp.getComponent(id).hidden, true, "Layer has been hidden in legend");
+
+ lp.destroy();
+ mapPanel.destroy();
+ }
+
+ function test_dynamic(t) {
+ t.plan(1);
+ var mapPanel = loadMapPanel();
+ var lp = new GeoExt.LegendPanel({
+ dynamic: false,
+ renderTo: 'legendpanel'});
+ lp.render();
+
+ var layer;
+ layer = new OpenLayers.Layer.WMS("test2", '/ows', {layers: 'b', format: 'image/png', transparent: 'TRUE'});
+ mapPanel.map.addLayer(layer);
+
+ t.eq(lp.items.length, 1, "If dynamic is false, do not add or remove layers from legend");
+
+ lp.destroy();
+ mapPanel.destroy();
+ }
+
+ function test_wms(t) {
+ t.plan(1);
+ var mapPanel = loadMapPanel();
+ var lp = new GeoExt.LegendPanel({
+ renderTo: 'legendpanel'});
+ lp.render();
+
+ var item = lp.getComponent(mapPanel.map.layers[0].id);
+ var url = item.items.items[1].items.items[0].url;
+ var expectedUrl = "/ows?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_xml&FORMAT=image%2Fgif&LAYER=a";
+ t.eq(url, expectedUrl, "GetLegendGraphic url is generated correctly");
+
+ lp.destroy();
+ mapPanel.destroy();
+ }
+
+ function test_addremove(t) {
+ t.plan(4);
+ var mapPanel = loadMapPanel();
+ var lp = new GeoExt.LegendPanel({
+ renderTo: 'legendpanel'});
+ lp.render();
+ t.eq(lp.items.length, 1, "Same number of layers in legend panel and in map");
+
+ var item = lp.getComponent(mapPanel.map.layers[0].id);
+
+ var layer;
+ layer = new OpenLayers.Layer.WMS("test2", '/ows', {layers: 'b', format: 'image/png', transparent: 'TRUE'});
+ mapPanel.map.addLayer(layer);
+
+ t.eq(lp.items.length, 2, "New WMS layer has been added");
+
+ layer = new OpenLayers.Layer.WMS("test3", '/ows', {layers: 'c'}, {visibility: false});
+ mapPanel.map.addLayer(layer);
+
+ t.eq(lp.items.length, 3, "A non visible WMS layer will be added but will be invisible");
+
+ mapPanel.map.removeLayer(mapPanel.map.layers[0]);
+ t.eq(lp.items.length, 2, "Removing the WMS layer really removes the legend from the panel");
+
+ lp.destroy();
+ mapPanel.destroy();
+ }
+
+ </script>
+ <body>
+ <div id="legendpanel"></div>
+ <div id="mappanel"></div>
+ </body>
+</html>
Modified: sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/MapPanel.html
===================================================================
--- sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/MapPanel.html 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/tests/lib/GeoExt/widgets/MapPanel.html 2009-06-02 12:41:29 UTC (rev 943)
@@ -12,14 +12,24 @@
var map = new OpenLayers.Map();
var layer = new OpenLayers.Layer("test", {isBaseLayer: true});
map.addLayer(layer);
+ // add a vector layer, which would fail onmapresize if we render
+ // the map before the panel has a layout.
+ map.addLayer(new OpenLayers.Layer.Vector("vector layer"));
return map;
}
function test_mappanel(t) {
- t.plan(3)
+ t.plan(4)
+ var moveToCnt;
+
var map = createMap();
-
+ map.moveTo = function() {
+ moveToCnt++;
+ OpenLayers.Map.prototype.moveTo.apply(this, arguments);
+ };
+
+ moveToCnt = 0;
var mapPanel = new GeoExt.MapPanel({
// panel options
id: "map-panel",
@@ -32,6 +42,7 @@
center: new OpenLayers.LonLat(5, 45),
zoom: 4
});
+ t.eq(moveToCnt, 1, "map.moveTo called exactly once");
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");
@@ -74,6 +85,24 @@
}
+ function test_zoom(t) {
+
+ t.plan(1);
+
+ var panel = new GeoExt.MapPanel({
+ title: "GeoExt MapPanel",
+ renderTo: "mappanel",
+ height: 400,
+ width: 600,
+ layers: [new OpenLayers.Layer()],
+ zoom: 4
+ });
+
+ t.eq(panel.map.zoom, 4, "zoom correctly set");
+
+ panel.destroy();
+ }
+
function test_extent(t) {
t.plan(3);
@@ -82,10 +111,12 @@
map = createMap();
map.zoomToExtent = function(extent) {
log.extent = extent;
- }
+ };
panel = new GeoExt.MapPanel({
renderTo: "mappanel",
map: map,
+ height: 400,
+ width: 600,
extent: [1, 2, 3, 4]
});
t.eq(log.extent.toArray(), [1, 2, 3, 4], "map extent set with array");
@@ -97,10 +128,12 @@
map = createMap();
map.zoomToExtent = function(extent) {
log.extent = extent;
- }
+ };
panel = new GeoExt.MapPanel({
renderTo: "mappanel",
map: map,
+ height: 400,
+ width: 600,
extent: "1, 2, 3, 4"
});
t.eq(log.extent.toArray(), [1, 2, 3, 4], "map extent set with string");
@@ -111,10 +144,12 @@
map = createMap();
map.zoomToExtent = function(extent) {
log.extent = extent;
- }
+ };
panel = new GeoExt.MapPanel({
renderTo: "mappanel",
map: map,
+ height: 400,
+ width: 600,
extent: new OpenLayers.Bounds(1, 2, 3, 4)
});
t.eq(log.extent.toArray(), [1, 2, 3, 4], "map extent set with Bounds");
@@ -132,10 +167,12 @@
map = createMap();
map.setCenter = function(center) {
log.center = center;
- }
+ };
panel = new GeoExt.MapPanel({
renderTo: "mappanel",
map: map,
+ height: 400,
+ width: 600,
center: [1, 2]
});
t.eq(log.center.toString(), "lon=1,lat=2", "map center set with array");
@@ -147,10 +184,12 @@
map = createMap();
map.setCenter = function(center) {
log.center = center;
- }
+ };
panel = new GeoExt.MapPanel({
renderTo: "mappanel",
map: map,
+ height: 400,
+ width: 600,
center: "1, 2"
});
t.eq(log.center.toString(), "lon=1,lat=2", "map center set with string");
@@ -162,10 +201,12 @@
map = createMap();
map.setCenter = function(center) {
log.center = center;
- }
+ };
panel = new GeoExt.MapPanel({
renderTo: "mappanel",
map: map,
+ height: 400,
+ width: 600,
center: new OpenLayers.LonLat(1, 2)
});
t.eq(log.center.toString(), "lon=1,lat=2", "map center set with LonLat");
@@ -213,7 +254,43 @@
}
+ function test_layout(t) {
+ t.plan(1);
+ var map, panel, layout = 0;
+
+ map = new OpenLayers.Map({
+ render: function() {
+ OpenLayers.Map.prototype.render.apply(this, arguments);
+ t.ok(layout, 1,
+ "the OpenLayers map is rendered once the container " +
+ "has its final dimensions");
+ },
+ allOverlays: true
+ });
+
+ panel = new Ext.Panel({
+ layout: "border",
+ renderTo: "mappanel",
+ listeners: {
+ afterlayout: function() {
+ layout++;
+ }
+ },
+ items: [{
+ region: "center",
+ xtype: "gx_mappanel",
+ map: map,
+ layers: [
+ new OpenLayers.Layer("")
+ ]
+ }]
+ });
+
+ panel.destroy();
+ }
+
+
</script>
<body>
<div id="mappanel"></div>
Modified: sandbox/camptocamp/geobretagne/tests/list-tests.html
===================================================================
--- sandbox/camptocamp/geobretagne/tests/list-tests.html 2009-06-02 08:27:59 UTC (rev 942)
+++ sandbox/camptocamp/geobretagne/tests/list-tests.html 2009-06-02 12:41:29 UTC (rev 943)
@@ -17,4 +17,5 @@
<li>lib/GeoExt/widgets/form/FormPanel.html</li>
<li>lib/GeoExt/widgets/tree/LayerNode.html</li>
<li>lib/GeoExt/widgets/tree/LayerContainer.html</li>
+ <li>lib/GeoExt/widgets/LegendPanel.html</li>
</ul>
More information about the Commits
mailing list