[Commits] r1569 - in sandbox/cmoullet/ux/Redlining: examples ux/control

commits at geoext.org commits at geoext.org
Tue Dec 8 13:24:31 CET 2009


Author: cmoullet
Date: 2009-12-08 13:24:31 +0100 (Tue, 08 Dec 2009)
New Revision: 1569

Added:
   sandbox/cmoullet/ux/Redlining/ux/control/RedliningControl.js
Modified:
   sandbox/cmoullet/ux/Redlining/examples/RedliningExample.html
   sandbox/cmoullet/ux/Redlining/examples/RedliningExample.js
   sandbox/cmoullet/ux/Redlining/ux/control/RedliningPolygonControl.js
Log:
Architecture try

Modified: sandbox/cmoullet/ux/Redlining/examples/RedliningExample.html
===================================================================
--- sandbox/cmoullet/ux/Redlining/examples/RedliningExample.html	2009-12-08 06:33:45 UTC (rev 1568)
+++ sandbox/cmoullet/ux/Redlining/examples/RedliningExample.html	2009-12-08 12:24:31 UTC (rev 1569)
@@ -6,6 +6,7 @@
     <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/examples/shared/examples.css"/>
     <script src="http://openlayers.org/api/2.8/OpenLayers.js"></script>
     <script type="text/javascript" src="../../../trunk/geoext/lib/GeoExt.js"></script>
+    <script type="text/javascript" src="../ux/control/RedliningControl.js"></script>
     <script type="text/javascript" src="../ux/control/RedliningPolygonControl.js"></script>
     <script type="text/javascript" src="RedliningExample.js"></script>
 

Modified: sandbox/cmoullet/ux/Redlining/examples/RedliningExample.js
===================================================================
--- sandbox/cmoullet/ux/Redlining/examples/RedliningExample.js	2009-12-08 06:33:45 UTC (rev 1568)
+++ sandbox/cmoullet/ux/Redlining/examples/RedliningExample.js	2009-12-08 12:24:31 UTC (rev 1569)
@@ -6,6 +6,8 @@
 
 var layer;
 
+var redliningPolygonControl
+
 Ext.onReady(function() {
 
     var bluemarble = new OpenLayers.Layer.WMS(
@@ -28,33 +30,42 @@
 
     var redliningLayer = new OpenLayers.Layer.Vector("redliningLayer");
     map.addLayers([redliningLayer]);
-    
+
+    redliningPolygonControl = new GeoExt.ux.RedliningPolygonControl({
+            layer: redliningLayer,
+            map: map
+        });
+
     var action = new GeoExt.Action({
-        text: "Draw Polygon",
-        control: new GeoExt.ux.RedliningPolygonControl(
-                redliningLayer,
-                OpenLayers.Handler.Polygon,
-        {
-            map: map
-        }
-                ),
+        text: "Polygon Editing",
+        control: redliningPolygonControl,
         map: map,
-        toggleGroup: "draw",
+        toggleGroup: "editing",
         allowDepress: true,
-        tooltip: "draw polygon",
-        group: "draw"
+        tooltip: "Polygon Editing",
+        group: "editing"
     });
     toolbar.push(action);
 
     toolbar.push({
+        text: 'Save As KML',
+        enableToggle: false,
+        handler: function() {
+            redliningPolygonControl.saveFile('kml');
+        }
+    });
+    
+    toolbar.push({
         text: 'Permalink',
-                enableToggle: false,
-                handler: function() {
-                    alert('TODO not implemented')
-                }
+        enableToggle: false,
+        handler: function() {
+             alert("TODO: not implemented");
+        }
     });
 
 
+
+
     var mapStore = new GeoExt.data.LayerStore({
         map: map,
         layers: [bluemarble]

Added: sandbox/cmoullet/ux/Redlining/ux/control/RedliningControl.js
===================================================================
--- sandbox/cmoullet/ux/Redlining/ux/control/RedliningControl.js	                        (rev 0)
+++ sandbox/cmoullet/ux/Redlining/ux/control/RedliningControl.js	2009-12-08 12:24:31 UTC (rev 1569)
@@ -0,0 +1,80 @@
+/**
+ * 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.
+ */
+
+Ext.namespace('GeoExt.ux');
+
+GeoExt.ux.RedliningControl = OpenLayers.Class(OpenLayers.Control, {
+    drawControl: null,
+
+    modifyControl: null,
+
+    initialize: function(options) {
+        OpenLayers.Control.prototype.initialize.apply(this, arguments);
+        this.layer.events.on({
+            "beforefeaturemodified": function(event) {
+                console.log(event.type + " Show edition popup " + event.feature.id);
+            },
+            "featuremodified": function(event) {
+            },
+            "afterfeaturemodified": function(event) {
+            },
+            "vertexmodified": function(event) {
+            },
+            "sketchmodified": function(event) {
+            },
+            "sketchstarted": function(event) {
+            },
+            "sketchcomplete": function(event, feature) {
+            }
+        });
+        // Create the modify feature control
+        this.modifyControl = new OpenLayers.Control.ModifyFeature(this.layer);
+        this.map.addControl(this.modifyControl);
+        this.modifyControl.events.on({
+            "featureadded": function(event) {
+            },
+            "activate": function(event) {
+            },
+            "deactivate": function(event) {
+            }
+        });
+        this.modifyControl.selectControl.events.on({
+            "beforefeaturehighlighted": function(event) {
+            },
+            "featurehighlighted": function(event) {
+            },
+            "featureunhighlighted": function(event) {
+            }
+        })
+    },
+
+    activate: function () {
+        this.drawControl.activate();
+        this.modifyControl.activate();
+        return OpenLayers.Control.prototype.activate.apply(
+                this, arguments
+                );
+    },
+    deactivate: function () {
+        this.drawControl.deactivate();
+        this.modifyControl.deactivate();
+        return OpenLayers.Control.prototype.deactivate.apply(
+                this, arguments
+                );
+    },
+    saveFile: function(format) {
+        if (format == 'kml') {
+            var kml = new OpenLayers.Format.KML();
+            var kmlString = kml.write(this.layer.features);
+            alert(kmlString);
+        }
+    },
+    loadFile: function(file) {
+        alert('TODO not implemented');
+    }
+});
\ No newline at end of file

Modified: sandbox/cmoullet/ux/Redlining/ux/control/RedliningPolygonControl.js
===================================================================
--- sandbox/cmoullet/ux/Redlining/ux/control/RedliningPolygonControl.js	2009-12-08 06:33:45 UTC (rev 1568)
+++ sandbox/cmoullet/ux/Redlining/ux/control/RedliningPolygonControl.js	2009-12-08 12:24:31 UTC (rev 1569)
@@ -8,36 +8,35 @@
 
 Ext.namespace('GeoExt.ux');
 
-GeoExt.ux.RedliningPolygonControl = OpenLayers.Class(OpenLayers.Control.DrawFeature, {
+GeoExt.ux.RedliningPolygonControl = OpenLayers.Class(GeoExt.ux.RedliningControl, {
 
-    map: null,
-    highlightCtrl: null,
-    selectCtrl: null,
-    modifyCtrl: null,
-
     initialize: function(options) {
-        OpenLayers.Control.DrawFeature.prototype.initialize.apply(this, arguments);
-        // Highlight the feature onHover
-        this.highlightCtrl = new OpenLayers.Control.SelectFeature(this.layer, {
-            hover: true,
-            highlightOnly: true
-        });
+        GeoExt.ux.RedliningControl.prototype.initialize.apply(this, arguments);
 
-        // Select the feature
-        this.selectCtrl = new OpenLayers.Control.SelectFeature(this.layer, {
-            clickout: true
+        // Create the draw control
+        this.drawControl = new OpenLayers.Control.DrawFeature(this.layer,
+                OpenLayers.Handler.Polygon);
+        this.map.addControl(this.drawControl);
+        this.drawControl.events.on({
+            featureadded: function(event) {
+            },
+            activate: function(event) {
+            },
+            deactivate: function(event) {
+            }
         });
-        
-        // Modifiy the feature
-        this.modifyCtrl = new OpenLayers.Control.ModifyFeature(this.layer, {
-            clickout: true
-        });
-        this.map.addControl(this.highlightCtrl);
-        this.map.addControl(this.selectCtrl);
-        this.map.addControl(this.modifyCtrl);
+    },
 
-        this.highlightCtrl.activate();
-        this.selectCtrl.activate();
-        this.modifyCtrl.activate();
+    activate: function () {
+        this.drawControl.activate();
+        return GeoExt.ux.RedliningControl.prototype.activate.apply(
+                this, arguments
+                );
+    },
+    deactivate: function () {
+        this.drawControl.deactivate();
+        return GeoExt.ux.RedliningControl.prototype.deactivate.apply(
+                this, arguments
+                );
     }
 });
\ No newline at end of file



More information about the Commits mailing list