[Commits] r1639 - in sandbox/cmoullet/ux/LayerManager/ux: data widgets

commits at geoext.org commits at geoext.org
Thu Dec 31 17:53:26 CET 2009


Author: cmoullet
Date: 2009-12-31 17:53:26 +0100 (Thu, 31 Dec 2009)
New Revision: 1639

Modified:
   sandbox/cmoullet/ux/LayerManager/ux/data/Import.js
   sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerImportPanel.js
Log:
Improve event dataimported

Modified: sandbox/cmoullet/ux/LayerManager/ux/data/Import.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/data/Import.js	2009-12-31 12:35:48 UTC (rev 1638)
+++ sandbox/cmoullet/ux/LayerManager/ux/data/Import.js	2009-12-31 16:53:26 UTC (rev 1639)
@@ -8,22 +8,24 @@
 
 Ext.namespace("GeoExt.ux.data");
 
+GeoExt.ux.data.importFeatures = null;
+
 // layer: optional {<OpenLayers.Layer>}
 // features: optional: {Array(<OpenLayers.Feature.Vector>)}
 GeoExt.ux.data.Import = function(map, layer, format, filecontent, features) {
-    var importFeatures = [];
+    GeoExt.ux.data.Import.importFeatures = [];
 
     if (format && filecontent) {
         if (format == 'KML') {
             var kmlReader = new OpenLayers.Format.KML(GeoExt.ux.data.formats.getFormatConfig(format));
-            importFeatures = kmlReader.read(filecontent);
+            GeoExt.ux.data.importFeatures = kmlReader.read(filecontent);
         } else {
             return 'Format ' + format + ' not supported. Patch welcome !';
         }
     }
 
     if (features) {
-        importFeatures = features;
+        GeoExt.ux.data.importFeatures = features;
     }
     if (!layer) {
         layer = new OpenLayers.Layer.Vector("Import", {
@@ -32,7 +34,7 @@
         map.addLayer(layer);
     }
 
-    layer.addFeatures(importFeatures);
+    layer.addFeatures(GeoExt.ux.data.importFeatures);
 };
 
 GeoExt.ux.data.Import.KMLImport = function(map, layer) {
@@ -43,7 +45,7 @@
         layer: layer
     });
     importPanel.on('dataimported', function(panel, format, filecontent, features) {
-        alert(OpenLayers.i18n("KML data sucessfully imported in layer: " + panel.layer.name + " !"));
+        alert(OpenLayers.i18n("KML data sucessfully imported in layer: " + panel.layer.name + " !" + " Number of imported features: " + features.length));
         importWindow.close();
     });
     var importWindow = new Ext.Window({

Modified: sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerImportPanel.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerImportPanel.js	2009-12-31 12:35:48 UTC (rev 1638)
+++ sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerImportPanel.js	2009-12-31 16:53:26 UTC (rev 1639)
@@ -117,12 +117,12 @@
                                             if (objFSO.FileExists(document.getElementById('fileselector').value)) {
                                                 filecontent = objFSO.OpenTextFile(document.getElementById('fileselector').value, 1).ReadAll();
                                             }
-                                            GeoExt.ux.data.Import(this.map,this.layer,this.formatCombo.getValue(),filecontent,null);
-                                            this.fireEvent('dataimported', this, this.formatCombo.getValue(), filecontent,null);
+                                            GeoExt.ux.data.Import(this.map, this.layer, this.formatCombo.getValue(), filecontent, null);
+                                            this.fireEvent('dataimported', this, this.formatCombo.getValue(), filecontent, GeoExt.ux.data.importFeatures);
                                         } else if (Ext.isGecko) {
                                             filecontent = document.getElementById('fileselector').files.item(0).getAsText('UTF-8');
-                                            GeoExt.ux.data.Import(this.map,this.layer,this.formatCombo.getValue(),filecontent,null);
-                                            this.fireEvent('dataimported', this, this.formatCombo.getValue(), filecontent,null);                                            
+                                            GeoExt.ux.data.Import(this.map, this.layer, this.formatCombo.getValue(), filecontent, null);
+                                            this.fireEvent('dataimported', this, this.formatCombo.getValue(), filecontent, GeoExt.ux.data.importFeatures);
                                         } else {
                                             alert('Your browser is not supported. Patch welcome !');
                                         }
@@ -136,7 +136,18 @@
                 ]
             }
         ];
-        this.addEvents('dataimported');
+        this.addEvents(
+            /** api: event[dataimported]
+             *  Fires after data have been imported
+             *
+             *  Listener arguments:
+             *  * comp - :class:`GeoExt.ux.LayerManagerImportPanel`` This component.
+             *  * format - import format
+             *  * filecontent - content of the imported file
+             *  * features - imported features
+             *  *
+             */
+                'dataimported');
         GeoExt.ux.LayerManagerImportPanel.superclass.initComponent.call(this);
     },
     onRender: function(container, position) {



More information about the Commits mailing list