From 94d448258152f82881684d98627e0aa01ffc7383 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 19 Sep 2014 15:54:16 +0000 Subject: [PATCH] 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 --- .../tablewidget/client/rows/EditRowPanel.java | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/rows/EditRowPanel.java b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/rows/EditRowPanel.java index b89c937..08225ce 100644 --- a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/rows/EditRowPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/rows/EditRowPanel.java @@ -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.Radio; import com.sencha.gxt.widget.core.client.form.TextField; +import com.sencha.gxt.widget.core.client.form.validator.RegExValidator; /** * * @author "Giancarlo Panichi" * */ -public class EditRowPanel extends FramedPanel - implements MonitorDialogListener { +public class EditRowPanel extends FramedPanel 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 HEIGHT = "370px"; protected String FIELDSHEIGHT = "370px"; @@ -81,8 +84,6 @@ public class EditRowPanel extends FramedPanel protected RowRaw rowRaw; protected boolean editRow; - - protected VerticalLayoutContainer v; private TextButton btnSave; private TextButton btnClose; @@ -225,7 +226,7 @@ public class EditRowPanel extends FramedPanel protected ArrayList generateFields() { ArrayList fields = new ArrayList(); - + for (ColumnData col : columns) { String label = new String(); if (col != null && col.getLabel() != null) { @@ -325,6 +326,9 @@ public class EditRowPanel extends FramedPanel if (col.getDataTypeName().compareTo( ColumnDataType.Geometry.toString()) == 0) { TextField geometry = new TextField(); + geometry.addValidator(new RegExValidator( + GEOMETRY_REGEXPR, + "Geometry Type not valid")); String value = ""; if (editRow) { value = rowRaw.getMap().get( @@ -410,7 +414,7 @@ public class EditRowPanel extends FramedPanel protected FieldLabel retrieveDimensionLabel(final ColumnData col, String label) { - Log.debug("retriveDimensionLabel on:"+col); + Log.debug("retriveDimensionLabel on:" + col); // comboDimension DimensionRowsProperties propsDimension = GWT .create(DimensionRowsProperties.class); @@ -443,9 +447,8 @@ public class EditRowPanel extends FramedPanel } }; - String viewColumn = col.getRelationship().getTargetColumnId(); - + String valueOnViewColumn = null; String rowId = null; if (editRow) { @@ -554,11 +557,20 @@ public class EditRowPanel extends FramedPanel ColumnDataType.Geometry.toString()) == 0) { TextField geometry = (TextField) fieldLabel .getWidget(); - String val = geometry.getCurrentValue(); - if (val == null) { - val = ""; + if (geometry.isValid()) { + String val = geometry.getCurrentValue(); + 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 { if (colCurrent.getDataTypeName().compareTo( ColumnDataType.Integer.toString()) == 0) { @@ -638,8 +650,6 @@ public class EditRowPanel extends FramedPanel } - - protected void callEditRow(EditRowSession editRowSession) { TDGWTServiceAsync.INSTANCE.startEditRow(editRowSession, @@ -663,8 +673,7 @@ public class EditRowPanel extends FramedPanel }); } - - + protected void close() { if (parent != null) { parent.close();