[Commits] r237 - in sandbox/opengeo/alachua/lib: . GeoExt GeoExt/request

commits at geoext.org commits at geoext.org
Fri Mar 20 17:58:05 CET 2009


Author: tcoulter
Date: 2009-03-20 17:58:04 +0100 (Fri, 20 Mar 2009)
New Revision: 237

Added:
   sandbox/opengeo/alachua/lib/GeoExt/request/
   sandbox/opengeo/alachua/lib/GeoExt/request/ErrorWindow.js
   sandbox/opengeo/alachua/lib/GeoExt/request/RequestManager.js
Modified:
   sandbox/opengeo/alachua/lib/GeoExt.js
Log:
Added ErrorWindow and RequestManager from Drake. Also refactored the toolbar and made a loading icon that shows when the map layers are loading. This closes #140.

Added: sandbox/opengeo/alachua/lib/GeoExt/request/ErrorWindow.js
===================================================================
--- sandbox/opengeo/alachua/lib/GeoExt/request/ErrorWindow.js	                        (rev 0)
+++ sandbox/opengeo/alachua/lib/GeoExt/request/ErrorWindow.js	2009-03-20 16:58:04 UTC (rev 237)
@@ -0,0 +1,31 @@
+// Show a nice error window on request failures. 
+// Based on Facebook's error window: 
+// http://www.disobey.com/ghostsites/uploaded_images/facebook_error-778596.JPG
+
+GeoExt.ErrorWindow = Ext.extend(Ext.Window, {
+
+    url: null,
+    request: null,
+    
+    autoHeight: true,
+    width: 350,
+    
+    bodyStyle: "padding: 5px; background-color: #FFFFFF;",
+    
+    title: "HTTP Error",
+
+    initComponent: function() {
+        this.html = "Transport error (#" + this.request.status + ") while retreiving data from endpoint<br>`" + this.url + "': Unknown HTTP error #" + this.request.status;
+        this.buttons = [
+            new Ext.Button({
+                text: "Okay",
+                handler: function() {
+                    this.close();
+                },
+                scope: this
+            })
+        ];
+        
+        GeoExt.ErrorWindow.superclass.initComponent.call(this);
+    }
+});

Added: sandbox/opengeo/alachua/lib/GeoExt/request/RequestManager.js
===================================================================
--- sandbox/opengeo/alachua/lib/GeoExt/request/RequestManager.js	                        (rev 0)
+++ sandbox/opengeo/alachua/lib/GeoExt/request/RequestManager.js	2009-03-20 16:58:04 UTC (rev 237)
@@ -0,0 +1,38 @@
+/**
+ * Hook to support application-wide request handling. In an attempt to fit 
+ * both OpenLayers and Ext requests into the same interface, some data is 
+ * lost from simply listening to Ext.Ajax events. 
+ * 
+ * Written in the parlance of Ext's WindowManager.js
+ */
+
+Ext.namespace("GeoExt");
+
+GeoExt.RequestHook = function() {
+    this.addEvents("requestcomplete", "requestexception");
+    
+    // Fire on both OpenLayers and Ext requests.
+    
+    // OpenLayers:
+    // We ignore the "complete" event to stay in parlance with Ext.
+    OpenLayers.Request.events.register("success", this, function(evt) {
+        this.fireEvent("requestcomplete", evt.request, evt.requestUrl);
+    });
+    
+    OpenLayers.Request.events.register("failure", this, function(evt) {
+        this.fireEvent("requestexception", evt.request, evt.requestUrl);
+    });
+    
+    // Ext:
+    Ext.Ajax.on("requestcomplete", function(connection, xhr, options) {
+        this.fireEvent("requestcomplete", xhr, options.url);
+    }, this);
+    
+    Ext.Ajax.on("requestexception", function(connection, xhr, options) {
+        this.fireEvent("requestexception", xhr, options.url);
+    }, this);
+}
+
+Ext.extend(GeoExt.RequestHook, Ext.util.Observable);
+
+GeoExt.RequestMgr = new GeoExt.RequestHook();

Modified: sandbox/opengeo/alachua/lib/GeoExt.js
===================================================================
--- sandbox/opengeo/alachua/lib/GeoExt.js	2009-03-18 22:16:38 UTC (rev 236)
+++ sandbox/opengeo/alachua/lib/GeoExt.js	2009-03-20 16:58:04 UTC (rev 237)
@@ -84,6 +84,8 @@
             "GeoExt/data/LayerStore.js",
             "GeoExt/data/ProtocolProxy.js",
             "GeoExt/layer/Vector.js",
+            "GeoExt/request/RequestManager.js",
+            "GeoExt/request/ErrorWindow.js",
             "GeoExt/widgets/MapPanel.js"
         );
 



More information about the Commits mailing list