[Commits] r1201 - in apps/opengeo/geoexplorer/trunk/src: html script/app script/app/GeoExplorer
commits at geoext.org
commits at geoext.org
Thu Jul 2 06:47:13 CEST 2009
Author: tschaub
Date: 2009-07-02 06:47:12 +0200 (Thu, 02 Jul 2009)
New Revision: 1201
Modified:
apps/opengeo/geoexplorer/trunk/src/html/embed.html
apps/opengeo/geoexplorer/trunk/src/html/index.html
apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer.js
apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/CapabilitiesGrid.js
apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/Full.js
apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/GroupContainer.js
apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/LayerMenuItem.js
Log:
Giving the group layer container a group property. If the record group field value matches the container group property, a node will be added to the container. If dragdrop is enabled, a layer can be added to another group. The application enforces behavior of the 'background' group - this group name doesn't mean anything special to the container.
Modified: apps/opengeo/geoexplorer/trunk/src/html/embed.html
===================================================================
--- apps/opengeo/geoexplorer/trunk/src/html/embed.html 2009-07-01 22:42:34 UTC (rev 1200)
+++ apps/opengeo/geoexplorer/trunk/src/html/embed.html 2009-07-02 04:47:12 UTC (rev 1201)
@@ -44,7 +44,7 @@
layers: [{
name: "openstreetmap",
ows: "demo",
- background: true
+ group: "background"
},{
name: "topp:states",
ows: "demo"
Modified: apps/opengeo/geoexplorer/trunk/src/html/index.html
===================================================================
--- apps/opengeo/geoexplorer/trunk/src/html/index.html 2009-07-01 22:42:34 UTC (rev 1200)
+++ apps/opengeo/geoexplorer/trunk/src/html/index.html 2009-07-02 04:47:12 UTC (rev 1201)
@@ -48,7 +48,7 @@
name: "topp:bluemarble",
title: "Global Imagery",
ows: "demo",
- background: true
+ group: "background"
}, {
name: "topp:states",
ows: "demo",
Modified: apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/CapabilitiesGrid.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/CapabilitiesGrid.js 2009-07-01 22:42:34 UTC (rev 1200)
+++ apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/CapabilitiesGrid.js 2009-07-02 04:47:12 UTC (rev 1201)
@@ -113,11 +113,11 @@
layer.maxExtent = layer.restrictedExtent;
}
- record.set("background", !!base);
- this.mapPanel.layers.insert((base ?
- 0 :
- this.mapPanel.layers.getCount()),
- record);
+ record.set("background", base && "background");
+ this.mapPanel.layers.insert(
+ base ? 0 : this.mapPanel.layers.getCount(),
+ record
+ );
}
}
Modified: apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/Full.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/Full.js 2009-07-01 22:42:34 UTC (rev 1200)
+++ apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/Full.js 2009-07-02 04:47:12 UTC (rev 1201)
@@ -195,7 +195,7 @@
var basemaps = [];
for (var i = 0, len = config.map.layers.length; i < len; i++) {
- if (config.map.layers[i].background) {
+ if (config.map.layers[i].group === "background") {
basemaps.push(config.map.layers[i]);
} else {
datalayers.push(config.map.layers[i]);
Modified: apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/GroupContainer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/GroupContainer.js 2009-07-01 22:42:34 UTC (rev 1200)
+++ apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/GroupContainer.js 2009-07-02 04:47:12 UTC (rev 1201)
@@ -2,8 +2,14 @@
GeoExplorer.GroupContainer = Ext.extend(GeoExt.tree.LayerContainer, {
- background: null,
-
+ /** api: config[group]
+ * ``String``
+ * Only layer records with a group field value that matches this value
+ * will be added to the container. If not provided, then only layer
+ * records with null or undefined group field value will be added to the
+ * container.
+ */
+
/**
* Constructor: GeoExplorer.GroupContainer
*
@@ -12,9 +18,13 @@
*/
constructor: function(config) {
config.text = config.text || "Layers";
- this.background = config.background;
- GeoExplorer.GroupContainer.superclass.constructor.apply(this,
- arguments);
+ this.group = config.group;
+ GeoExplorer.GroupContainer.superclass.constructor.apply(this, arguments);
+ this.on({
+ insert: this.onChildAdd,
+ append: this.onChildAdd,
+ scope: this
+ });
},
/**
@@ -25,7 +35,7 @@
* layerRecord - {Ext.data.Record} the layer record to add a node for
*/
addLayerNode: function(layerRecord) {
- if (layerRecord.get("background") == this.background) {
+ if (layerRecord.get("group") == this.group) {
GeoExplorer.GroupContainer.superclass.addLayerNode.call(this,
layerRecord);
}
@@ -39,9 +49,80 @@
* layerRecord - {Ext.data.Record} the layer record to remove the node for
*/
removeLayerNode: function(layerRecord) {
- if (layerRecord.get("background") == this.background) {
+ if (layerRecord.get("group") == this.group) {
GeoExplorer.GroupContainer.superclass.removeLayerNode.call(
this, layerRecord);
}
+ },
+
+ /** 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;
+ var count = store.getCount();
+ var nodeCount = this.childNodes.length;
+ var nodeIndex = -1;
+ var record;
+ for(var i=count-1; i>=0; --i) {
+ record = store.getAt(i);
+ if(record.get("layer").displayInLayerSwitcher &&
+ record.get("group") == this.group) {
+ ++nodeIndex;
+ if(index === i || nodeIndex > nodeCount-1) {
+ break;
+ }
+ }
+ };
+ return nodeIndex;
+ },
+
+ /** 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;
+ var count = store.getCount();
+ var nodeIndex = -1;
+ var record;
+ for(var i=count-1; i>=0; --i) {
+ record = store.getAt(i);
+ if(record.get("layer").displayInLayerSwitcher &&
+ record.get("group") == this.group) {
+ ++nodeIndex;
+ if(index === nodeIndex) {
+ break;
+ }
+ }
+ }
+ return i;
+ },
+
+ /** 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.
+ */
+ onChildAdd: function(tree, container, node) {
+ var record = this.layerStore.getAt(
+ this.layerStore.findBy(function(record) {
+ return record.get("layer") === node.layer;
+ })
+ );
+ if(record.get("group") !== this.group) {
+ record.set("group", this.group);
+ }
}
+
+
});
Modified: apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/LayerMenuItem.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/LayerMenuItem.js 2009-07-01 22:42:34 UTC (rev 1200)
+++ apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer/LayerMenuItem.js 2009-07-02 04:47:12 UTC (rev 1201)
@@ -39,7 +39,7 @@
border: false
},
items: [{
- xtype: record.get("background") ? "radio" : "checkbox",
+ xtype: record.get("group") === "background" ? "radio" : "checkbox",
checked: layer.getVisibility(),
handler: function(el, checked) {
layer.setVisibility(checked);
Modified: apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer.js 2009-07-01 22:42:34 UTC (rev 1200)
+++ apps/opengeo/geoexplorer/trunk/src/script/app/GeoExplorer.js 2009-07-02 04:47:12 UTC (rev 1201)
@@ -182,7 +182,7 @@
{name: "prefix"},
// Added for GeoExplorer.
- {name: "background", type: "boolean"},
+ {name: "group", type: "string"},
{name: "source_id", type: "string"}
]
});
@@ -357,7 +357,6 @@
text: "Overlays",
iconCls: "gx-folder",
expanded: true,
- background: false,
layerStore: this.mapPanel.layers,
singleClickExpand: true,
allowDrag: false,
@@ -371,7 +370,7 @@
text: "Base Layers",
iconCls: "gx-folder",
expanded: true,
- background: true,
+ group: "background",
layerStore: this.mapPanel.layers,
singleClickExpand: true,
allowDrag: false,
@@ -404,19 +403,6 @@
}
}),
listeners: {
- dragdrop: function(tree, node, dd, evt) {
- if(node && node.layer) {
- var index = this.mapPanel.layers.findBy(function(r) {
- return r.get("layer") === node.layer;
- });
- if(index > -1) {
- var record = this.mapPanel.layers.getAt(index);
- if(record.get("background") !== node.parentNode.background) {
- record.set("background");
- }
- }
- }
- },
contextmenu: function(node, e) {
if(node && node.layer) {
node.select();
@@ -521,7 +507,7 @@
var vis = [], all = [];
store.each(function(record) {
- if(record.get("background")) {
+ if(record.get("group") === "background") {
all.push(record);
if(record.get("layer").getVisibility()) {
vis.push(record);
@@ -551,7 +537,7 @@
add: function(store, records, index) {
var candidate;
Ext.each(records, function(r) {
- if(r.get("background")) {
+ if(r.get("group") === "background") {
candidate = r;
return false;
}
@@ -561,12 +547,12 @@
}
},
remove: function(store, record, index) {
- if(record.get("background")) {
+ if(record.get("group") === "background") {
updateBackground(store);
}
},
update: function(store, record, op) {
- if(record.get("background")) {
+ if(record.get("group") === "background") {
updateBackground(store, record);
}
}
@@ -657,12 +643,11 @@
record.set("title", conf.title);
}
- record.set("background", ("background" in conf ?
- conf.background : false));
+ record.set("group", conf.group);
// set any other layer configuration
// ensures that background layers are on the bottom
- if(record.get("background")){
+ if(record.get("group") === "background") {
records.unshift(record);
} else {
records.push(record);
@@ -1431,7 +1416,7 @@
name: layerRecord.get("name"),
title: layerRecord.get("title"),
visibility: layer.getVisibility(),
- background: layerRecord.get('background'),
+ group: layerRecord.get("group"),
ows: source.get("identifier")
});
}
More information about the Commits
mailing list