[Commits] r927 - in apps/opengeo/geoexplorer/trunk: . build lib lib/GeoExplorer script theme
commits at geoext.org
commits at geoext.org
Mon Jun 1 20:47:16 CEST 2009
Author: tcoulter
Date: 2009-06-01 20:47:16 +0200 (Mon, 01 Jun 2009)
New Revision: 927
Added:
apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/NewSourceWindow.js
Modified:
apps/opengeo/geoexplorer/trunk/build/geoexplorer-all.cfg
apps/opengeo/geoexplorer/trunk/debug.html
apps/opengeo/geoexplorer/trunk/index.html
apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js
apps/opengeo/geoexplorer/trunk/theme/geoexplorer.css
Log:
Add a new server! Also includes: 1) Fixed build. 2) Graceful handling of erroneous layer sources in configuration and while adding them. 3) Fixed index.html. 4) Some servers removed from debug.html because they are slow or buggy.
Modified: apps/opengeo/geoexplorer/trunk/build/geoexplorer-all.cfg
===================================================================
--- apps/opengeo/geoexplorer/trunk/build/geoexplorer-all.cfg 2009-05-29 22:07:37 UTC (rev 926)
+++ apps/opengeo/geoexplorer/trunk/build/geoexplorer-all.cfg 2009-06-01 18:47:16 UTC (rev 927)
@@ -12,6 +12,8 @@
GeoExt/widgets/ScaleSlider.js
GeoExt/widgets/tips/ScaleSliderTip.js
GeoExt/widgets/tree/LayerContainer.js
+ GeoExt/widgets/tree/BaseLayerContainer.js
+ GeoExt/widgets/tree/OverlayLayerContainer.js
GeoExt/widgets/LegendPanel.js
GeoExt/widgets/legend/Image.js
GeoExt/widgets/legend/WMS.js
@@ -79,4 +81,5 @@
GeoExplorer/Embed/Embed.js
GeoExplorer/LayerMenuItem.js
GeoExplorer/Wizard.js
+ GeoExplorer/NewSourceWindow.js
Modified: apps/opengeo/geoexplorer/trunk/debug.html
===================================================================
--- apps/opengeo/geoexplorer/trunk/debug.html 2009-05-29 22:07:37 UTC (rev 926)
+++ apps/opengeo/geoexplorer/trunk/debug.html 2009-06-01 18:47:16 UTC (rev 927)
@@ -31,8 +31,6 @@
var app = new GeoExplorer.Full({
proxy: "/proxy/?url=",
ows: {
- "sigma": "http://sigma.openplans.org/geoserver/ows",
- "geo": "http://geo.openplans.org/geoserver/ows",
"demo": "http://demo.opengeo.org/geoserver/ows"
},
map: {
@@ -42,10 +40,7 @@
isBaseLayer: true
},{
name: "nurc:Img_Sample",
- ows: "geo"
- },{
- name: "topp:states",
- ows: "sigma"
+ ows: "demo"
}],
center: [-96.7, 37.6],
zoom: 4
Modified: apps/opengeo/geoexplorer/trunk/index.html
===================================================================
--- apps/opengeo/geoexplorer/trunk/index.html 2009-05-29 22:07:37 UTC (rev 926)
+++ apps/opengeo/geoexplorer/trunk/index.html 2009-06-01 18:47:16 UTC (rev 927)
@@ -28,10 +28,18 @@
<script>
Ext.BLANK_IMAGE_URL = "theme/img/blank.gif";
var app = new GeoExplorer.Full({
- ows: "/geoserver/ows",
+ proxy: "/proxy/?url=",
+ ows: {
+ "demo": "http://demo.opengeo.org/geoserver/ows"
+ },
map: {
layers: [{
- name: "topp:states"
+ name: "openstreetmap",
+ ows: "demo",
+ isBaseLayer: true
+ },{
+ name: "nurc:Img_Sample",
+ ows: "demo"
}],
center: [-96.7, 37.6],
zoom: 4
Added: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/NewSourceWindow.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/NewSourceWindow.js (rev 0)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/NewSourceWindow.js 2009-06-01 18:47:16 UTC (rev 927)
@@ -0,0 +1,84 @@
+Ext.namespace("GeoExplorer");
+GeoExplorer.NewSourceWindow = Ext.extend(Ext.Window, {
+
+ title: "Add New Server...",
+ bodyStyle: "padding: 0px",
+ width: 300,
+ closeAction: 'hide',
+
+ error: null,
+
+ initComponent: function() {
+
+ this.addEvents("server-added");
+
+ this.urlTextField = new Ext.form.TextField({
+ fieldLabel: "URL",
+ width: 240,
+ msgTarget: "under",
+ validator: OpenLayers.Function.bind(function() {
+ return (this.error == null) ? true : this.error;
+ }, this)
+ });
+
+ this.form = new Ext.form.FormPanel({
+ items: [
+ this.urlTextField
+ ],
+ border: false,
+ labelWidth: 30,
+ bodyStyle: "padding: 5px",
+ autoWidth: true,
+ autoHeight: true
+ });
+
+ this.bbar = [
+ new Ext.Button({
+ text: "Cancel",
+ handler: function() {
+ this.hide();
+ },
+ scope: this
+ }),
+ new Ext.Toolbar.Fill(),
+ new Ext.Button({
+ text: "Add Server",
+ iconCls: "icon-addlayers",
+ handler: function() {
+ // Clear validation before trying again.
+ this.error = null;
+ this.urlTextField.validate();
+
+ this.fireEvent("server-added", this.urlTextField.getValue());
+ },
+ scope: this
+ })
+ ];
+
+ this.items = this.form;
+
+ GeoExplorer.NewSourceWindow.superclass.initComponent.call(this);
+
+ this.form.on("render", function() {
+ this.loadMask = new Ext.LoadMask(this.form.getEl(), {msg:"Contacting Server..."});
+ }, this);
+
+ this.on("hide", function() {
+ // Reset values so it looks right the next time it pops up.
+ this.error = null;
+ this.urlTextField.validate(); // Remove error text.
+ this.urlTextField.setValue("");
+ this.loadMask.hide();
+ }, this);
+ },
+
+ setLoading: function() {
+ this.loadMask.show();
+ },
+
+ setError: function(error) {
+ this.loadMask.hide();
+ this.error = error;
+ this.urlTextField.validate();
+ }
+});
Modified: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js 2009-05-29 22:07:37 UTC (rev 926)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js 2009-06-01 18:47:16 UTC (rev 927)
@@ -7,99 +7,88 @@
*/
/**
- * api: (define)
- * module = GeoExplorer
- * class = GeoExplorer(config)
- * extends = Viewer
- */
-
-/** api: constructor
- * .. class:: GeoExplorer(config)
- * Create a new GeoExplorer application.
+ * Constructor: GeoExplorer
+ * Create a new GeoExplorer application.
*
- * Parameters:
- * config - {Object} Optional application configuration properties.
+ * Parameters:
+ * config - {Object} Optional application configuration properties.
*
- * Valid config properties:
- * map - {Object} Map configuration object.
- * ows - {String} OWS URL
- * alignToGrid - {boolean} if true, align tile requests to the grid
- * enforced by tile caches such as GeoWebCache or Tilecache
+ * Valid config properties:
+ * map - {Object} Map configuration object.
+ * ows - {String} OWS URL
+ * alignToGrid - {boolean} if true, align tile requests to the grid enforced by
+ * tile caches such as GeoWebCache or Tilecache
*
- * Valid map config properties:
- * layers - {Array} A list of layer configuration objects.
- * center - {Array} A two item array with center coordinates.
- * zoom - {Number} An initial zoom level.
+ * Valid map config properties:
+ * layers - {Array} A list of layer configuration objects.
+ * center - {Array} A two item array with center coordinates.
+ * zoom - {Number} An initial zoom level.
*
- * Valid layer config properties:
- * name - {String} Required WMS layer name.
- * title - {String} Optional title to display for layer.
+ * Valid layer config properties:
+ * name - {String} Required WMS layer name.
+ * title - {String} Optional title to display for layer.
*
+ * Extends:
+ * - Viewer
*/
var GeoExplorer = Ext.extend(Viewer, {
- /** api: property[map]
- * :class:`OpenLayers.Map` The application's map.
+ /**
+ * Property: map
+ * {OpenLayers.Map} The application's map.
*/
map: null,
- /** private: property[layers]
- * A :class:`GeoExt.data.LayerStore` containing a record for each layer
- * on the map.
+ /**
+ * Property: layers
+ * {GeoExt.data.LayerStore} A store containing a record for each layer
+ * on the map.
*/
layers: null,
+ /**
+ * Property: capabilities
+ * {GeoExt.data.WMSCapabilitiesStore} A store containing a record for each
+ * layer on the server.
+ */
+ capabilities: null,
-
/**
- * private: property[mapPanel]
- * the :class:`GeoExt.MapPanel` instance for the main viewport
+ * Property: mapPanel
+ * {GeoExt.MapPanel} the MapPanel instance for the main viewport
*/
mapPanel: null,
/**
- * api: config[alignToGrid]
- * A boolean indicating whether or not to restrict tile request to tiled
- * mapping service recommendation.
- *
- * True => align to grid
- * False => unrestrained tile requests
+ * Property: alignToGrid
+ * whether or not to restrict tile request to tiled mapping service recommendation
*/
alignToGrid: false,
/**
- * private: property[capGrid]
- * :class:`Ext.Window` The window containing the CapabilitiesGrid panel to
- * use when the user is adding new layers to the map.
+ * Property: capGrid
+ * {<Ext.Window>} A window which includes a CapabilitiesGrid panel.
*/
capGrid: null,
/**
- * private: property[popupCache]
- * :class:`Object` An object containing references to visible popups so that
- * we can insert responses from multiple requests.
- *
- * ..seealso:: :method:`GeoExplorer.displayPopup()`
+ * Property: popupCache
+ * {Object} An object containing references to visible popups so that
+ * we can insert responses from multiple requests.
*/
popupCache: {},
- /** api: property[layerSources]
- * A :class:`Ext.data.Store` containing one
- * :class:`GeoExt.data.WMSCapabilitiesStore` for each WMS service in use by
- * the application, along with service-specific metadata like the service
- * name.
- */
layerSources: null,
/**
- * private: method[load]
+ * Method: load
* Called at the end of construction. This initiates the sequence that
- * prepares the application for use, including tasks such as loading
- * capabilities from remote servers, populating the map, etc.
+ * prepares the application for use.
*/
load: function() {
+
this.layerSources = new Ext.data.SimpleStore({
- fields: ["identifier", "name", "store"],
+ fields: ["identifier", "name", "store", "url"],
data: []
});
@@ -114,56 +103,79 @@
];
for (var id in this.ows) {
-
- // Load capabilities for each ows passed in.
+ // Load capabilities for each ows passed through the configuration.
dispatchQueue.push(
(function(id) {
// Create a new scope for 'id'.
return function(done){
- var store = new GeoExt.data.WMSCapabilitiesStore();
- var url = this.createWMSCapabilitiesURL(this.ows[id]);
-
- OpenLayers.Request.GET({
- proxy: this.proxy,
- url: url,
- success: function(request){
- var data = request.responseXML || request.responseText;
-
- // Read the response. It's important to note that the
- // WMSCapabilitiesStore reads the data as well, though
- // we need to do it ourselves in order to maintain
- // low coupling.
- var format = new OpenLayers.Format.WMSCapabilities();
- var extractedData = format.read(data);
-
- store.loadData(data);
-
- var record = new this.layerSources.recordType({
- store: store,
- identifier: id,
- name: extractedData.service.title || id
- });
-
- this.layerSources.add(record);
- done();
- },
- failure: function(){
- OpenLayers.Console.error("Couldn't get capabilities document for ows '" + id + "'.");
- done();
- },
- scope: this
- });
+ this.addSource(this.ows[id], id, done, done);
};
- })(id));
+ })(id)
+ );
}
this.dispatch(
dispatchQueue,
// activate app when the above are both done
- this.activate);
+ this.activate
+ );
},
+ /** private: method[addSource]
+ * Add a new WMS server to GeoExplorer. The id parameter is optional,
+ * and will be given a default if not specified; success and fail
+ * are also optional, and scope only applies if success or fail
+ * is passed in.
+ */
+ addSource: function(url, id, success, fail, scope) {
+ scope = scope || this;
+ success = OpenLayers.Function.bind(success, scope);
+ fail = OpenLayers.Function.bind(fail, scope);
+
+ id = id || OpenLayers.Util.createUniqueID("source");
+ var capsURL = this.createWMSCapabilitiesURL(url);
+
+ OpenLayers.Request.GET({
+ proxy: this.proxy,
+ url: capsURL,
+ success: function(request){
+ var store = new GeoExt.data.WMSCapabilitiesStore();
+ var data = request.responseXML || request.responseText;
+
+ try {
+ // Read the response. It's important to note that the
+ // WMSCapabilitiesStore reads the data as well, though
+ // we need to do it ourselves in order to maintain
+ // low coupling.
+ var format = new OpenLayers.Format.WMSCapabilities();
+ var extractedData = format.read(data);
+
+ store.loadData(data);
+ } catch(err) {
+ OpenLayers.Console.error("Could not load source: " + url);
+ fail();
+ return;
+ }
+
+ var record = new this.layerSources.recordType({
+ url: url,
+ store: store,
+ identifier: id,
+ name: extractedData.service.title || id
+ });
+
+ this.layerSources.add(record);
+ success(record);
+ },
+ failure: function(){
+ OpenLayers.Console.error("Couldn't get capabilities document for ows '" + id + "'.");
+ fail();
+ },
+ scope: this
+ });
+ },
+
/** private: method[createWMSCapabilitiesURL]
* Given the URL to an OWS service endpoint, generate a GET request URL for
* the service's WMS capabilities.
@@ -185,7 +197,8 @@
return url;
},
- /** private: method[createLayout]
+ /**
+ * Method: createLayout
* Create the various parts that compose the layout.
*/
createLayout: function() {
@@ -193,6 +206,7 @@
// create the map
// TODO: check this.initialConfig.map for any map options
this.map = new OpenLayers.Map({
+ allOverlays: true,
controls: [new OpenLayers.Control.PanPanel(),
new OpenLayers.Control.ZoomPanel()]
});
@@ -271,8 +285,6 @@
}
});
- //this is a hack around OpenLayers #2111
- var map = this.map
var removeLayerAction = new Ext.Action({
text: "Remove Layer",
iconCls: "icon-removelayers",
@@ -286,10 +298,6 @@
store.remove(store.getAt(store.findBy(function(record) {
return record.get("layer") === layer;
})));
-
- //this is a hack around OpenLayers #2111
- map.baseLayer.events.triggerEvent("visibilitychanged");
-
removeLayerAction.disable();
}
}
@@ -408,7 +416,8 @@
});
},
- /** private: method[activate]
+ /**
+ * Method: activate
* Activate the application. Call after application is configured.
*/
activate: function() {
@@ -423,9 +432,9 @@
},
- /** private: method[addLayers]
- * Construct the layer store to be used with the map (referenced as
- * :attr:`GeoExplorer.layers`).
+ /**
+ * Method: addLayers
+ * Construct the layer store to be used with the map (referenced as <layers>).
*/
addLayers: function() {
var mapConfig = this.initialConfig.map;
@@ -469,7 +478,7 @@
}
layer.setIsBaseLayer("isBaseLayer" in conf ?
- conf.isBaseLayer : false);
+ conf.isBaseLayer: false);
// set any other layer configuration
records.push(record);
@@ -493,11 +502,14 @@
},
/**
- * private: method[initCapGrid]
+ * Method: initCapGrid
* Constructs a window with a capabilities grid.
*/
initCapGrid: function(){
+ // TODO: Might be nice to subclass some of these things into
+ // into their own classes.
+
var firstSource = this.layerSources.getAt(0);
var capGridPanel = new CapabilitiesGrid({
@@ -521,6 +533,7 @@
triggerAction: "all",
editable: false,
allowBlank: false,
+ forceSelection: true,
mode: "local",
value: firstSource.data.identifier
});
@@ -529,6 +542,31 @@
capGridPanel.reconfigure(record.data.store, capGridPanel.getColumnModel());
}, this);
+ var newSourceWindow = new GeoExplorer.NewSourceWindow();
+
+ newSourceWindow.on("server-added", function(url) {
+ newSourceWindow.setLoading();
+
+ var success = function(record) {
+ // The combo box will automatically update when a new item
+ // is added to the layerSources store. Now all we have to
+ // do is select it. Note: There's probably a better way to do this,
+ // but there doesn't seem to be another way to get the select event
+ // to fire.
+ var index = this.layerSources.find("identifier", record.data.identifier)
+ sourceComboBox.fireEvent("select", sourceComboBox, record, index);
+
+ // Close the new source window.
+ newSourceWindow.hide();
+ };
+
+ var failure = function() {
+ newSourceWindow.setError("Error contacting server.\nPlease check the url and try again.");
+ };
+
+ this.addSource(url, null, success, failure, this);
+ }, this);
+
this.capGrid = new Ext.Window({
title: "Available Layers",
closeAction: 'hide',
@@ -542,7 +580,14 @@
new Ext.Toolbar.TextItem({
text: "View available data from:"
}),
- sourceComboBox
+ sourceComboBox,
+ new Ext.Button({
+ text: "or add a new server.",
+ handler: function() {
+ newSourceWindow.show();
+ },
+ scope: this
+ })
],
bbar: [
"->",
@@ -555,14 +600,6 @@
scope : this
}),
new Ext.Button({
- text: "Add Base Layers",
- iconCls: "icon-addlayers",
- handler: function(){
- capGridPanel.addLayers(true);
- },
- scope : this
- }),
- new Ext.Button({
text: "Done",
handler: function() {
this.capGrid.hide();
@@ -578,7 +615,8 @@
});
},
- /** private: method[showCapabilitiesGrid]
+ /**
+ * Method: showCapabilitiesGrid
* Shows the window with a capabilities grid.
*/
showCapabilitiesGrid: function() {
@@ -588,11 +626,6 @@
this.capGrid.show();
},
- /** private: method[createMapOverlay]
- * Builds the :class:`Ext.Panel` containing components to be overlaid on the
- * map, setting up the special configuration for its layout and
- * map-friendliness.
- */
createMapOverlay: function() {
var scaleLinePanel = new Ext.Panel({
cls: 'olControlScaleLine overlay-element overlay-scaleline',
@@ -670,11 +703,6 @@
return mapOverlay;
},
- /** private: method[createTools]
- * Create the toolbar configuration for the main panel. This method can be
- * overridden in derived explorer classes such as :class:`GeoExplorer.Full`
- * or :class:`GeoExplorer.Embed` to provide specialized controls.
- */
createTools: function() {
// create a navigation control
@@ -759,7 +787,7 @@
layers: [x.get("layer")],
eventListeners: {
getfeatureinfo: function(evt) {
- gx.displayPopup(evt, x.get("title") || x.get("name"));
+ gx.displayPopup(evt, x.get("title"));
},
scope: gx
}
@@ -858,14 +886,6 @@
return tools;
},
- /** private: method[createMeasureTool]
- * :param: handlerType: the :class:`OpenLayers.Handler` for the measurement
- * operation
- * :param: title: the string label to display alongside results
- *
- * Convenience method for creating a :class:`OpenLayers.Control.Measure`
- * control
- */
createMeasureTool: function(handlerType, title) {
var styleMap = new OpenLayers.StyleMap({
@@ -979,13 +999,7 @@
return measureControl;
},
- /** private: method[displayPopup]
- * :param: evt: the event object from a
- * :class:`OpenLayers.Control.GetFeatureInfo` control
- * :param: title: a String to use for the title of the results section
- * reporting the info to the user
- */
- displayPopup: function(evt, title) {
+ displayPopup: function(evt, title){
var popup;
var popupKey = evt.xy.x + "." + evt.xy.y;
@@ -1028,11 +1042,12 @@
/**
- * private: method[bookmark]
- * :return: the URL :class:`String` that was displayed to the user
- *
+ * Method: bookmark
* Creates a window that shows the user a URL that can be used to
* reload the map in its current configuration.
+ *
+ * Returns:
+ *{String} The URL displayed to the user.
*/
bookmark: function(){
var config = this.extractConfiguration();
@@ -1062,10 +1077,13 @@
},
/**
- * private: method[extractConfiguration]
- * :return: an :class:`Object` representing the app's current configuration.
+ * Method: extractConfiguration
+ * Returns an object that represents the app's current configuration.
+ *
+ * Returns:
+ *{Object} An object that represents the app's current configuration.
*/
- extractConfiguration: function() {
+ extractConfiguration: function(){
var config = {};
// Map configuration
@@ -1081,25 +1099,21 @@
config.map.layers = [];
this.layers.each(function(layerRecord){
- if (layerRecord.get('layer').displayInLayerSwitcher) {
- var c = {
- title: layerRecord.get("title"),
- name: (layerRecord.get("layer").params &&
- layerRecord.get("layer").params.LAYERS) ||
- layerRecord.get("name"),
- visibility: layerRecord.get("layer").getVisibility()
- };
- config.map.layers.push(c);
- }
+ var c = {
+ title: layerRecord.get("title"),
+ name: (layerRecord.get("layer").params &&
+ layerRecord.get("layer").params.LAYERS) ||
+ layerRecord.get("name"),
+ visibility: layerRecord.get("layer").getVisibility()
+ };
+
+ config.map.layers.push(c);
});
return config;
},
- /** private: method[displayAppInfo]
- * Display an informational dialog about the application.
- */
displayAppInfo: function() {
var win = new Ext.Window({
title: "About GeoExplorer",
Modified: apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js 2009-05-29 22:07:37 UTC (rev 926)
+++ apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js 2009-06-01 18:47:16 UTC (rev 927)
@@ -14,7 +14,8 @@
"lib/GeoExplorer/CapabilitiesGrid.js",
"lib/GeoExplorer/Full/Full.js",
"lib/GeoExplorer/Embed/Embed.js",
- "lib/GeoExplorer/EventfulWMSCapabilitiesReader.js"
+ "lib/GeoExplorer/EventfulWMSCapabilitiesReader.js",
+ "lib/GeoExplorer/NewSourceWindow.js"
);
var appendable = !(/MSIE/.test(navigator.userAgent) ||
Modified: apps/opengeo/geoexplorer/trunk/theme/geoexplorer.css
===================================================================
--- apps/opengeo/geoexplorer/trunk/theme/geoexplorer.css 2009-05-29 22:07:37 UTC (rev 926)
+++ apps/opengeo/geoexplorer/trunk/theme/geoexplorer.css 2009-06-01 18:47:16 UTC (rev 927)
@@ -35,6 +35,10 @@
background-image: url(img/silk/delete.png);
}
+.x-btn .icon-addserver {
+ background-image: url(img/silk/server_add.png);
+}
+
.x-btn .icon-getfeatureinfo {
background-image: url(img/silk/information.png);
}
More information about the Commits
mailing list