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

commits at geoext.org commits at geoext.org
Fri Jan 8 21:55:44 CET 2010


Author: adube
Date: 2010-01-08 21:55:44 +0100 (Fri, 08 Jan 2010)
New Revision: 1676

Modified:
   sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js
   sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js
Log:
comments added

Modified: sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js	2010-01-08 19:17:21 UTC (rev 1675)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/FeatureEditingControler.js	2010-01-08 20:55:44 UTC (rev 1676)
@@ -1,23 +1,63 @@
+/** api: (define)
+ *  module = GeoExt.ux
+ *  class = FeatureEditingControler
+ *  base_link = `Ext.util.Observable <http://extjs.com/deploy/dev/docs/?class=Ext.util.Observable>`_
+ */
 Ext.namespace("GeoExt.ux");
 
+/** api: constructor
+ *  .. class:: FeatureEditingControler(config)
+ *   
+ *      Create a FeatureEditing main controler.
+ */
 GeoExt.ux.FeatureEditingControler = Ext.extend(Ext.util.Observable, {
-    
+
+    /** api: property[map]
+     *  ``OpenLayers.Map``  A configured map object.
+     */
     map: null,
 
-    featureStore: null,
-
+    /** api: config[drawControls]
+     *  ``Array(OpenLayers.Control.DrawFeature)``
+     *  An array of DrawFeature controls automatically created from the current
+     *  activeLayer
+     */
     drawControls: null,
 
+    /** api: config[deleteAllAction]
+     *  ``Ext.Action``  
+     *  The action created to delete all features.
+     */
     deleteAllAction: null,
 
+    /** api: config[actions]
+     *  ``Array(GeoExt.Action or Ext.Action)``
+     *  An array of actions created from various controls or tasks that are to
+     *  be added to a toolbar.
+     */
     actions: null,
 
+    /** api: config[featureControl]
+     *  ``OpenLayers.Control.ModifyFeature or OpenLayers.Control.SelectFeature``
+     *  The OpenLayers control responsible of selecting the feature by clicks
+     *  on the screen and, optionnaly, edit feature geometry.
+     */
     featureControl: null,
 
+    /** api: config[layers]
+     *  ``Array(OpenLayers.Layer.Vector)``
+     *  An array of OpenLayers.Layer.Vector objects
+     */
     layers: null,
 
+    /** api: config[activeLayer]
+     *  ``OpenLayers.Layer.Vector``  The current layer being edited.
+     */    
     activeLayer: null,
-    
+
+    /** private: method[constructor]
+     *  Private constructor override.
+     */    
     constructor: function(config) {
         Ext.apply(this, config);
 
@@ -46,6 +86,11 @@
         }
     },
 
+    /** private: method[addLayer]
+     *  :param layer: ``OpenLayers.Layer.Vector``
+     *  Add layer to the map object, to this layers array and register some
+     *  events for feature modification.
+     */
     addLayer: function(layer) {
         if(!layer.map) {
             this.map.addLayer(layer);
@@ -70,11 +115,20 @@
         });
     },
 
+    /** private: method[setActiveLayer]
+     *  :param layer: ``OpenLayers.Layer.Vector``
+     *  Change activeLayer to this layer.
+     */
     setActiveLayer: function(layer) {
         this.activeLayer = layer;
         this.fireEvent("activelayerchanged", this, layer);
     },
 
+    /** private: method[initFeatureControl]
+     *  Create a ModifyFeature control linked to the current activeLayer and
+     *  add it to the map.  An GeoExt.Action is also created and pushed to the
+     *  actions array.
+     */
     initFeatureControl: function() {
         var layer, control, options;
 
@@ -105,9 +159,17 @@
         this.actions.push(action);
     },
 
+    /** private: method[destroyFeatureControl]
+     *  Destroy the current featureControl and all related objects.
+     */
     destroyFeatureControl: function() {
     },
 
+    /** private: method[initDrawControls]
+     *  Create DrawFeature controls linked to the current activeLayer and 
+     *  depending on its geometryType property and add them to the map.
+     *  GeoExt.Action are also created and pushed to the actions array.
+     */
     initDrawControls: function() {
         var layer, control, handler, geometryTypes, geometryType,
             options, action, iconCls;
@@ -176,6 +238,9 @@
         }
     },
 
+    /** private: method[destroyDrawControls]
+     *  Destroy all drawControls and all their related objects.
+     */
     destroyDrawControls: function() {
         for(var i=0; i<this.drawControls.length; i++) {
             this.drawControls[i].destroy();
@@ -183,6 +248,10 @@
         this.drawControls = [];
     },
 
+    /** private: method[initDeleteAllAction]
+     *  Create a Ext.Action object that is set as the deleteAllAction property
+     *  and pushed to te actions array.
+     */
     initDeleteAllAction: function() {
         var action = new Ext.Action({
             text:'DeleteAll',
@@ -194,12 +263,21 @@
         this.actions.push(action);
     },
 
+   /** private: method[deleteAllFeatures]
+     *  Called when the deleteAllAction is triggered (button pressed).  
+     *  Destroy all features from all layers.
+     */
     deleteAllFeatures: function() {
         for(var i=0; i<this.layers.length; i++) {
             this.layers[i].destroyFeatures();
         }
     },
 
+    /** private: method[getSelectControl]
+     *  :return: ``OpenLayers.Control.Select``
+     *  Convenience method to return the SelectFeature control from
+     *  this.featureControl object.
+     */
     getSelectControl: function() {
         var control = false;
 
@@ -216,6 +294,11 @@
         return control;
     },
 
+    /** private: method[getActiveDrawControl]
+     *  :return: ``OpenLayers.Control.DrawFeature or false``
+     *  Get the current active DrawFeature control.  If none is active, false
+     *  is returned.
+     */
     getActiveDrawControl: function() {
         var control = false;
 
@@ -229,6 +312,11 @@
         return control;
     },
 
+    /** private: method[onFeatureAdded]
+     *  :param event: ``event``
+     *  Called when a new feature is added to the activeLayer.  Change the state
+     *  of the feature to INSERT and select it.
+     */
     onFeatureAdded: function(event) {
         var feature, drawControl;
 
@@ -245,8 +333,13 @@
         this.getSelectControl().select(feature);
     },
 
-    onModificationStart: function(object) {
-        var feature = (object.geometry) ? object : object.feature;
+    /** private: method[onModificationStart]
+     *  :param event: ``event``
+     *  Called when a feature is selected.  Display a popup that contains the
+     *  FeaturePanel.
+     */
+    onModificationStart: function(event) {
+        var feature = (event.geometry) ? event : event.feature;
 
         // to keep the state before any modification, useful when hitting the
         // 'cancel' button
@@ -277,18 +370,28 @@
 
     },
 
-    onModification: function(object) {
+    /** private: method[onModification]
+     *  :param event: ``event``
+     */
+    onModification: function(event) {
+        var feature = (event.geometry) ? event : event.feature;
         //we could execute commits here
     },
 
-    onModificationEnd: function(object) {
-        var feature = (object.geometry) ? object : object.feature;
-
+    /** private: method[onModificationEnd]
+     *  :param event: ``event``
+     */
+    onModificationEnd: function(event) {
+        var feature = (event.geometry) ? event : event.feature;
         // or we could execute commits here also
     },
 
-    onFeatureUnselect: function(object) {
-        var feature = (object.geometry) ? object : object.feature;
+    /** private: method[onModificationEnd]
+     *  :param event: ``event``
+     *  Close the popup linked to a feature if any.
+     */
+    onFeatureUnselect: function(event) {
+        var feature = (event.geometry) ? event : event.feature;
 
         if(feature.popup){
             feature.popup.close();

Modified: sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js	2010-01-08 19:17:21 UTC (rev 1675)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js	2010-01-08 20:55:44 UTC (rev 1676)
@@ -1,9 +1,7 @@
-/**
- * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
- * 
- * Published under the BSD license.
- * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
- * of the license.
+/** api: (define)
+ *  module = GeoExt.ux.form
+ *  class = RedLiningPanel
+ *  base_link = `Ext.form.FormPanel <http://extjs.com/deploy/dev/docs/?class=Ext.form.FormPanel>`_
  */
 Ext.namespace("GeoExt.ux.form");
 
@@ -13,24 +11,72 @@
  *  base_link = `Ext.form.FormPanel <http://extjs.com/deploy/dev/docs/?class=Ext.form.FormPanel>`_
  */
 
+/** api: example
+ *  Sample code to create a RedLiningPanel object
+ * 
+ *  .. code-block:: javascript
+ *     
+ *      var redLiningPanel = new GeoExt.ux.form.RedLiningPanel({
+ *          title: "RedLining Panel"
+ *          map: map
+ *      });
+ */
+
 /** api: constructor
  *  .. class:: RedLiningPanel
  * 
- *  Todo
+ *  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.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,
     
     /** private: method[initComponent]
@@ -46,6 +92,7 @@
     },
     
     /** private: method[initMap]
+     *  Convenience method to make sure that the map object is correctly set.
      */
     initMap: function() {
         if(this.map instanceof GeoExt.MapPanel) {
@@ -58,6 +105,8 @@
     },
 
     /** private: method[initControler]
+     *  Convenience method to make sure that the FeatureEditingControler has
+     *  been linked to this panel.
      */
     initControler: function() {
         if(!this.controler){
@@ -68,6 +117,8 @@
     },
 
     /** 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");
@@ -77,6 +128,8 @@
     },
 
     /** private: method[initToolbar]
+     *  Initialize the controls of the controler and create a toolbar from the
+     *  actions created.
      */
     initToolbar: function() {
         this.controler.initDrawControls();
@@ -97,6 +150,7 @@
     },
 
     /** private: method[initForm]
+     *  Create field options and link them to the controler controls and actions
      */
     initForm: function() {
         oItems = [];



More information about the Commits mailing list