[Commits] r2632 - in sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing: examples lib/GeoExt.ux/widgets
commits at geoext.org
commits at geoext.org
Wed Mar 23 15:23:09 CET 2011
Author: adube
Date: 2011-03-23 15:23:09 +0100 (Wed, 23 Mar 2011)
New Revision: 2632
Modified:
sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/examples/WFSTFeatureEditing.html
sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/examples/WFSTFeatureEditing.js
sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/lib/GeoExt.ux/widgets/WFSTFeatureEditingManager.js
Log:
WFSTFeatureEditing - layer options (require patch A2 from #412), layer events, editing close and cancel, FeatureEditorGrid added, no commit yet
Modified: sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/examples/WFSTFeatureEditing.html
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/examples/WFSTFeatureEditing.html 2011-03-23 12:30:51 UTC (rev 2631)
+++ sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/examples/WFSTFeatureEditing.html 2011-03-23 14:23:09 UTC (rev 2632)
@@ -41,6 +41,7 @@
src="../../../../openlayers/lib/OpenLayers/Lang/fr.js"></script-->
<script type="text/javascript"
src="../../../../geoext/lib/GeoExt.js"></script>
+ <script type="text/javascript" src="http://dev.geoext.org/ux/geoext.ux/ux/FeatureEditing/lib/GeoExt.ux/FeatureEditorGrid.js"></script>
<script type="text/javascript"
src="../lib/GeoExt.ux/WFSTFeatureEditing.js"></script>
<!--script type="text/javascript" src="../resources/lang/fr.js"></script-->
Modified: sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/examples/WFSTFeatureEditing.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/examples/WFSTFeatureEditing.js 2011-03-23 12:30:51 UTC (rev 2631)
+++ sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/examples/WFSTFeatureEditing.js 2011-03-23 14:23:09 UTC (rev 2632)
@@ -92,10 +92,22 @@
map.setCenter(new OpenLayers.LonLat(-8005708,6182838), 7);
// WFSTFeatureEditingManager
+ var extWindow = new Ext.Window({
+ resizable: true,
+ modal: false,
+ closeAction: 'hide',
+ width: 550,
+ height: 450,
+ title: "WFSTFeatureEditing",
+ layout: 'fit',
+ items: []
+ });
+
manager = new GeoExt.ux.WFSTFeatureEditingManager({
"map": mapPanel.map,
"toolbar": toolbar,
"url": tinyURL,
- "actionGroup": "myGroup"
+ "actionGroup": "myGroup",
+ "mainPanelContainer": extWindow
});
});
Modified: sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/lib/GeoExt.ux/widgets/WFSTFeatureEditingManager.js
===================================================================
--- sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/lib/GeoExt.ux/widgets/WFSTFeatureEditingManager.js 2011-03-23 12:30:51 UTC (rev 2631)
+++ sandbox/mapgears/geoext.ux/ux/WFSTFeatureEditing/lib/GeoExt.ux/widgets/WFSTFeatureEditingManager.js 2011-03-23 14:23:09 UTC (rev 2632)
@@ -20,6 +20,18 @@
featureNS: "http://localhost"
},
+ DEFAULT_LAYER_OPTIONS: {
+ visibility: false,
+ displayInLayerSwitcher: false,
+ strategies: ["BBOX", "Save"]
+ },
+
+ DEFAULT_LAYER_OPTIONS_USE_FILTER: {
+ visibility: false,
+ displayInLayerSwitcher: false,
+ strategies: ["Fixed", "Save"]
+ },
+
DEFAULT_ACTION_GROUP: "wfstFeatureEditing",
@@ -35,7 +47,11 @@
editMenuButtonTooltipText: "Edit Tool: Select a layer from the list then " +
"click on a feature on the map to edit it.",
+ featureGridContainerTitleText: "Features",
+ featureEditorGridContainerTitleText: "Editing feature",
+
+
/* API */
toolbar: null,
@@ -44,23 +60,33 @@
map: null,
+ mainPanelContainer: null,
+
capabilitiesParams: null,
describeFeatureTypeParams: null,
protocolOptions: null,
+ layerOptions: null,
+
geomProperty: "the_geom",
actionGroup: null,
useFilter: false,
+ ignoredAttributes: {name:["the_geom", "id", "gid", "fid"]},
+
/* PRIVATE*/
mainPanel: null,
+ featureGridContainer: null,
+
+ featureEditorGridContainer: null,
+
statusBar: null,
queries: null,
@@ -86,6 +112,7 @@
},
initMainTools: function() {
+ // === Draw and Edit toolbar buttons and Menus ===
this.drawMenuButton = new Ext.Button({
//"iconCls": "wfstFeatureEditing_DrawFeature",
"text": this.drawMenuButtonText,
@@ -105,6 +132,34 @@
this.toolbar.addItem(this.editMenuButton);
this.toolbar.addItem("-");
this.toolbar.doLayout();
+
+ // === featureGrid and featureEditorGrid containers, mainPanel ===
+
+ this.featureGridContainer = new Ext.Panel({
+ "title": this.featureGridContainerTitleText,
+ "border": true,
+ "width": 300,
+ "region": "west",
+ "resizable": true,
+ "collapsible": true,
+ "layout": "fit"
+ });
+
+ this.featureEditorGridContainer = new Ext.Panel({
+ "title": this.featureEditorGridContainerTitleText,
+ "border": true,
+ "region": "center",
+ "layout": "fit"
+ });
+
+ this.mainPanel = new Ext.Panel({
+ "border": false,
+ "layout": "border",
+ "items": [this.featureGridContainer,
+ this.featureEditorGridContainer]
+ });
+
+ this.mainPanelContainer && this.mainPanelContainer.add(this.mainPanel);
},
createToolsFromURL: function(url) {
@@ -112,6 +167,13 @@
this.capabilitiesParams || {}, this.DEFAULT_CAPABILITIES_PARAMS
)));
+ var layerOptions = Ext.applyIf(this.layerOptions || {}, (this.useFilter)
+ ? this.DEFAULT_LAYER_OPTIONS_USE_FILTER
+ : this.DEFAULT_LAYER_OPTIONS);
+ // todo : delegate to WFSCapabilitiesReader
+ layerOptions = Ext.applyIf(layerOptions, {
+ projection: new OpenLayers.Projection(this.map.getProjection())});
+
var wfsCapStore = new GeoExt.data.WFSCapabilitiesStore( {
url: wfsCapURL,
listeners: {
@@ -122,13 +184,7 @@
},
protocolOptions: Ext.applyIf(
this.protocolOptions || {}, this.DEFAULT_PROTOCOL_OPTIONS),
- layerOptions: {
- // todo: delegate to WFSCapabilitiesReader
- projection: new OpenLayers.Projection(this.map.getProjection()),
- visibility: false,
- displayInLayerSwitcher: false,
- //minScale: 250000
- }
+ layerOptions: layerOptions
});
wfsCapStore.load();
@@ -266,11 +322,9 @@
layer.eraseFeatures([feature]);
feature.geometry = new multiGeom(feature.geometry);
}
- /*
- this.editingTools.drawControl.deactivate();
- this.editingTools.selectControl.activate();
- this.editingTools.selectControl.select(feature);
- */
+ this.wfstFeatureEditing.drawControl.deactivate();
+ this.wfstFeatureEditing.highlightControl.activate();
+ this.wfstFeatureEditing.selectControl.select(feature);
}
},
scope: layer
@@ -363,6 +417,8 @@
this.map.addControl(selectControl);
this.useFilter && this.map.addControl(highlightControl);
+ layer.wfstFeatureEditing._mainEditControl = (this.useFilter)
+ ? getFeatureControl : highlightControl;
var editAction = new GeoExt.Action({
text: layer.name,
@@ -387,6 +443,30 @@
}, this);
layer.wfstFeatureEditing.editAction = editAction;
+
+ // ============
+ // Layer events
+ // ============
+
+ layer.events.on({
+ "featureunselected" :function(e) {
+ // only useful if SelectFeature ctrl has clickOut property set
+ // to true
+ this.manager.cancelEditing(this.layer);
+ },
+ "featureselected" :function(e) {
+ var feature = e.feature;
+ var editorGrid = this.manager.getNewFeatureEditorGrid(feature);
+
+ // todo: is this useful ?
+ this.layer.wfstFeatureEditing.editorGrid = editorGrid;
+
+ this.manager.featureEditorGridContainer.add(editorGrid);
+ this.manager.mainPanelContainer.doLayout();
+ this.manager.mainPanelContainer.show();
+ },
+ scope: {layer: layer, manager: manager}
+ });
},
resetAll: function() {
@@ -403,5 +483,79 @@
}
}, this);
return wmsLayerSibling;
- }
+ },
+
+ getNewFeatureGrid: function() {
+ },
+
+ getNewFeatureEditorGrid: function(feature) {
+ var layer = feature.layer;
+ var params = Ext.applyIf(Ext.applyIf(
+ this.describeFeatureTypeParams || {},
+ this.DEFAULT_DESCRIBE_FEATURETYPE_PARAMS),
+ {'TYPENAME': layer.protocol.featureType});
+ var store = new GeoExt.data.AttributeStore({
+ feature: feature,
+ url: Ext.urlAppend(feature.layer.protocol.url,
+ OpenLayers.Util.getParameterString(params)),
+ ignore: this.ignoredAttributes
+ });
+ store.load();
+
+ return new GeoExt.ux.FeatureEditorGrid({
+ nameField: "name",
+ store: store,
+ feature: feature,
+ forceValidation: true,
+ allowSave: true,
+ allowCancel: true,
+ allowDelete: true,
+ border: false,
+ listeners: {
+ done: function(panel, e) {
+ var feature = e.feature, modified = e.modified;
+ this.closeEditing(feature.layer);
+ this.commitFeature(feature);
+ },
+ cancel: function(panel, e) {
+ this.cancelEditing(e.feature.layer);
+ return false;
+ },
+ scope: this
+ }
+ }); // end of return
+ },
+
+ commitFeature: function(feature) {
+
+ },
+
+ cancelEditing: function(layer) {
+ if (layer.wfstFeatureEditing.editorGrid) {
+ var feature = layer.wfstFeatureEditing.editorGrid.store.feature;
+ layer.wfstFeatureEditing.editorGrid.dirty &&
+ layer.wfstFeatureEditing.editorGrid.cancel();
+ this.closeEditing(layer);
+ if (this.isDrawing) {
+ feature.layer.wfstFeatureEditing.highlight.deactivate();
+ feature.layer.wfstFeatureEditing.drawControl.activate();
+ }
+ if(feature && feature.state === OpenLayers.State.INSERT) {
+ feature.layer && feature.layer.destroyFeatures([feature]);
+ }
+ }
+ },
+
+ closeEditing: function(layer) {
+ // avoid reentrance
+ if(!arguments.callee._in) {
+ arguments.callee._in = true;
+ this.featureGridContainer.removeAll(true);
+ this.featureEditorGridContainer.removeAll(true);
+ layer.wfstFeatureEditing.featureGrid = null;
+ layer.wfstFeatureEditing.editorGrid = null;
+ layer.wfstFeatureEditing.selectControl.unselectAll();
+ delete arguments.callee._in;
+ }
+ },
});
More information about the Commits
mailing list