Updated Geometry and Geospatial
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-table-widget@112169 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ac1ccd4cfd
commit
22d8fda52c
|
@ -177,12 +177,11 @@ public class GeometryCreatePointPanel extends FramedPanel implements
|
|||
vl.setScrollMode(ScrollMode.AUTO);
|
||||
vl.setAdjustForScroll(true);
|
||||
|
||||
vl.add(new FieldLabel(comboLatitude, "Latitude"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
|
||||
vl.add(new FieldLabel(comboLongitude, "Longitude"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
|
||||
vl.add(new FieldLabel(comboLatitude, "Latitude"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
|
||||
vl.add(columnLab, new VerticalLayoutData(1, -1));
|
||||
|
||||
vl.add(createPointButton, new VerticalLayoutData(-1, -1, new Margins(
|
||||
|
@ -248,10 +247,10 @@ public class GeometryCreatePointPanel extends FramedPanel implements
|
|||
}
|
||||
|
||||
protected void onGeometryCreatePoint() {
|
||||
ColumnData latitude = comboLatitude.getCurrentValue();
|
||||
if (latitude != null) {
|
||||
ColumnData longitude = comboLongitude.getCurrentValue();
|
||||
if (longitude != null) {
|
||||
ColumnData longitude = comboLongitude.getCurrentValue();
|
||||
if (longitude != null) {
|
||||
ColumnData latitude = comboLatitude.getCurrentValue();
|
||||
if (latitude != null) {
|
||||
String columnLab = columnLabelField.getCurrentValue();
|
||||
if (columnLab != null && !columnLab.isEmpty()) {
|
||||
GeometryCreatePointSession geoCreatePointSession = new GeometryCreatePointSession(
|
||||
|
@ -261,10 +260,10 @@ public class GeometryCreatePointPanel extends FramedPanel implements
|
|||
UtilsGXT3.alert("Attention", "Select a column label!");
|
||||
}
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention", "Select Longitude!");
|
||||
UtilsGXT3.alert("Attention", "Select Latitude!");
|
||||
}
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention", "Select Latitude!");
|
||||
UtilsGXT3.alert("Attention", "Select Longitude!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
|||
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||
import com.sencha.gxt.widget.core.client.form.Radio;
|
||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||
import com.sencha.gxt.widget.core.client.info.Info;
|
||||
|
||||
/**
|
||||
|
@ -88,7 +87,9 @@ public class GeospatialCreateCoordinatesPanel extends FramedPanel implements
|
|||
private Radio hasQuadrantFalse;
|
||||
private FieldLabel comboQuadrantLabel;
|
||||
private FieldLabel hasQuadrantLabel;
|
||||
private TextField resolutionField;
|
||||
|
||||
private ComboBox<Resolution> comboResolution;
|
||||
private ListStore<Resolution> storeComboResolution;
|
||||
|
||||
public GeospatialCreateCoordinatesPanel(TRId trId,
|
||||
RequestProperties requestProperties, EventBus eventBus) {
|
||||
|
@ -207,9 +208,28 @@ public class GeospatialCreateCoordinatesPanel extends FramedPanel implements
|
|||
comboGsCoordinatesType.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
// Resolution
|
||||
resolutionField = new TextField();
|
||||
resolutionField.setValue("0.1");
|
||||
FieldLabel resolutionLabel = new FieldLabel(resolutionField,
|
||||
ResolutionPropertiesCombo propsResolution = GWT
|
||||
.create(ResolutionPropertiesCombo.class);
|
||||
|
||||
storeComboResolution = new ListStore<Resolution>(propsResolution.id());
|
||||
storeComboResolution
|
||||
.addAll(ResolutionStore.getStoreCSquareResolution());
|
||||
|
||||
comboResolution = new ComboBox<Resolution>(storeComboResolution,
|
||||
propsResolution.value());
|
||||
Log.trace("Combo Resolution created");
|
||||
|
||||
addHandlersForComboResolution(propsResolution.value());
|
||||
|
||||
comboResolution.setEmptyText("Select a resolution...");
|
||||
comboResolution.setValue(ResolutionStore
|
||||
.getStoreCSquareResolutionDefault());
|
||||
comboResolution.setWidth(191);
|
||||
comboResolution.setTypeAhead(false);
|
||||
comboResolution.setEditable(false);
|
||||
comboResolution.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
FieldLabel resolutionLabel = new FieldLabel(comboResolution,
|
||||
"Resolution");
|
||||
|
||||
// Has Quadrant
|
||||
|
@ -301,11 +321,10 @@ public class GeospatialCreateCoordinatesPanel extends FramedPanel implements
|
|||
vl.setScrollMode(ScrollMode.AUTO);
|
||||
vl.setAdjustForScroll(true);
|
||||
|
||||
vl.add(new FieldLabel(comboLatitude, "Latitude"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
|
||||
vl.add(new FieldLabel(comboLongitude, "Longitude"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
vl.add(new FieldLabel(comboLatitude, "Latitude"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
|
||||
vl.add(new FieldLabel(comboGsCoordinatesType, "Type"),
|
||||
new VerticalLayoutData(1, -1));
|
||||
|
@ -325,6 +344,32 @@ public class GeospatialCreateCoordinatesPanel extends FramedPanel implements
|
|||
|
||||
}
|
||||
|
||||
private void addHandlersForComboResolution(
|
||||
final LabelProvider<Resolution> value) {
|
||||
comboResolution.addSelectionHandler(new SelectionHandler<Resolution>() {
|
||||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Resolution> event) {
|
||||
Info.display(
|
||||
"Resolution Selected",
|
||||
"You selected "
|
||||
+ (event.getSelectedItem() == null ? "nothing"
|
||||
: value.getLabel(event
|
||||
.getSelectedItem()) + "!"));
|
||||
Log.debug("Reolution selected: " + event.getSelectedItem());
|
||||
Resolution resolution = event.getSelectedItem();
|
||||
updatedResolution(resolution);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void updatedResolution(Resolution resolution) {
|
||||
|
||||
}
|
||||
|
||||
private void addHandlersForComboColumnLatitude(
|
||||
final LabelProvider<ColumnData> labelProvider) {
|
||||
comboLatitude.addSelectionHandler(new SelectionHandler<ColumnData>() {
|
||||
|
@ -417,7 +462,14 @@ public class GeospatialCreateCoordinatesPanel extends FramedPanel implements
|
|||
hasQuadrantLabel.setVisible(false);
|
||||
comboQuadrantLabel.setVisible(false);
|
||||
comboGsCoordinatesType.setValue(gsCoordinatesType);
|
||||
resolutionField.setValue("10.0");
|
||||
storeComboResolution.clear();
|
||||
storeComboResolution.addAll(ResolutionStore
|
||||
.getStoreCSquareResolution());
|
||||
storeComboResolution.commitChanges();
|
||||
comboResolution.clear();
|
||||
comboResolution.reset();
|
||||
comboResolution.setValue(ResolutionStore
|
||||
.getStoreCSquareResolutionDefault());
|
||||
createCoordinatesButton.setIcon(ResourceBundle.INSTANCE
|
||||
.geospatialCSquare());
|
||||
|
||||
|
@ -433,14 +485,28 @@ public class GeospatialCreateCoordinatesPanel extends FramedPanel implements
|
|||
comboQuadrantLabel.setVisible(true);
|
||||
|
||||
}
|
||||
resolutionField.setValue("0.1");
|
||||
storeComboResolution.clear();
|
||||
storeComboResolution.addAll(ResolutionStore
|
||||
.getStoreOceanAreaResolution());
|
||||
storeComboResolution.commitChanges();
|
||||
comboResolution.clear();
|
||||
comboResolution.reset();
|
||||
comboResolution.setValue(ResolutionStore
|
||||
.getStoreOceanAreaResolutionDefault());
|
||||
hasQuadrantLabel.setVisible(true);
|
||||
comboGsCoordinatesType.setValue(gsCoordinatesType);
|
||||
createCoordinatesButton.setIcon(ResourceBundle.INSTANCE
|
||||
.geospatialOceanArea());
|
||||
break;
|
||||
default:
|
||||
resolutionField.setValue("10.0");
|
||||
storeComboResolution.clear();
|
||||
storeComboResolution.addAll(ResolutionStore
|
||||
.getStoreCSquareResolution());
|
||||
storeComboResolution.commitChanges();
|
||||
comboResolution.clear();
|
||||
comboResolution.reset();
|
||||
comboResolution.setValue(ResolutionStore
|
||||
.getStoreCSquareResolutionDefault());
|
||||
hasQuadrantLabel.setVisible(false);
|
||||
comboQuadrantLabel.setVisible(false);
|
||||
createCoordinatesButton.setIcon(ResourceBundle.INSTANCE
|
||||
|
@ -488,70 +554,68 @@ public class GeospatialCreateCoordinatesPanel extends FramedPanel implements
|
|||
}
|
||||
|
||||
protected void onGeospatialCreateCoordinates() {
|
||||
ColumnData latitude = comboLatitude.getCurrentValue();
|
||||
if (latitude != null) {
|
||||
ColumnData longitude = comboLongitude.getCurrentValue();
|
||||
if (longitude != null) {
|
||||
String resol = resolutionField.getCurrentValue();
|
||||
Double resolution = null;
|
||||
try {
|
||||
resolution = new Double(resol);
|
||||
} catch (NumberFormatException e) {
|
||||
UtilsGXT3.alert("Attention", "Insert a valid resolution!");
|
||||
return;
|
||||
}
|
||||
ColumnData longitude = comboLongitude.getCurrentValue();
|
||||
if (longitude != null) {
|
||||
ColumnData latitude = comboLatitude.getCurrentValue();
|
||||
if (latitude != null) {
|
||||
Resolution resolution = comboResolution.getCurrentValue();
|
||||
if (resolution != null) {
|
||||
|
||||
GeospatialCoordinatesType type = comboGsCoordinatesType
|
||||
.getCurrentValue();
|
||||
if (type != null) {
|
||||
GeospatialCreateCoordinatesSession gsCreateCoordinatesSession;
|
||||
switch (type) {
|
||||
case C_SQUARE:
|
||||
gsCreateCoordinatesSession = new GeospatialCreateCoordinatesSession(
|
||||
trId, latitude, longitude, type, false, null,
|
||||
resolution);
|
||||
callGeospatialCreateCoordinates(gsCreateCoordinatesSession);
|
||||
break;
|
||||
case OCEAN_AREA:
|
||||
if (hasQuadrant()) {
|
||||
ColumnData quadrant = comboQuadrant
|
||||
.getCurrentValue();
|
||||
if (quadrant != null) {
|
||||
gsCreateCoordinatesSession = new GeospatialCreateCoordinatesSession(
|
||||
trId, latitude, longitude, type, true,
|
||||
quadrant, resolution);
|
||||
callGeospatialCreateCoordinates(gsCreateCoordinatesSession);
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Select Quadrant column!");
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
GeospatialCoordinatesType type = comboGsCoordinatesType
|
||||
.getCurrentValue();
|
||||
if (type != null) {
|
||||
GeospatialCreateCoordinatesSession gsCreateCoordinatesSession;
|
||||
switch (type) {
|
||||
case C_SQUARE:
|
||||
gsCreateCoordinatesSession = new GeospatialCreateCoordinatesSession(
|
||||
trId, latitude, longitude, type, false,
|
||||
null, resolution);
|
||||
null, resolution.getValue());
|
||||
callGeospatialCreateCoordinates(gsCreateCoordinatesSession);
|
||||
break;
|
||||
case OCEAN_AREA:
|
||||
if (hasQuadrant()) {
|
||||
ColumnData quadrant = comboQuadrant
|
||||
.getCurrentValue();
|
||||
if (quadrant != null) {
|
||||
gsCreateCoordinatesSession = new GeospatialCreateCoordinatesSession(
|
||||
trId, latitude, longitude, type,
|
||||
true, quadrant, resolution.getValue());
|
||||
callGeospatialCreateCoordinates(gsCreateCoordinatesSession);
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Select Quadrant column!");
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
gsCreateCoordinatesSession = new GeospatialCreateCoordinatesSession(
|
||||
trId, latitude, longitude, type, false,
|
||||
null, resolution.getValue());
|
||||
callGeospatialCreateCoordinates(gsCreateCoordinatesSession);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
UtilsGXT3
|
||||
.alert("Attention",
|
||||
"Select valid geospatial coordinates type!");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Select valid geospatial coordinates type!");
|
||||
break;
|
||||
|
||||
"Invalid Geospatial Coordinates Type!");
|
||||
}
|
||||
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Invalid Geospatial Coordinates Type!");
|
||||
UtilsGXT3.alert("Attention", "Select Resolution!");
|
||||
}
|
||||
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention", "Select Longitude!");
|
||||
UtilsGXT3.alert("Attention", "Select Latitude!");
|
||||
}
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention", "Select Latitude!");
|
||||
UtilsGXT3.alert("Attention", "Select Longitude!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package org.gcube.portlets.user.td.tablewidget.client.geospatial;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class Resolution {
|
||||
private int id;
|
||||
private Double value;
|
||||
|
||||
public Resolution() {
|
||||
}
|
||||
|
||||
public Resolution(int id, Double value) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Double getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Resolution [id=" + id + ", value=" + value + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package org.gcube.portlets.user.td.tablewidget.client.geospatial;
|
||||
|
||||
import com.google.gwt.editor.client.Editor.Path;
|
||||
import com.sencha.gxt.data.shared.LabelProvider;
|
||||
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||
import com.sencha.gxt.data.shared.PropertyAccess;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface ResolutionPropertiesCombo extends PropertyAccess<Resolution> {
|
||||
|
||||
@Path("id")
|
||||
ModelKeyProvider<Resolution> id();
|
||||
|
||||
LabelProvider<Resolution> value();
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package org.gcube.portlets.user.td.tablewidget.client.geospatial;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ResolutionStore implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6520001942214730827L;
|
||||
|
||||
private static ArrayList<Resolution> storeCSquareResolution;
|
||||
private static ArrayList<Resolution> storeOcenaAreaResolution;
|
||||
|
||||
private static Resolution resolutionCSquare1=new Resolution(1, 0.1d);
|
||||
private static Resolution resolutionCSquare2=new Resolution(2, 0.5d);
|
||||
private static Resolution resolutionCSquare3=new Resolution(3, 1.0d);
|
||||
private static Resolution resolutionCSquare4=new Resolution(4, 5.0d);
|
||||
private static Resolution resolutionCSquare5=new Resolution(5, 10.0d);
|
||||
|
||||
private static Resolution resolutionOceanArea1=new Resolution(1, 1.0d);
|
||||
private static Resolution resolutionOceanArea2=new Resolution(2, 5.0d);
|
||||
private static Resolution resolutionOceanArea3=new Resolution(3, 10.0d);
|
||||
|
||||
public static ArrayList<Resolution> getStoreCSquareResolution() {
|
||||
storeCSquareResolution=new ArrayList<Resolution>();
|
||||
storeCSquareResolution.add(resolutionCSquare1);
|
||||
storeCSquareResolution.add(resolutionCSquare2);
|
||||
storeCSquareResolution.add(resolutionCSquare3);
|
||||
storeCSquareResolution.add(resolutionCSquare4);
|
||||
storeCSquareResolution.add(resolutionCSquare5);
|
||||
return storeCSquareResolution;
|
||||
}
|
||||
|
||||
public static Resolution getStoreCSquareResolutionDefault(){
|
||||
return resolutionCSquare2;
|
||||
}
|
||||
|
||||
public static ArrayList<Resolution> getStoreOceanAreaResolution() {
|
||||
storeOcenaAreaResolution=new ArrayList<Resolution>();
|
||||
storeOcenaAreaResolution.add(resolutionOceanArea1);
|
||||
storeOcenaAreaResolution.add(resolutionOceanArea2);
|
||||
storeOcenaAreaResolution.add(resolutionOceanArea3);
|
||||
return storeOcenaAreaResolution;
|
||||
}
|
||||
|
||||
public static Resolution getStoreOceanAreaResolutionDefault(){
|
||||
return resolutionOceanArea2;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue