[Commits] r2133 - sandbox/bartvde/playground/geoext.ux/ux/WMSTree/lib/GeoExt.ux

commits at geoext.org commits at geoext.org
Tue Apr 27 14:58:16 CEST 2010


Author: bartvde
Date: 2010-04-27 14:58:16 +0200 (Tue, 27 Apr 2010)
New Revision: 2133

Modified:
   sandbox/bartvde/playground/geoext.ux/ux/WMSTree/lib/GeoExt.ux/WMSLoader.js
Log:
now with less code :-)

Modified: sandbox/bartvde/playground/geoext.ux/ux/WMSTree/lib/GeoExt.ux/WMSLoader.js
===================================================================
--- sandbox/bartvde/playground/geoext.ux/ux/WMSTree/lib/GeoExt.ux/WMSLoader.js	2010-04-27 12:45:30 UTC (rev 2132)
+++ sandbox/bartvde/playground/geoext.ux/ux/WMSTree/lib/GeoExt.ux/WMSLoader.js	2010-04-27 12:58:16 UTC (rev 2133)
@@ -2,77 +2,29 @@
 
 GeoExt.ux.WMSLoader = function(config) {
     Ext.apply(this, config);
-    // TODO add events?
     GeoExt.ux.WMSLoader.superclass.constructor.call(this);
 };
 
-Ext.extend(GeoExt.ux.WMSLoader, Ext.util.Observable, {
+Ext.extend(GeoExt.ux.WMSLoader, Ext.tree.TreeLoader, {
 
-    url: null,
+    requestMethod: 'GET',
 
-    load: function(node, callback, scope) {
-        if(this.clearOnLoad){
-            while(node.firstChild){
-                node.removeChild(node.firstChild);
-            }
-        }
-        this.requestData(node, callback, scope || node); 
+    getParams: function(node) {
+        return {'service': 'WMS', 'request': 'GetCapabilities'};
     },
 
-    requestData: function(node, callback, scope){
-        if(this.fireEvent("beforeload", this, node, callback) !== false){
-            this.transId = Ext.Ajax.request({
-                method: 'GET',
-                url: this.url,
-                params: {'service': 'WMS', 'request': 'GetCapabilities'},
-                success: this.handleResponse,
-                failure: this.handleFailure,
-                scope: this,
-                argument: {callback: callback, node: node, scope: scope}
-            });
-        } else {
-            // if the load is cancelled, make sure we notify
-            // the node that we are done
-            this.runCallback(callback, scope || node, []);
-        }
-    },
-
-    // private
-    runCallback: function(cb, scope, args){
-        if(Ext.isFunction(cb)){
-            cb.apply(scope, args);
-        }
-    },
-
-    createNode : function(attr){
-        // apply baseAttrs, nice idea Corey!
-        if(this.baseAttrs){
-            Ext.applyIf(attr, this.baseAttrs);
-        }
-        if(this.applyLoader !== false && !attr.loader){
-            attr.loader = this;
-        }
-        if(Ext.isString(attr.uiProvider)){
-           attr.uiProvider = this.uiProviders[attr.uiProvider] || eval(attr.uiProvider);
-        }
-        if(attr.nodeType){
-            return new Ext.tree.TreePanel.nodeTypes[attr.nodeType](attr);
-        }else{
-            return new Ext.tree.TreeNode(attr);
-        }
-    }, 
-
     processResponse : function(response, node, callback, scope){
-        var caps = new OpenLayers.Format.WMSCapabilities().read(response.responseXML || response.responseText);
-        if (caps.capability) {
-            this.processLayer(caps.capability, node); 
-        }
+        var capabilities = new OpenLayers.Format.WMSCapabilities().read(
+            response.responseXML || response.responseText);
+        this.processLayer(capabilities.capability, node); 
         this.runCallback(callback, scope || node, [node]);
     }, 
 
     processLayer: function(layer, node) {
         Ext.each(layer.nestedLayers, function(el) {
             var n = this.createNode({text: el.title, 
+                // use nodeType 'node' so no AsyncTreeNodes are created
+                nodeType: 'node',
                 leaf: (el.nestedLayers.length === 0)});
             if(n){
                 node.appendChild(n);
@@ -81,19 +33,6 @@
                 this.processLayer(el, n);
             }
         }, this);
-    },
-
-    handleResponse : function(response){
-        this.transId = false;
-        var a = response.argument;
-        this.processResponse(response, a.node, a.callback, a.scope);
-        this.fireEvent("load", this, a.node, response);
-    },
-
-    handleFailure : function(response){
-        this.transId = false;
-        var a = response.argument;
-        this.fireEvent("loadexception", this, a.node, response);
-        this.runCallback(a.callback, a.scope || a.node, [a.node]);
     }
+
 });



More information about the Commits mailing list