diff --git a/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/control/DeleteFeature.java b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/control/DeleteFeature.java new file mode 100644 index 00000000..330eede6 --- /dev/null +++ b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/control/DeleteFeature.java @@ -0,0 +1,25 @@ +package org.gwtopenmaps.openlayers.client.control; + +import org.gwtopenmaps.openlayers.client.control.Control; +import org.gwtopenmaps.openlayers.client.layer.Vector; +import org.gwtopenmaps.openlayers.client.util.JSObject; + +/** + * + * @author Maciej Jezierski - Pinocchio + * Download plugin OpenLayers.Control.DeleteFeature from internet + * or use plugin from repository + * + */ +public class DeleteFeature extends Control { + + public DeleteFeature(JSObject element) { + super(element); + } + + public DeleteFeature(Vector vector) { + this(DeleteFeatureImpl.create(vector.getJSObject())); + } + +} + diff --git a/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/control/DeleteFeatureImpl.java b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/control/DeleteFeatureImpl.java new file mode 100644 index 00000000..f98cbb3b --- /dev/null +++ b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/control/DeleteFeatureImpl.java @@ -0,0 +1,9 @@ +package org.gwtopenmaps.openlayers.client.control; + +import org.gwtopenmaps.openlayers.client.util.JSObject; + +public class DeleteFeatureImpl { + public native static JSObject create(JSObject vector) /*-{ + return new $wnd.OpenLayers.Control.DeleteFeature(vector); + }-*/; +} diff --git a/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/control/NavigationHistory.java b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/control/NavigationHistory.java new file mode 100644 index 00000000..1eb6ac83 --- /dev/null +++ b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/control/NavigationHistory.java @@ -0,0 +1,71 @@ +package org.gwtopenmaps.openlayers.client.control; + +import org.gwtopenmaps.openlayers.client.control.Control; +import org.gwtopenmaps.openlayers.client.util.JSObject; + +/** + * + * @author Maciej Jezierski - Pinocchio + * + */ +public class NavigationHistory extends Control { + + public NavigationHistory(JSObject element) { + super(element); + } + + public NavigationHistory() { + this(NavigationHistoryImpl.create()); + } + + /** + * Switch map view to a previous step in browser's history. + * + */ + public void previous() { + NavigationHistoryImpl.previous(this.getJSObject()); + } + /** + * Switch map view to next step in browser's history. + * + */ + public void next() { + NavigationHistoryImpl.next(this.getJSObject()); + } + + /** + * Optional limit on the number of history items to retain. + * If null, there is no limit. Default is 50. + * + * @param limit - number of items + * @return void + */ + public void limit(int limit) { + NavigationHistoryImpl.limit(this.getJSObject(), limit); + } + + /** + * Activate the control when it is added to a map. + * Default is true. If set to false, activate() method must + * be fired in order to use the control with map. + * + * @param autoActivate - set automatic activation true or false + * @return void + */ + public void autoActivate(boolean autoActivate) { + NavigationHistoryImpl.autoActivate(this.getJSObject(), autoActivate); + } + + /** + * Restore the next state. If no items are in the next history + * stack, this has no effect. The next history stack is populated + * as states are restored from the previous history stack. + * + * + * @param void + * @return JSObject - Item representing state that was restored. Undefined if no items are in the next history stack. + */ + public JSObject nextTrigger() { + return NavigationHistoryImpl.nextTrigger(this.getJSObject()); + } +} \ No newline at end of file diff --git a/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/control/NavigationHistoryImpl.java b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/control/NavigationHistoryImpl.java new file mode 100644 index 00000000..6d0aae5d --- /dev/null +++ b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/control/NavigationHistoryImpl.java @@ -0,0 +1,29 @@ +package org.gwtopenmaps.openlayers.client.control; + +import org.gwtopenmaps.openlayers.client.util.JSObject; + +public class NavigationHistoryImpl { + public native static JSObject create() /*-{ + return new $wnd.OpenLayers.Control.NavigationHistory(); + }-*/; + + public native static void previous(JSObject self) /*-{ + self.previous.trigger(); + }-*/; + + public native static void next(JSObject self) /*-{ + self.next.trigger(); + }-*/; + + public native static void limit(JSObject self, int limit) /*-{ + self.limit = limit; + }-*/; + + public native static void autoActivate(JSObject self, boolean autoActivate) /*-{ + self.autoActivate = autoActivate; + }-*/; + + public native static JSObject nextTrigger(JSObject self) /*-{ + return self.nextTrigger(); + }-*/; +} \ No newline at end of file diff --git a/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/FixedStrategy.java b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/FixedStrategy.java new file mode 100644 index 00000000..4fd29dd1 --- /dev/null +++ b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/FixedStrategy.java @@ -0,0 +1,45 @@ +package org.gwtopenmaps.openlayers.client.strategy; + +import org.gwtopenmaps.openlayers.client.strategy.Strategy; +import org.gwtopenmaps.openlayers.client.util.JSObject; + +/** + * + * @author Maciej Jezierski - Pinocchio + * A simple strategy that requests features once and never requests new data + * + */ +public class FixedStrategy extends Strategy{ + + /** + * Clean up the strategy. + */ + public void destroy() { + FixedStrategyImpl.destroy(this.getJSObject()); + } + + /** + * Load data before layer made visible. Enabling this may result in considerable overhead if your application loads many data layers that are not visible by default. Default is false. + * @param preload + */ + public void preload(boolean preload) { + FixedStrategyImpl.preload(this.getJSObject(), preload); + } + + public FixedStrategy(JSObject strategy, boolean preload) { + super(strategy); + preload(preload); + } + + public FixedStrategy(JSObject strategy) { + super(strategy); + } + + public FixedStrategy(boolean preload) { + this(FixedStrategyImpl.create(), preload); + } + + public FixedStrategy() { + this(FixedStrategyImpl.create()); + } +} \ No newline at end of file diff --git a/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/FixedStrategyImpl.java b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/FixedStrategyImpl.java new file mode 100644 index 00000000..f68d56ba --- /dev/null +++ b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/FixedStrategyImpl.java @@ -0,0 +1,17 @@ +package org.gwtopenmaps.openlayers.client.strategy; + +import org.gwtopenmaps.openlayers.client.util.JSObject; + +public class FixedStrategyImpl { + public native static JSObject create() /*-{ + return new $wnd.OpenLayers.Strategy.Fixed(); + }-*/; + + public native static void preload(JSObject self, boolean load) /*-{ + self.preload(load); + }-*/; + + public native static void destroy(JSObject self) /*-{ + self.destroy(); + }-*/; +} \ No newline at end of file diff --git a/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/PagingStrategy.java b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/PagingStrategy.java new file mode 100644 index 00000000..44ca691b --- /dev/null +++ b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/PagingStrategy.java @@ -0,0 +1,51 @@ +package org.gwtopenmaps.openlayers.client.strategy; + +import org.gwtopenmaps.openlayers.client.util.JSObject; + +/** + * + * @author Maciej Jezierski - Pinocchio + * + */ +public class PagingStrategy extends Strategy { + + public boolean activate() { + return PagingStrategyImpl.activate(this.getJSObject()); + } + + public boolean deactivate() { + return PagingStrategyImpl.deactivate(this.getJSObject()); + } + + public int pageCount() { + return PagingStrategyImpl.pageCount(this.getJSObject()); + } + + public int pageNum() { + return PagingStrategyImpl.pageNum(this.getJSObject()); + } + + public int pageLength() { + return PagingStrategyImpl.pageLength(this.getJSObject()); + } + + public int pageLength(int length) { + return PagingStrategyImpl.pageLength(this.getJSObject(), length); + } + + public boolean pageNext() { + return PagingStrategyImpl.pageNext(this.getJSObject()); + } + + public boolean pagePrevious() { + return PagingStrategyImpl.pagePrevious(this.getJSObject()); + } + + public PagingStrategy(JSObject strategy) { + super(strategy); + } + + public PagingStrategy() { + this(PagingStrategyImpl.create()); + } +} diff --git a/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/PagingStrategyImpl.java b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/PagingStrategyImpl.java new file mode 100644 index 00000000..051ac04c --- /dev/null +++ b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/PagingStrategyImpl.java @@ -0,0 +1,42 @@ +package org.gwtopenmaps.openlayers.client.strategy; + +import org.gwtopenmaps.openlayers.client.util.JSObject; + +public class PagingStrategyImpl { + + public native static JSObject create() /*-{ + return $wnd.OpenLayers.Strategy.Paging(); + }-*/; + + public native static boolean activate(JSObject self) /*-{ + return self.activate(); + }-*/; + + public native static boolean deactivate(JSObject self) /*-{ + return self.deactivate(); + }-*/; + + public native static int pageCount(JSObject self) /*-{ + return self.pageCount(); + }-*/; + + public native static int pageNum(JSObject self) /*-{ + return self.pageNum(); + }-*/; + + public native static int pageLength(JSObject self) /*-{ + return self.pageLength(); + }-*/; + + public native static int pageLength(JSObject self, int length) /*-{ + return self.pageLength(length); + }-*/; + + public native static boolean pageNext(JSObject self) /*-{ + return self.pageNext(); + }-*/; + + public native static boolean pagePrevious(JSObject self) /*-{ + return self.pagePrevious(); + }-*/; +} diff --git a/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/RefreshStrategy.java b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/RefreshStrategy.java new file mode 100644 index 00000000..ab760571 --- /dev/null +++ b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/RefreshStrategy.java @@ -0,0 +1,31 @@ +package org.gwtopenmaps.openlayers.client.strategy; + +import org.gwtopenmaps.openlayers.client.util.JSObject; + +/** + * + * @author Maciej Jezierski - Pinocchio + * + */ +public class RefreshStrategy extends Strategy { + + public boolean activate() { + return RefreshStrategyImpl.activate(this.getJSObject()); + } + + public boolean deactivate() { + return RefreshStrategyImpl.deactivate(this.getJSObject()); + } + + public void refresh() { + RefreshStrategyImpl.refresh(this.getJSObject()); + } + + public RefreshStrategy(JSObject strategy) { + super(strategy); + } + + public RefreshStrategy() { + this(RefreshStrategyImpl.create()); + } +} diff --git a/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/RefreshStrategyImpl.java b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/RefreshStrategyImpl.java new file mode 100644 index 00000000..24525b39 --- /dev/null +++ b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/RefreshStrategyImpl.java @@ -0,0 +1,22 @@ +package org.gwtopenmaps.openlayers.client.strategy; + +import org.gwtopenmaps.openlayers.client.util.JSObject; + +public class RefreshStrategyImpl { + + public native static JSObject create() /*-{ + return $wnd.OpenLayers.Strategy.Refresh(); + }-*/; + + public native static boolean activate(JSObject self) /*-{ + return self.activate(); + }-*/; + + public native static boolean deactivate(JSObject self) /*-{ + return self.deactivate(); + }-*/; + + public native static void refresh(JSObject self) /*-{ + self.refresh(); + }-*/; +} diff --git a/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/SaveStrategy.java b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/SaveStrategy.java new file mode 100644 index 00000000..82e7178d --- /dev/null +++ b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/SaveStrategy.java @@ -0,0 +1,58 @@ +package org.gwtopenmaps.openlayers.client.strategy; + +import org.gwtopenmaps.openlayers.client.util.JSObject; + +/** + * + * @author Maciej Jezierski - Pinocchio + * + */ +public class SaveStrategy extends Strategy { + + public boolean activate() { + return SaveStrategyImpl.activate(this.getJSObject()); + } + + public boolean deactivate() { + return SaveStrategyImpl.deactivate(this.getJSObject()); + } + + /** + * Feature will be saved immediately after being added to the layer and with each modification or deletion + * @param enable + */ + public void setAuto(boolean enable) { + SaveStrategyImpl.setAuto(this.getJSObject(), enable); + } + + /** + * Features will be saved on an interval provided by the value (in seconds) + * @param interval + */ + public void setAuto(int interval) { + SaveStrategyImpl.setAuto(this.getJSObject(), interval); + } + + /** + * Tell the layer protocol to commit unsaved features. If the layer projection differs from the map projection, features will be transformed into the layer projection before being committed + */ + public void save() { + SaveStrategyImpl.save(this.getJSObject()); + } + + /** + * Tell the layer protocol which features should be saved + * @param array array of VectorFeatures + */ + public void save(JSObject array) { + SaveStrategyImpl.save(this.getJSObject(), array); + } + + public SaveStrategy() { + this(SaveStrategyImpl.create()); + } + + public SaveStrategy(JSObject strategy) { + super(strategy); + } +} diff --git a/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/SaveStrategyImpl.java b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/SaveStrategyImpl.java new file mode 100644 index 00000000..737de444 --- /dev/null +++ b/gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/strategy/SaveStrategyImpl.java @@ -0,0 +1,34 @@ +package org.gwtopenmaps.openlayers.client.strategy; + +import org.gwtopenmaps.openlayers.client.util.JSObject; + +public class SaveStrategyImpl { + + public native static boolean activate(JSObject self) /*-{ + return self.activate(); + }-*/; + + public native static boolean deactivate(JSObject self) /*-{ + return self.activate(); + }-*/; + + public native static void setAuto(JSObject self, boolean enable) /*-{ + self.auto = enable; + }-*/; + + public native static void setAuto(JSObject self, int interval) /*-{ + self.auto = interval; + }-*/; + + public native static void save(JSObject self) /*-{ + self.save(); + }-*/; + + public native static void save(JSObject self, JSObject array) /*-{ + self.save(array); + }-*/; + + public native static JSObject create() /*-{ + return new $wnd.OpenLayers.Strategy.Save(); + }-*/; +} \ No newline at end of file diff --git a/openlayers/plugin/DeleteFeature.js b/openlayers/plugin/DeleteFeature.js new file mode 100644 index 00000000..2e8de29a --- /dev/null +++ b/openlayers/plugin/DeleteFeature.js @@ -0,0 +1,26 @@ +OpenLayers.Control.DeleteFeature = OpenLayers.Class(OpenLayers.Control, { + initialize: function(layer, options) { + OpenLayers.Control.prototype.initialize.apply(this, [options]); + this.layer = layer; + this.handler = new OpenLayers.Handler.Feature( + this, layer, {click: this.clickFeature} + ); + }, + clickFeature: function(feature) { + // if feature doesn't have a fid, destroy it + if(feature.fid == undefined) { + this.layer.destroyFeatures([feature]); + } else { + feature.state = OpenLayers.State.DELETE; + this.layer.events.triggerEvent("afterfeaturemodified", + {feature: feature}); + feature.renderIntent = "select"; + this.layer.drawFeature(feature); + } + }, + setMap: function(map) { + this.handler.setMap(map); + OpenLayers.Control.prototype.setMap.apply(this, arguments); + }, + CLASS_NAME: "OpenLayers.Control.DeleteFeature" +});