Updated Geometry Type Support

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-table-widget@100070 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-09-19 15:54:16 +00:00 committed by Giancarlo Panichi
parent 64af2a1c83
commit 94d4482581
1 changed files with 25 additions and 16 deletions

View File

@ -61,14 +61,17 @@ import com.sencha.gxt.widget.core.client.form.DateField;
import com.sencha.gxt.widget.core.client.form.FieldLabel; 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.Radio;
import com.sencha.gxt.widget.core.client.form.TextField; import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.form.validator.RegExValidator;
/** /**
* *
* @author "Giancarlo Panichi" * @author "Giancarlo Panichi"
* *
*/ */
public class EditRowPanel extends FramedPanel public class EditRowPanel extends FramedPanel implements MonitorDialogListener {
implements MonitorDialogListener { private static final String GEOMETRY_REGEXPR = "(\\s*POINT\\s*\\(\\s*(-)?\\d+(\\.\\d+)?\\s+(-)?\\d+(\\.\\d+)?\\s*\\)\\s*$)"
+ "|(\\s*LINESTRING\\s*\\((\\s*(-)?\\d+(\\.\\d+)?\\s+(-)?\\d+(\\.\\d+)?\\s*,)+\\s*((-)?\\d+(\\.\\d+)?\\s+(-)?\\d+(\\.\\d+)?\\s*)\\)\\s*$)";
protected String WIDTH = "510px"; protected String WIDTH = "510px";
protected String HEIGHT = "370px"; protected String HEIGHT = "370px";
protected String FIELDSHEIGHT = "370px"; protected String FIELDSHEIGHT = "370px";
@ -81,8 +84,6 @@ public class EditRowPanel extends FramedPanel
protected RowRaw rowRaw; protected RowRaw rowRaw;
protected boolean editRow; protected boolean editRow;
protected VerticalLayoutContainer v; protected VerticalLayoutContainer v;
private TextButton btnSave; private TextButton btnSave;
private TextButton btnClose; private TextButton btnClose;
@ -225,7 +226,7 @@ public class EditRowPanel extends FramedPanel
protected ArrayList<FieldLabel> generateFields() { protected ArrayList<FieldLabel> generateFields() {
ArrayList<FieldLabel> fields = new ArrayList<FieldLabel>(); ArrayList<FieldLabel> fields = new ArrayList<FieldLabel>();
for (ColumnData col : columns) { for (ColumnData col : columns) {
String label = new String(); String label = new String();
if (col != null && col.getLabel() != null) { if (col != null && col.getLabel() != null) {
@ -325,6 +326,9 @@ public class EditRowPanel extends FramedPanel
if (col.getDataTypeName().compareTo( if (col.getDataTypeName().compareTo(
ColumnDataType.Geometry.toString()) == 0) { ColumnDataType.Geometry.toString()) == 0) {
TextField geometry = new TextField(); TextField geometry = new TextField();
geometry.addValidator(new RegExValidator(
GEOMETRY_REGEXPR,
"Geometry Type not valid"));
String value = ""; String value = "";
if (editRow) { if (editRow) {
value = rowRaw.getMap().get( value = rowRaw.getMap().get(
@ -410,7 +414,7 @@ public class EditRowPanel extends FramedPanel
protected FieldLabel retrieveDimensionLabel(final ColumnData col, protected FieldLabel retrieveDimensionLabel(final ColumnData col,
String label) { String label) {
Log.debug("retriveDimensionLabel on:"+col); Log.debug("retriveDimensionLabel on:" + col);
// comboDimension // comboDimension
DimensionRowsProperties propsDimension = GWT DimensionRowsProperties propsDimension = GWT
.create(DimensionRowsProperties.class); .create(DimensionRowsProperties.class);
@ -443,9 +447,8 @@ public class EditRowPanel extends FramedPanel
} }
}; };
String viewColumn = col.getRelationship().getTargetColumnId(); String viewColumn = col.getRelationship().getTargetColumnId();
String valueOnViewColumn = null; String valueOnViewColumn = null;
String rowId = null; String rowId = null;
if (editRow) { if (editRow) {
@ -554,11 +557,20 @@ public class EditRowPanel extends FramedPanel
ColumnDataType.Geometry.toString()) == 0) { ColumnDataType.Geometry.toString()) == 0) {
TextField geometry = (TextField) fieldLabel TextField geometry = (TextField) fieldLabel
.getWidget(); .getWidget();
String val = geometry.getCurrentValue(); if (geometry.isValid()) {
if (val == null) { String val = geometry.getCurrentValue();
val = ""; if (val == null) {
val = "";
}
maps.put(columnId, val);
} else {
UtilsGXT3
.alert("Attentions","The value of "+
colCurrent.getLabel()
+ " is not a valid text representation for geometry type ( e.g. POINT(34 56) or LINESTRING(65 34, 56.43 78.65)!");
btnSave.enable();
return;
} }
maps.put(columnId, val);
} else { } else {
if (colCurrent.getDataTypeName().compareTo( if (colCurrent.getDataTypeName().compareTo(
ColumnDataType.Integer.toString()) == 0) { ColumnDataType.Integer.toString()) == 0) {
@ -638,8 +650,6 @@ public class EditRowPanel extends FramedPanel
} }
protected void callEditRow(EditRowSession editRowSession) { protected void callEditRow(EditRowSession editRowSession) {
TDGWTServiceAsync.INSTANCE.startEditRow(editRowSession, TDGWTServiceAsync.INSTANCE.startEditRow(editRowSession,
@ -663,8 +673,7 @@ public class EditRowPanel extends FramedPanel
}); });
} }
protected void close() { protected void close() {
if (parent != null) { if (parent != null) {
parent.close(); parent.close();