From 541e893ec71b7091cb3b74a6fc4c2e9817349564 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 22 Jul 2016 15:50:25 +0000 Subject: [PATCH] refs 4172: Dataminer interface enhancements https://support.d4science.org/issues/4172 Added support to trajectories git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/openlayer-basic-widgets@130721 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/OpenLayerBasicWidgetsManager.java | 27 ++-- .../client/event/SelectAreaDialogEvent.java | 31 ++++- .../event/SelectAreaDialogEventType.java | 3 +- .../client/widgets/AreaSelectionDialog.java | 131 +++++++++++------- 4 files changed, 123 insertions(+), 69 deletions(-) diff --git a/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/OpenLayerBasicWidgetsManager.java b/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/OpenLayerBasicWidgetsManager.java index 0126280..54d5079 100644 --- a/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/OpenLayerBasicWidgetsManager.java +++ b/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/OpenLayerBasicWidgetsManager.java @@ -1,5 +1,7 @@ package org.gcube.portlets.widgets.openlayerbasicwidgets.client; +import org.gcube.portlets.widgets.openlayerbasicwidgets.client.event.SelectAreaDialogEvent; +import org.gcube.portlets.widgets.openlayerbasicwidgets.client.event.SelectAreaDialogEvent.SelectAreaDialogEventHandler; import org.gcube.portlets.widgets.openlayerbasicwidgets.client.widgets.AreaSelectionDialog; import com.google.gwt.core.client.EntryPoint; @@ -63,24 +65,21 @@ public class OpenLayerBasicWidgetsManager implements EntryPoint { private void loadMainPanel() { GWT.log("OpenLayerBasicWidgetsManager"); - // Example - new AreaSelectionDialog(); - /*WizardEvent.WizardEventHandler handler = new WizardEvent.WizardEventHandler() { - + + // Example + SelectAreaDialogEventHandler handler=new SelectAreaDialogEventHandler() { + @Override - public void onResponse(WizardEvent event) { - GWT.log("Wizard Response: " + event.getWizardEventType()); - + public void onResponse(SelectAreaDialogEvent event) { + GWT.log("SelectAreaDialog Response: "+event); + } }; - - GitHubConnectorWizard wizard = new GitHubConnectorWizard( - "0cfde9e2-a6f0-451f-a048-adbd42d7d57f"); - wizard.addWizardEventHandler(handler); - wizard.show(); - */ - + + AreaSelectionDialog dialog=new AreaSelectionDialog(); + dialog.addSelectAreaDialogEventHandler(handler); + } } diff --git a/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/event/SelectAreaDialogEvent.java b/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/event/SelectAreaDialogEvent.java index 78099c7..459e18c 100644 --- a/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/event/SelectAreaDialogEvent.java +++ b/src/main/java/org/gcube/portlets/widgets/openlayerbasicwidgets/client/event/SelectAreaDialogEvent.java @@ -13,10 +13,12 @@ import com.google.gwt.event.shared.HasHandlers; * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it * */ -public class SelectAreaDialogEvent extends GwtEvent { +public class SelectAreaDialogEvent extends + GwtEvent { public static Type TYPE = new Type(); private SelectAreaDialogEventType selectAreaDialogEventType; + private String area; private String errorMessage; private Exception exception; @@ -47,7 +49,8 @@ public class SelectAreaDialogEvent extends GwtEvent"); - comboGeometryType = new ListBox(); - comboGeometryType.setWidth("256px"); - comboGeometryType.setTabIndex(10001); - comboGeometryType.ensureDebugId("comboGeometryType"); - for (GeometryType gType : GeometryType.asList()) { - comboGeometryType.addItem(gType.getLabel()); - } - - comboGeometryType.setSelectedIndex(initialGeometry.ordinal()); - comboGeometryType.addChangeHandler(new ChangeHandler() { - - @Override - public void onChange(ChangeEvent event) { - int selected = comboGeometryType.getSelectedIndex(); - if (selected >= 0) { - String geoLabel = comboGeometryType.getValue(selected); - GeometryType gType = GeometryType.getFromLabel(geoLabel); - onChangeTypeSelect(gType.getId()); - } - + if (ShowAllGeometryGeometry) { + comboGeometryType = new ListBox(); + comboGeometryType.setWidth(COMBO_GEOMETY_TYPE_WIDTH); + comboGeometryType.setTabIndex(10001); + comboGeometryType.ensureDebugId("comboGeometryType"); + for (GeometryType gType : GeometryType.asList()) { + comboGeometryType.addItem(gType.getLabel()); } - }); + + comboGeometryType.setSelectedIndex(initialGeometry.ordinal()); + comboGeometryType.addChangeHandler(new ChangeHandler() { + + @Override + public void onChange(ChangeEvent event) { + int selected = comboGeometryType.getSelectedIndex(); + if (selected >= 0) { + String geoLabel = comboGeometryType.getValue(selected); + GeometryType gType = GeometryType + .getFromLabel(geoLabel); + onChangeTypeSelect(gType.getId()); + } + + } + }); + } wktGeometry = new TextArea(); wktGeometry.setReadOnly(true); wktGeometry.getElement().getStyle().setProperty("resize", "none"); wktGeometry.setVisibleLines(5); - wktGeometry.setWidth("250px"); + wktGeometry.setWidth(WKT_GEOMETRY_WIDTH); wktGeometry.setTabIndex(10002); wktGeometry.setStyleName("wktGeometryTextArea"); @@ -165,12 +187,18 @@ public class AreaSelectionDialog extends DialogBox implements .olBasicCSS().getAreaSelectionContent()); selectGeometryFlexTable.setCellSpacing(2); - selectGeometryFlexTable.setHTML(1, 0, "Geometry:"); - selectGeometryFlexTable.setWidget(1, 1, comboGeometryType); + if (ShowAllGeometryGeometry) { - selectGeometryFlexTable.setHTML(2, 0, "WKT:"); - selectGeometryFlexTable.setWidget(2, 1, wktGeometry); + selectGeometryFlexTable.setHTML(1, 0, "Geometry:"); + selectGeometryFlexTable.setWidget(1, 1, comboGeometryType); + selectGeometryFlexTable.setHTML(2, 0, "WKT:"); + selectGeometryFlexTable.setWidget(2, 1, wktGeometry); + } else { + selectGeometryFlexTable.setHTML(1, 0, "WKT:"); + selectGeometryFlexTable.setWidget(1, 1, wktGeometry); + } + areaSelectionPanel.add(selectGeometryFlexTable); // setContent(areaSelectionPanel); @@ -196,7 +224,7 @@ public class AreaSelectionDialog extends DialogBox implements @Override public void onClick(ClickEvent event) { - hide(); + btnSavePressed(); } }); @@ -209,7 +237,7 @@ public class AreaSelectionDialog extends DialogBox implements @Override public void onClick(ClickEvent event) { - hide(); + btnClosePressed(); } }); @@ -231,15 +259,27 @@ public class AreaSelectionDialog extends DialogBox implements } - /* - * var modify = new ol.interaction.Modify({ features : $wnd.features, - * - * deleteCondition : function(event) { return - * ol.events.condition.shiftKeyOnly(event) && - * ol.events.condition.singleClick(event); }, }); - * - * $wnd.olMap.addInteraction(modify); - */ + private void btnClosePressed() { + SelectAreaDialogEvent event = new SelectAreaDialogEvent( + SelectAreaDialogEventType.Aborted); + fireEvent(event); + hide(); + + } + + private void btnSavePressed() { + String area = wktGeometry.getValue(); + if (area == null || area.isEmpty()) { + GWTMessages.alert("Attention", "Select a valid area!", zIndex); + } else { + SelectAreaDialogEvent event = new SelectAreaDialogEvent( + SelectAreaDialogEventType.Completed); + event.setArea(area); + fireEvent(event); + hide(); + } + + } private static native void onChangeTypeSelect(String value) /*-{ //window.alert("Map: "+$wnd.olMap) @@ -256,11 +296,8 @@ public class AreaSelectionDialog extends DialogBox implements source : new ol.source.OSM() }); - //$wnd.features = new ol.Collection(); - $wnd.source = new ol.source.Vector({ wrapX : false - //features : $wnd.features }); $wnd.vector = new ol.layer.Vector({ @@ -288,8 +325,8 @@ public class AreaSelectionDialog extends DialogBox implements layers : [ $wnd.raster, $wnd.vector ], target : 'openLayerMap', view : new ol.View({ - center : [ -11000000, 4600000 ], - zoom : 4 + center : [ 0, 0 ], + zoom : 0 }) }); //window.alert("olMap: "+$wnd.olMap);