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
This commit is contained in:
Giancarlo Panichi 2016-07-22 15:50:25 +00:00
parent 26f16c17e1
commit 541e893ec7
4 changed files with 123 additions and 69 deletions

View File

@ -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);
}
}

View File

@ -13,10 +13,12 @@ import com.google.gwt.event.shared.HasHandlers;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class SelectAreaDialogEvent extends GwtEvent<SelectAreaDialogEvent.SelectAreaDialogEventHandler> {
public class SelectAreaDialogEvent extends
GwtEvent<SelectAreaDialogEvent.SelectAreaDialogEventHandler> {
public static Type<SelectAreaDialogEventHandler> TYPE = new Type<SelectAreaDialogEventHandler>();
private SelectAreaDialogEventType selectAreaDialogEventType;
private String area;
private String errorMessage;
private Exception exception;
@ -47,7 +49,8 @@ public class SelectAreaDialogEvent extends GwtEvent<SelectAreaDialogEvent.Select
return TYPE;
}
public static void fire(HasHandlers source, SelectAreaDialogEvent deleteItemEvent) {
public static void fire(HasHandlers source,
SelectAreaDialogEvent deleteItemEvent) {
source.fireEvent(deleteItemEvent);
}
@ -75,13 +78,29 @@ public class SelectAreaDialogEvent extends GwtEvent<SelectAreaDialogEvent.Select
this.exception = exception;
}
public SelectAreaDialogEventType getSelectAreaDialogEventType() {
return selectAreaDialogEventType;
}
public void setSelectAreaDialogEventType(
SelectAreaDialogEventType selectAreaDialogEventType) {
this.selectAreaDialogEventType = selectAreaDialogEventType;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
@Override
public String toString() {
return "SelectAreaDialogEvent [selectAreaDialogEventType="
+ selectAreaDialogEventType + ", errorMessage=" + errorMessage
+ ", exception=" + exception + "]";
+ selectAreaDialogEventType + ", area=" + area
+ ", errorMessage=" + errorMessage + ", exception=" + exception
+ "]";
}
}

View File

@ -10,8 +10,7 @@ import java.util.List;
*
*/
public enum SelectAreaDialogEventType {
Completed("Completed"), Failed("Failed"), Aborted("Aborted"), Background(
"Background");
Completed("Completed"), Failed("Failed"), Aborted("Aborted");
/**
* @param text

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.widgets.openlayerbasicwidgets.client.widgets;
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.event.SelectAreaDialogEvent;
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 com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
@ -38,13 +39,17 @@ import com.google.gwt.user.client.ui.VerticalPanel;
*/
public class AreaSelectionDialog extends DialogBox implements
SelectAreaDialogEvent.HasSelectAreaDialogEventHandler {
private HandlerRegistration resizeHandlerRegistration;
private static final String COMBO_GEOMETY_TYPE_WIDTH = "406px";
private static final String WKT_GEOMETRY_WIDTH = "400px";
private static final boolean RESIZABLE = false;
private static final boolean COLLAPSIBLE = true;
private static final String title = "Select Area";
private static final String DIALOG_TITLE = "Select Area";
private HandlerRegistration resizeHandlerRegistration;
private Node closeEventTarget = null;
private int zIndex = -1;
private boolean ShowAllGeometryGeometry;
private ListBox comboGeometryType;
private TextArea wktGeometry;
private String wktData;
@ -59,7 +64,7 @@ public class AreaSelectionDialog extends DialogBox implements
public AreaSelectionDialog() {
try {
ShowAllGeometryGeometry = true;
initialGeometry = GeometryType.Polygon;
initWindow();
initHandler();
@ -71,13 +76,27 @@ public class AreaSelectionDialog extends DialogBox implements
}
}
public AreaSelectionDialog(GeometryType geometryType) {
try {
ShowAllGeometryGeometry = false;
initialGeometry = geometryType;
initWindow();
initHandler();
addToolIcon();
create();
} catch (Throwable e) {
GWT.log(e.getLocalizedMessage());
e.printStackTrace();
}
}
private void initWindow() {
GWT.log(title);
GWT.log(DIALOG_TITLE);
OLBasicResources.INSTANCE.olBasicCSS().ensureInjected();
setModal(true);
setGlassEnabled(true);
setAnimationEnabled(true);
setText(title);
setText(DIALOG_TITLE);
}
@ -124,34 +143,37 @@ public class AreaSelectionDialog extends DialogBox implements
HTML mapContainer = new HTML(
"<div id='openLayerMap' class='openLayerMap' style='width:500px;height:250px;'></div>");
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);