diff --git a/.classpath b/.classpath
index 7e6649c..142b3ee 100644
--- a/.classpath
+++ b/.classpath
@@ -1,12 +1,12 @@
-
+
-
+
@@ -22,7 +22,7 @@
-
+
@@ -33,5 +33,5 @@
-
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 7078bf8..131c0d4 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -7,7 +7,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
diff --git a/distro/changelog.xml b/distro/changelog.xml
index c44bd4c..a56f548 100644
--- a/distro/changelog.xml
+++ b/distro/changelog.xml
@@ -1,4 +1,9 @@
+
+ Added location and zoom support [ticket #11708]
+ Added coordinates EPSG:4326 and EPSG:3857 support [ticket #11710]
+
Support Java 8 compatibility [ticket #8471]
diff --git a/pom.xml b/pom.xml
index b2658fb..b243f85 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
org.gcube.portlets.widgets
openlayer-basic-widgets
- 1.2.0-SNAPSHOT
+ 1.3.0-SNAPSHOT
openlayer-basic-widgets
openlayer-basic-widgets
@@ -38,11 +38,12 @@
${project.build.directory}/${project.build.finalName}
distro
config
+
+
+ 1.7
+ 1.8
-
- 1.7
-
2.7.0
3.3.2
@@ -198,8 +199,8 @@
maven-compiler-plugin
2.3.2
-
- ${javaVersion}
+
+ ${maven.compiler.target}
diff --git a/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/widgets/AreaSelectionDialog.java b/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/widgets/AreaSelectionDialog.java
index 2ce09a9..aa9fb80 100644
--- a/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/widgets/AreaSelectionDialog.java
+++ b/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/widgets/AreaSelectionDialog.java
@@ -4,6 +4,8 @@ import org.gcube.portlets.widgets.openlayerbasicwidgets.client.event.SelectAreaD
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.event.SelectAreaDialogEventType;
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.resource.OLBasicResources;
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.util.GWTMessages;
+import org.gcube.portlets.widgets.openlayerbasicwidgets.shared.data.Coordinates;
+import org.gcube.portlets.widgets.openlayerbasicwidgets.shared.data.ProjectionType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
@@ -37,8 +39,7 @@ import com.google.gwt.user.client.ui.VerticalPanel;
*
*
*/
-public class AreaSelectionDialog extends DialogBox implements
- SelectAreaDialogEvent.HasSelectAreaDialogEventHandler {
+public class AreaSelectionDialog extends DialogBox implements SelectAreaDialogEvent.HasSelectAreaDialogEventHandler {
private static final String COMBO_GEOMETY_TYPE_WIDTH = "406px";
private static final boolean RESIZABLE = false;
private static final boolean COLLAPSIBLE = true;
@@ -52,7 +53,8 @@ public class AreaSelectionDialog extends DialogBox implements
private ListBox comboGeometryType;
private TextArea wktGeometry;
private String wktData;
- private GeometryType initialGeometry;
+ private GeometryType geometryType;
+ private Coordinates coordinates;
public void setWktGeometry(String wktData) {
// wktData = wktData;
@@ -64,7 +66,8 @@ public class AreaSelectionDialog extends DialogBox implements
public AreaSelectionDialog() {
try {
ShowAllGeometryGeometry = true;
- initialGeometry = GeometryType.Polygon;
+ this.geometryType = GeometryType.Polygon;
+ this.coordinates = null;
initWindow();
initHandler();
addToolIcon();
@@ -78,7 +81,24 @@ public class AreaSelectionDialog extends DialogBox implements
public AreaSelectionDialog(GeometryType geometryType) {
try {
ShowAllGeometryGeometry = false;
- initialGeometry = geometryType;
+ this.geometryType = geometryType;
+ this.coordinates = null;
+ dialogTitle = "Draw a " + geometryType.getLabel();
+ initWindow();
+ initHandler();
+ addToolIcon();
+ create();
+ } catch (Throwable e) {
+ GWT.log(e.getLocalizedMessage());
+ e.printStackTrace();
+ }
+ }
+
+ public AreaSelectionDialog(GeometryType geometryType, Coordinates coordinates) {
+ try {
+ ShowAllGeometryGeometry = false;
+ this.geometryType = geometryType;
+ this.coordinates = coordinates;
dialogTitle = "Draw a " + geometryType.getLabel();
initWindow();
initHandler();
@@ -101,23 +121,21 @@ public class AreaSelectionDialog extends DialogBox implements
}
private void initHandler() {
- resizeHandlerRegistration = Window
- .addResizeHandler(new ResizeHandler() {
+ resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() {
- @Override
- public void onResize(ResizeEvent event) {
- center();
+ @Override
+ public void onResize(ResizeEvent event) {
+ center();
- }
- });
+ }
+ });
}
private void create() {
SimplePanel areaSelectionPanel = new SimplePanel();
- areaSelectionPanel.setStyleName(OLBasicResources.INSTANCE.olBasicCSS()
- .getAreaSelectionPanel());
+ areaSelectionPanel.setStyleName(OLBasicResources.INSTANCE.olBasicCSS().getAreaSelectionPanel());
HTML mapContainer = new HTML(
"");
@@ -125,11 +143,14 @@ public class AreaSelectionDialog extends DialogBox implements
if (ShowAllGeometryGeometry) {
comboGeometryType = new ListBox();
comboGeometryType.getElement().setId("combo-geometry-type");
-
- //comboGeometryType.getElement().getStyle().setProperty("width", "406px!important");
-
- /*comboGeometryType.addStyleName(OLBasicResources.INSTANCE
- .olBasicCSS().getComboGeometryType());*/
+
+ // comboGeometryType.getElement().getStyle().setProperty("width",
+ // "406px!important");
+
+ /*
+ * comboGeometryType.addStyleName(OLBasicResources.INSTANCE
+ * .olBasicCSS().getComboGeometryType());
+ */
comboGeometryType.setWidth(COMBO_GEOMETY_TYPE_WIDTH);
comboGeometryType.setTabIndex(10001);
@@ -138,7 +159,7 @@ public class AreaSelectionDialog extends DialogBox implements
comboGeometryType.addItem(gType.getLabel());
}
- comboGeometryType.setSelectedIndex(initialGeometry.ordinal());
+ comboGeometryType.setSelectedIndex(geometryType.ordinal());
comboGeometryType.addChangeHandler(new ChangeHandler() {
@Override
@@ -146,9 +167,8 @@ public class AreaSelectionDialog extends DialogBox implements
int selected = comboGeometryType.getSelectedIndex();
if (selected >= 0) {
String geoLabel = comboGeometryType.getValue(selected);
- GeometryType gType = GeometryType
- .getFromLabel(geoLabel);
- onChangeTypeSelect(gType.getId());
+ GeometryType gType = GeometryType.getFromLabel(geoLabel);
+ onChangeTypeSelect(gType.name());
}
}
@@ -161,19 +181,18 @@ public class AreaSelectionDialog extends DialogBox implements
wktGeometry.setVisibleLines(5);
wktGeometry.setTabIndex(10002);
wktGeometry.getElement().setId("wkt-geometry-text-area");
-
+
/*
- wktGeometry.addStyleName(OLBasicResources.INSTANCE.olBasicCSS()
- .getWKTGeometryTextArea());
- */
+ * wktGeometry.addStyleName(OLBasicResources.INSTANCE.olBasicCSS()
+ * .getWKTGeometryTextArea());
+ */
// ////////
// Form
FlexTable layout = new FlexTable();
layout.setCellSpacing(10);
FlexTable selectGeometryFlexTable = new FlexTable();
- selectGeometryFlexTable.setStyleName(OLBasicResources.INSTANCE
- .olBasicCSS().getAreaSelectionContent());
+ selectGeometryFlexTable.setStyleName(OLBasicResources.INSTANCE.olBasicCSS().getAreaSelectionContent());
selectGeometryFlexTable.setCellSpacing(2);
if (ShowAllGeometryGeometry) {
@@ -197,12 +216,10 @@ public class AreaSelectionDialog extends DialogBox implements
dialogContents.setSpacing(4);
dialogContents.add(mapContainer);
- dialogContents.setCellHorizontalAlignment(mapContainer,
- HasHorizontalAlignment.ALIGN_CENTER);
+ dialogContents.setCellHorizontalAlignment(mapContainer, HasHorizontalAlignment.ALIGN_CENTER);
dialogContents.add(areaSelectionPanel);
- dialogContents.setCellHorizontalAlignment(areaSelectionPanel,
- HasHorizontalAlignment.ALIGN_CENTER);
+ dialogContents.setCellHorizontalAlignment(areaSelectionPanel, HasHorizontalAlignment.ALIGN_CENTER);
// Add Button
Button btnSave = new Button("Save");
@@ -237,8 +254,7 @@ public class AreaSelectionDialog extends DialogBox implements
buttonPack.add(btnClose);
dialogContents.add(buttonPack);
- dialogContents.setCellHorizontalAlignment(buttonPack,
- HasHorizontalAlignment.ALIGN_CENTER);
+ dialogContents.setCellHorizontalAlignment(buttonPack, HasHorizontalAlignment.ALIGN_CENTER);
setWidget(dialogContents);
@@ -248,13 +264,49 @@ public class AreaSelectionDialog extends DialogBox implements
public void show() {
super.show();
center();
- initMap(this, initialGeometry.getId());
+ String projection=null;
+ String longitude= null;
+ String latitude = null;
+ String zoom = null;
+ if (coordinates == null) {
+ projection = ProjectionType.EPSG4326.getLabel();
+ longitude = "0";
+ latitude = "0";
+ zoom = "0";
+ } else {
+ if (coordinates.getProjection() == null || coordinates.getProjection().isEmpty()) {
+ projection = ProjectionType.EPSG4326.getLabel();
+ } else {
+ if (coordinates.getProjection().compareTo(ProjectionType.EPSG4326.getLabel()) == 0
+ || coordinates.getProjection().compareTo(ProjectionType.EPSG3857.getLabel()) == 0) {
+ projection = coordinates.getProjection();
+ } else {
+ projection = ProjectionType.EPSG4326.getLabel();
+ }
+ }
+ if (coordinates.getX() == null || coordinates.getX().isEmpty()) {
+ longitude = "0";
+ } else {
+ longitude = coordinates.getX();
+ }
+ if (coordinates.getY() == null || coordinates.getY().isEmpty()) {
+ latitude = "0";
+ } else {
+ latitude = coordinates.getY();
+ }
+ if (coordinates.getZoom() == null || coordinates.getZoom().isEmpty()) {
+ zoom = "0";
+ } else {
+ zoom = coordinates.getZoom();
+ }
+ }
+ initMap(this, geometryType.name(), projection, longitude, latitude, zoom);
};
+
private void btnClosePressed() {
- SelectAreaDialogEvent event = new SelectAreaDialogEvent(
- SelectAreaDialogEventType.Aborted);
+ SelectAreaDialogEvent event = new SelectAreaDialogEvent(SelectAreaDialogEventType.Aborted);
fireEvent(event);
hide();
@@ -265,8 +317,7 @@ public class AreaSelectionDialog extends DialogBox implements
if (area == null || area.isEmpty()) {
GWTMessages.alert("Attention", "Select a valid area!", zIndex);
} else {
- SelectAreaDialogEvent event = new SelectAreaDialogEvent(
- SelectAreaDialogEventType.Completed);
+ SelectAreaDialogEvent event = new SelectAreaDialogEvent(SelectAreaDialogEventType.Completed);
event.setArea(area);
fireEvent(event);
hide();
@@ -280,9 +331,14 @@ public class AreaSelectionDialog extends DialogBox implements
$wnd.addInteraction(value);
}-*/;
- private static native void initMap(AreaSelectionDialog instance,
- String initialGeometry) /*-{
-
+ private static native void initMap(AreaSelectionDialog instance, String geometryName, String projectionName,
+ String initX, String initY, String initZoom) /*-{
+ console.log(geometryName);
+ console.log(projectionName);
+ console.log(initX);
+ console.log(initY);
+ console.log(initZoom);
+
//window.alert("ol: "+$wnd.ol);
var ol = $wnd.ol;
$wnd.raster = new ol.layer.Tile({
@@ -312,17 +368,25 @@ public class AreaSelectionDialog extends DialogBox implements
})
});
+ // coords=ol.proj.fromLonLat(coords);
+ // longitude first, then latitude
+ var coords=[initX,initY];
+ console.log(coords);
+
//window.alert("Retrieve map Id: "+$doc.getElementById('map'));
-
+ $wnd.mapView=new ol.View({
+ projection : projectionName,
+ center : coords,
+ zoom : initZoom
+ });
+
+ console.log($wnd.mapView);
$wnd.olMap = new ol.Map({
layers : [ $wnd.raster, $wnd.vector ],
target : 'openLayerMap',
- view : new ol.View({
- projection: 'EPSG:4326',
- center : [ 0, 0 ],
- zoom : 0
- })
+ view : $wnd.mapView
});
+ console.log($wnd.olMap);
//window.alert("olMap: "+$wnd.olMap);
//
@@ -412,7 +476,7 @@ public class AreaSelectionDialog extends DialogBox implements
// addInteraction();
//};
- $wnd.addInteraction(initialGeometry);
+ $wnd.addInteraction(geometryName);
}-*/;
private void addToolIcon() {
@@ -421,16 +485,9 @@ public class AreaSelectionDialog extends DialogBox implements
Element dialogTopRight = getCellElement(0, 2);
// close button image html
- dialogTopRight.setInnerHTML(""
- + "
");
+ dialogTopRight.setInnerHTML("" + "
");
// set the event target
closeEventTarget = dialogTopRight.getChild(0).getChild(0);
@@ -449,10 +506,8 @@ public class AreaSelectionDialog extends DialogBox implements
protected void onPreviewNativeEvent(NativePreviewEvent event) {
NativeEvent nativeEvent = event.getNativeEvent();
- if (!event.isCanceled() && (event.getTypeInt() == Event.ONCLICK)
- && isCloseEvent(nativeEvent)) {
- final SelectAreaDialogEvent wizardEvent = new SelectAreaDialogEvent(
- SelectAreaDialogEventType.Aborted);
+ if (!event.isCanceled() && (event.getTypeInt() == Event.ONCLICK) && isCloseEvent(nativeEvent)) {
+ final SelectAreaDialogEvent wizardEvent = new SelectAreaDialogEvent(SelectAreaDialogEventType.Aborted);
fireEvent(wizardEvent);
this.hide();
}
diff --git a/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/widgets/GeometryType.java b/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/widgets/GeometryType.java
index 6be63f2..d1a4ae0 100644
--- a/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/widgets/GeometryType.java
+++ b/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/widgets/GeometryType.java
@@ -33,9 +33,6 @@ public enum GeometryType {
return label;
}
- public String getId() {
- return name();
- }
/**
*
diff --git a/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/shared/data/Coordinates.java b/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/shared/data/Coordinates.java
new file mode 100644
index 0000000..4177ee6
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/shared/data/Coordinates.java
@@ -0,0 +1,67 @@
+package org.gcube.portlets.widgets.openlayerbasicwidgets.shared.data;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Giancarlo Panichi
+ *
+ *
+ */
+public class Coordinates implements Serializable {
+ private static final long serialVersionUID = -1387634056697911513L;
+ private String projection;
+ private String x;
+ private String y;
+ private String zoom;
+
+ public Coordinates() {
+ super();
+ }
+
+ public Coordinates(String projection, String x, String y, String zoom) {
+ super();
+ this.projection = projection;
+ this.x = x;
+ this.y = y;
+ this.zoom = zoom;
+ }
+
+ public String getProjection() {
+ return projection;
+ }
+
+ public void setProjection(String projection) {
+ this.projection = projection;
+ }
+
+ public String getX() {
+ return x;
+ }
+
+ public void setX(String x) {
+ this.x = x;
+ }
+
+ public String getY() {
+ return y;
+ }
+
+ public void setY(String y) {
+ this.y = y;
+ }
+
+ public String getZoom() {
+ return zoom;
+ }
+
+ public void setZoom(String zoom) {
+ this.zoom = zoom;
+ }
+
+ @Override
+ public String toString() {
+ return "Coordinate [projection=" + projection + ", x=" + x + ", y=" + y + ", zoom=" + zoom + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/shared/data/ProjectionType.java b/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/shared/data/ProjectionType.java
new file mode 100644
index 0000000..e49ce2a
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/shared/data/ProjectionType.java
@@ -0,0 +1,42 @@
+package org.gcube.portlets.widgets.openlayerbasicwidgets.shared.data;
+
+/**
+ *
+ * @author Giancarlo Panichi
+ *
+ *
+ */
+public enum ProjectionType {
+
+ EPSG4326("EPSG:4326"),
+ EPSG3857("EPSG:3857");
+
+ private final String id;
+
+ private ProjectionType(final String id) {
+ this.id = id;
+ }
+
+
+ @Override
+ public String toString() {
+ return id;
+ }
+
+ public String getLabel() {
+ return id;
+ }
+
+
+ public static ProjectionType getProjectionTypeFromId(String id) {
+ for (ProjectionType projectionType : values()) {
+ if (projectionType.id.compareToIgnoreCase(id) == 0) {
+ return projectionType;
+ }
+ }
+ return null;
+ }
+
+
+
+}