[Commits] r987 - in apps/opengeo/geoexplorer/trunk: . lib lib/GeoExplorer script

commits at geoext.org commits at geoext.org
Thu Jun 4 20:53:03 CEST 2009


Author: dwins
Date: 2009-06-04 20:53:03 +0200 (Thu, 04 Jun 2009)
New Revision: 987

Added:
   apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/util.js
Removed:
   apps/opengeo/geoexplorer/trunk/lib/Viewer.js
Modified:
   apps/opengeo/geoexplorer/trunk/debug.html
   apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
   apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js
Log:
Refactor Viewer functionality into GeoExplorer and GeoExplorer.util


Modified: apps/opengeo/geoexplorer/trunk/debug.html
===================================================================
--- apps/opengeo/geoexplorer/trunk/debug.html	2009-06-04 18:20:43 UTC (rev 986)
+++ apps/opengeo/geoexplorer/trunk/debug.html	2009-06-04 18:53:03 UTC (rev 987)
@@ -31,20 +31,21 @@
             var app = new GeoExplorer.Full({
                 proxy: "/proxy/?url=",
                 ows: {
-                    "demo": "http://demo.opengeo.org/geoserver/ows"
+                    "local": "http://10.254.200.217/geoserver/ows/",
+                    "notlocal": "http://10.254.200.217/geoserver/ows/"
                 },
                 map: {
                     layers: [{
                         name: "nurc:Img_Sample",
-                        ows: "demo"
+                        ows: "local"
                     },{
                         name: "topp:states",
-                        ows: "demo",
+                        ows: "local",
                         background: true,
                         visibility:true
                     },{
-                        name: "openstreetmap",
-                        ows: "demo",
+                        name: "topp:bluemarble",
+                        ows: "local",
                         visibility: false,
                         background: true  
                     }],

Copied: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/util.js (from rev 982, apps/opengeo/geoexplorer/trunk/lib/Viewer.js)
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/util.js	                        (rev 0)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/util.js	2009-06-04 18:53:03 UTC (rev 987)
@@ -0,0 +1,45 @@
+/**
+ * Copyright (c) 2008 The Open Planning Project
+ */
+
+/**
+ * api: (define)
+ * module = GeoExplorer.util
+ */
+
+GeoExplorer.util = {
+    /** api: method[dispatch]
+     * :param: functions: :class:`Array(Function)` List of functions to be 
+     *     called.  All functions will be called with two arguments - a callback
+     *     to call when the sequence is done and a storage object
+     * :param: complete: :class:`Function` A function that will be called when 
+     *     all other functions report that they are done.  The final callback 
+     *     will be called with the storage object passed to all other functions.
+     * :param: scope: :class:`Object` Optional object to be set as the scope of
+     *     all functions called.
+     *
+     * Allows multiple asynchronous sequences to be called in parallel.  A final
+     * callback is called when all other sequences report that they are done.
+     */
+    dispatch: function(functions, complete, scope) {
+        complete = complete || Ext.emptyFn;
+        scope = scope || this;
+        var requests = functions.length;
+        var responses = 0;
+        var storage = {};
+        function respond() {
+            ++responses;
+            if(responses === requests) {
+                complete.call(scope, storage);
+            }
+        }
+        function trigger(index) {
+            window.setTimeout(function() {
+                functions[index].apply(scope, [respond, storage]);
+            });
+        }
+        for(var i=0; i<requests; ++i) {
+            trigger(i);
+        }
+    }
+};


Property changes on: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/util.js
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js	2009-06-04 18:20:43 UTC (rev 986)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js	2009-06-04 18:53:03 UTC (rev 987)
@@ -9,7 +9,7 @@
 /**
  * api: (define)
  * module = GeoExplorer
- * extends = Viewer
+ * extends = Ext.Observable
  */
 
 /** api: constructor
@@ -35,7 +35,7 @@
  *     title - {String} Optional title to display for layer.
  *
  */
-var GeoExplorer = Ext.extend(Viewer, {
+var GeoExplorer = Ext.extend(Ext.util.Observable, {
     
     /** api: property[map]
      * :class:`OpenLayers.Map` The application's map.
@@ -88,6 +88,31 @@
      */
     layerSources: null,
 
+    constructor: function(config) {
+        this.popupCache = {};
+
+        var query = Ext.urlDecode(document.location.search.substr(1));
+        var queryConfig = Ext.util.JSON.decode(query.q);
+        
+        this.initialConfig = Ext.apply({}, queryConfig, config);
+        Ext.apply(this, this.initialConfig);
+        
+        // add any custom application events
+        this.addEvents(
+            /**
+             * Event: ready
+             * Fires when application is ready for user interaction.
+             */
+            "ready");
+        
+        // pass on any proxy config to OpenLayers
+        if(this.proxy) {
+            OpenLayers.ProxyHost = this.proxy;
+        }
+        
+        this.load();
+    },
+
     /**
      * private: method[load]
      * Called at the end of construction.  This initiates the sequence that
@@ -95,8 +120,6 @@
      * capabilities from remote servers, populating the map, etc.
      */
     load: function() {
-        this.popupCache = {};
-
         this.layerSources = new Ext.data.SimpleStore({
             fields: ["identifier", "name", "store", "url"],
             data: []
@@ -123,11 +146,12 @@
                 })(id));
         }
         
-        this.dispatch(
+        GeoExplorer.util.dispatch(
             dispatchQueue,
             
             // activate app when the above are both done
-            this.activate);
+            this.activate, 
+            this);
     },
     
     /** private: method[addSource]
@@ -145,8 +169,6 @@
         var capsURL = this.createWMSCapabilitiesURL(url);
                         var store = new GeoExt.data.WMSCapabilitiesStore();
 
-
-
         OpenLayers.Request.GET({
             proxy: this.proxy, 
             url: capsURL,
@@ -336,14 +358,6 @@
             }
         });
 
-        var baseSelectionModel = new Ext.tree.DefaultSelectionModel({
-            listeners: {
-                beforeselect: function() {
-                    removeBaseLayerAction.enable();
-                }
-            }
-        });
-
         var removeLayerAction = new Ext.Action({
             text: "Remove Layer",
             iconCls: "icon-removelayers",
@@ -356,7 +370,7 @@
                     var store = node.layerStore;
                     var record = store.getAt(store.findBy(function(record) {
                         return record.get("layer") === layer;
-                    }))
+                    }));
                     store.remove(record);
                     removeLayerAction.disable();
                 }
@@ -375,7 +389,7 @@
                     var store = node.layerStore;
                     var record = store.getAt(store.findBy(function(record) {
                         return record.get("layer") === layer;
-                    }))
+                    }));
                     store.remove(record);
                     removeBaseLayerAction.disable();
                 }
@@ -473,7 +487,7 @@
             border: false,
             region: 'center',
             layout: 'border',
-            items: [overlayLayerTree, baseLayerTree],
+            items: [overlayLayerTree, baseLayerTree]
         });
 
         var legendContainer = new GeoExt.LegendPanel({
@@ -554,7 +568,7 @@
                     });
                 }
             }
-        }
+        };
 
         // make sure one base layer is always visible after add, remove or update
         this.layers.on({
@@ -746,7 +760,7 @@
                 }),
                 baseSourceComboBox
             ];
-        };
+        }
 
         if (this.proxy) {
             capGridToolbar.push(new Ext.Button({
@@ -774,7 +788,7 @@
                 // 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)
+                var index = this.layerSources.find("identifier", record.data.identifier);
                 sourceComboBox.fireEvent("select", sourceComboBox, record, index);
                 
                 // Close the new source window.
@@ -1381,7 +1395,7 @@
                 var index = this.layerSources.find("identifier", layerRecord.get("source_id"));
                 var source = this.layerSources.getAt(index);
                 
-                if (source == null) {
+                if (source === null) {
                     OpenLayers.Console.error("Could not find source for layer '" + layerRecord.get("name") + "'");
                     
                     // Return; error gracefully. (This is debatable.)

Deleted: apps/opengeo/geoexplorer/trunk/lib/Viewer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/Viewer.js	2009-06-04 18:20:43 UTC (rev 986)
+++ apps/opengeo/geoexplorer/trunk/lib/Viewer.js	2009-06-04 18:53:03 UTC (rev 987)
@@ -1,85 +0,0 @@
-/**
- * Copyright (c) 2008 The Open Planning Project
- */
-
-/**
- * api: (define)
- * module = GeoExplorer
- * class = Viewer(config)
- * extends = Ext.util.Observable
- */
-
-/** api: constructor
- * ..class:: Viewer(config)
- * :param: config - optional application configuration properties
- *
- * Create a new Viewer application.
- */
-var Viewer = Ext.extend(Ext.util.Observable, {
-    
-    constructor: function(config) {
-
-        var query = Ext.urlDecode(document.location.search.substr(1));
-        var queryConfig = Ext.util.JSON.decode(query.q);
-        
-        this.initialConfig = Ext.apply({}, queryConfig, config);
-        Ext.apply(this, this.initialConfig);
-        
-        // add any custom application events
-        this.addEvents(
-            /**
-             * Event: ready
-             * Fires when application is ready for user interaction.
-             */
-            "ready");
-        
-        // pass on any proxy config to OpenLayers
-        if(this.proxy) {
-            OpenLayers.ProxyHost = this.proxy;
-        }
-        
-        this.load();
-        
-    },
-    
-    /** api: method[load]
-     * Called to load the application.  Implemented by a subclass.
-     */
-    load: Ext.emptyFn,
-
-    /** api: method[dispatch]
-     * :param: functions: :class:`Array(Function)` List of functions to be 
-     *     called.  All functions will be called with two arguments - a callback
-     *     to call when the sequence is done and a storage object
-     * :param: complete: :class:`Function` A function that will be called when 
-     *     all other functions report that they are done.  The final callback 
-     *     will be called with the storage object passed to all other functions.
-     * :param: scope: :class:`Object` Optional object to be set as the scope of
-     *     all functions called.
-     *
-     * Allows multiple asynchronous sequences to be called in parallel.  A final
-     * callback is called when all other sequences report that they are done.
-     */
-    dispatch: function(functions, complete, scope) {
-        complete = complete || Ext.emptyFn;
-        scope = scope || this;
-        var requests = functions.length;
-        var responses = 0;
-        var storage = {};
-        function respond() {
-            ++responses;
-            if(responses === requests) {
-                complete.call(scope, storage);
-            }
-        }
-        function trigger(index) {
-            window.setTimeout(function() {
-                functions[index].apply(scope, [respond, storage]);
-            });
-        }
-        for(var i=0; i<requests; ++i) {
-            trigger(i);
-        }
-    }
-    
-});

Modified: apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js	2009-06-04 18:20:43 UTC (rev 986)
+++ apps/opengeo/geoexplorer/trunk/script/GeoExplorer-debug.js	2009-06-04 18:53:03 UTC (rev 987)
@@ -3,8 +3,8 @@
     // Since the applications are located one directory down from
     // the base, all these includes must be prefixed by a ../
     var jsfiles = new Array(
-        "lib/Viewer.js",
         "lib/GeoExplorer.js",
+        "lib/GeoExplorer/util.js",
         "lib/Ext/grid/RowExpander.js",
         "lib/GeoExplorer/MapToolToggle.js",
         "lib/GeoExplorer/MapToolSplitToggle.js",



More information about the Commits mailing list