[Commits] r1718 - in sandbox/redlining/ux/FeatureEditing/ux/widgets: . form

commits at geoext.org commits at geoext.org
Tue Jan 12 15:24:53 CET 2010


Author: adube
Date: 2010-01-12 15:24:53 +0100 (Tue, 12 Jan 2010)
New Revision: 1718

Added:
   sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js
Modified:
   sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js
   sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js
Log:
RedLiningPanel now extends FeatureEditingPanel

Modified: sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js	2010-01-12 11:52:32 UTC (rev 1717)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js	2010-01-12 14:24:53 UTC (rev 1718)
@@ -86,6 +86,16 @@
         }
     },
 
+    /** private: method[addLayers]
+     *  :param layers: ``Array(OpenLayers.Layer.Vector)``
+     *  For each layers, add them with the addLayer method.
+     */
+    addLayers: function(layers) {
+        for(var i=0; i<layers.length; i++) {
+            this.addLayer(layers[i]);
+        }
+    },
+
     /** private: method[addLayer]
      *  :param layer: ``OpenLayers.Layer.Vector``
      *  Add layer to the map object, to this layers array and register some

Added: sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js	                        (rev 0)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js	2010-01-12 14:24:53 UTC (rev 1718)
@@ -0,0 +1,172 @@
+/** api: (define)
+ *  module = GeoExt.ux.form
+ *  class = FeatureEditingPanel
+ *  base_link = `Ext.form.FormPanel <http://extjs.com/deploy/dev/docs/?class=Ext.form.FormPanel>`_
+ */
+Ext.namespace("GeoExt.ux.form");
+
+/** api: example
+ *  Sample code to create a FeatureEditingPanel object
+ * 
+ *  .. code-block:: javascript
+ *     
+ *      var featureEditingPanel = new GeoExt.ux.form.FeatureEditingPanel({
+ *          title: "RedLining Panel"
+ *          map: map
+ *          layers: [new OpenLayers.Layer.Vector("Cosmetic")]
+ *      });
+ */
+
+/** api: constructor
+ *  .. class:: FeatureEditingPanel
+ * 
+ *  Create a FeatureEditingPanel automatically linked to a cosmetic vector layer
+ *  object.  Features created automatically have the "title" and "description"
+ *  attributes.
+ *
+ *  So it's a convenience object to quickly generate a RedLining complete tool
+ *  with all required controls and features.
+ */
+GeoExt.ux.form.FeatureEditingPanel = Ext.extend(Ext.form.FormPanel, {
+
+    /** api: config[labelWidth]
+     *  ``Number``  Default value.
+     */
+    labelWidth: 100,
+
+    /** api: config[border]
+     *  ``Boolean``  Default value.
+     */
+    border: false,
+
+    /** api: config[bodyStyle]
+     *  ``String``  Default value.
+     */
+    bodyStyle:'padding:5px 5px 5px 5px',
+
+    /** api: config[width]
+     *  ``Number``  Default value.
+     */
+    width: 300,
+
+    /** api: config[defaults]
+     *  ``Object``  Default value.
+     */
+    defaults: {width: 120},
+
+    /** api: config[defaultType]
+     *  ``String``  Default value.
+     */
+    defaultType: 'textfield',
+
+    /** api: property[map]
+     *  ``OpenLayers.Map``  A configured map object.
+     */
+    map: null,
+
+    /** api: property[map]
+     *  ``GeoExt.ux.FeatureEditingControler``
+     */
+    controler: null,
+
+    /** api: property[layers]
+     *  ``Array(OpenLayers.Layer.Vector)``
+     */
+    layers: null,
+    
+    /** private: method[initComponent]
+     */
+    initComponent: function() {
+        this.initMap();
+        this.initControler();
+        this.initLayers(this.layers);
+        this.initToolbar();
+        this.initForm();
+
+        GeoExt.ux.form.FeatureEditingPanel.superclass.initComponent.call(this);
+    },
+    
+    /** private: method[initMap]
+     *  Convenience method to make sure that the map object is correctly set.
+     */
+    initMap: function() {
+        if(this.map instanceof GeoExt.MapPanel) {
+            this.map = this.map.map;
+        }
+
+        if(!this.map) {
+            this.map = GeoExt.MapPanel.guess().map;
+        }
+    },
+
+    /** private: method[initControler]
+     *  Convenience method to make sure that the FeatureEditingControler has
+     *  been linked to this panel.
+     */
+    initControler: function() {
+        if(!this.controler){
+            this.controler = new GeoExt.ux.FeatureEditingControler({
+                map: this.map
+            });
+        }
+    },
+
+    /** private: method[initLayers]
+     *  :param layers: ``Array(OpenLayers.Layer.Vector)``
+     *  Add the layers to the controler and the first one as active.
+     */
+    initLayers: function(layers) {
+        if(layers instanceof Array) {
+            this.layers = layers;
+        } else {
+            this.layers = [layers];
+        }
+
+        this.controler.addLayers(this.layers);
+        this.controler.setActiveLayer(this.layers[0]);
+    },
+
+    /** private: method[initToolbar]
+     *  Initialize the controls of the controler and create a toolbar from the
+     *  actions created.
+     */
+    initToolbar: function() {
+        this.controler.initDrawControls();
+        this.controler.initFeatureControl();
+        this.controler.initDeleteAllAction();
+
+        // Add buttons and toolbar
+        Ext.apply(this, {tbar: new Ext.Toolbar(this.controler.actions)});
+    },
+
+    /** private: method[initForm]
+     *  Create field options and link them to the controler controls and actions
+     */
+    initForm: function() {
+        oItems = [];
+        oItems.push({
+              id: "testid",
+                    fieldLabel: "myOption",
+                    maxLength: 50,
+                    xtype: "checkbox"
+                });
+
+        Ext.apply(this, {items: oItems});
+    },
+    
+    /** private: method[beforeDestroy]
+     */
+    beforeDestroy: function() {
+        if(!this.initialConfig.layers) {
+            for(var i=0; i<layers.length; i++) {
+                this.layers[i].destroy();
+            }
+        }
+        delete this.controler;
+        delete this.map;
+    }
+    
+});
+
+/** api: xtype = gx_featureform */
+Ext.reg("gx_featureeditingpanel", GeoExt.ux.form.FeatureEditingPanel);


Property changes on: sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js	2010-01-12 11:52:32 UTC (rev 1717)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js	2010-01-12 14:24:53 UTC (rev 1718)
@@ -1,16 +1,10 @@
 /** api: (define)
  *  module = GeoExt.ux.form
  *  class = RedLiningPanel
- *  base_link = `Ext.form.FormPanel <http://extjs.com/deploy/dev/docs/?class=Ext.form.FormPanel>`_
+ *  base_link = `GeoExt.ux.form.FeatureEditingPanel <>`_
  */
 Ext.namespace("GeoExt.ux.form");
 
-/** api: (define)
- *  module = GeoExt.ux.form
- *  class = RedLiningPanel
- *  base_link = `Ext.form.FormPanel <http://extjs.com/deploy/dev/docs/?class=Ext.form.FormPanel>`_
- */
-
 /** api: example
  *  Sample code to create a RedLiningPanel object
  * 
@@ -32,137 +26,14 @@
  *  So it's a convenience object to quickly generate a RedLining complete tool
  *  with all required controls and features.
  */
-GeoExt.ux.form.RedLiningPanel = Ext.extend(Ext.form.FormPanel, {
-
-    /** api: config[labelWidth]
-     *  ``Number``  Default value.
-     */
-    labelWidth: 100,
-
-    /** api: config[border]
-     *  ``Boolean``  Default value.
-     */
-    border: false,
-
-    /** api: config[bodyStyle]
-     *  ``String``  Default value.
-     */
-    bodyStyle:'padding:5px 5px 5px 5px',
-
-    /** api: config[width]
-     *  ``Number``  Default value.
-     */
-    width: 300,
-
-    /** api: config[defaults]
-     *  ``Object``  Default value.
-     */
-    defaults: {width: 120},
-
-    /** api: config[defaultType]
-     *  ``String``  Default value.
-     */
-    defaultType: 'textfield',
-
-    /** api: property[map]
-     *  ``OpenLayers.Map``  A configured map object.
-     */
-    map: null,
-
-    /** api: property[map]
-     *  ``GeoExt.ux.FeatureEditingControler``
-     */
-    controler: null,
-
-    /** api: property[layer]
-     *  ``OpenLayers.Layer.Vector``
-     */
-    layer: null,
+GeoExt.ux.form.RedLiningPanel = Ext.extend(GeoExt.ux.form.FeatureEditingPanel, {
     
     /** private: method[initComponent]
      */
     initComponent: function() {
-        this.initMap();
-        this.initControler();
-        this.initLayer();
-        this.initToolbar();
-        this.initForm();
+        this.layers = this.layers || new OpenLayers.Layer.Vector("Cosmetic");
 
         GeoExt.ux.form.RedLiningPanel.superclass.initComponent.call(this);
-    },
-    
-    /** private: method[initMap]
-     *  Convenience method to make sure that the map object is correctly set.
-     */
-    initMap: function() {
-        if(this.map instanceof GeoExt.MapPanel) {
-            this.map = this.map.map;
-        }
-
-        if(!this.map) {
-            this.map = GeoExt.MapPanel.guess().map;
-        }
-    },
-
-    /** private: method[initControler]
-     *  Convenience method to make sure that the FeatureEditingControler has
-     *  been linked to this panel.
-     */
-    initControler: function() {
-        if(!this.controler){
-            this.controler = new GeoExt.ux.FeatureEditingControler({
-                map: this.map
-            });
-        }
-    },
-
-    /** private: method[initLayer]
-     *  Link the cosmetic vector layer to the controler.  If none was provided,
-     *  create one first.
-     */
-    initLayer: function() {
-        var layer = this.layer || new OpenLayers.Layer.Vector("cosmetic");
-        this.controler.addLayer(layer);
-        this.controler.setActiveLayer(layer);
-        this.layer = layer;
-    },
-
-    /** private: method[initToolbar]
-     *  Initialize the controls of the controler and create a toolbar from the
-     *  actions created.
-     */
-    initToolbar: function() {
-        this.controler.initDrawControls();
-        this.controler.initFeatureControl();
-        this.controler.initDeleteAllAction();
-
-        // Add buttons and toolbar
-        Ext.apply(this, {tbar: new Ext.Toolbar(this.controler.actions)});
-    },
-
-    /** private: method[initForm]
-     *  Create field options and link them to the controler controls and actions
-     */
-    initForm: function() {
-        oItems = [];
-        oItems.push({
-              id: "testid",
-                    fieldLabel: "myOption",
-                    maxLength: 50,
-                    xtype: "checkbox"
-                });
-
-        Ext.apply(this, {items: oItems});
-    },
-    
-    /** private: method[beforeDestroy]
-     */
-    beforeDestroy: function() {
-        if(!this.initialConfig.layer) {
-            this.layer.destroy();
-        }
-        delete this.controler;
-        delete this.map;
     }
     
 });



More information about the Commits mailing list