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.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<FieldLabel> generateFields() {
ArrayList<FieldLabel> fields = new ArrayList<FieldLabel>();
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();