Updated Geometry Type Support
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@100061 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2b43228854
commit
4dfe6711ff
|
@ -45,6 +45,8 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||||
|
import com.google.gwt.regexp.shared.MatchResult;
|
||||||
|
import com.google.gwt.regexp.shared.RegExp;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.web.bindery.event.shared.EventBus;
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
||||||
|
@ -73,6 +75,9 @@ import com.sencha.gxt.widget.core.client.info.Info;
|
||||||
*/
|
*/
|
||||||
public class AddColumnPanel extends FramedPanel implements
|
public class AddColumnPanel extends FramedPanel implements
|
||||||
CodelistSelectionListener, MonitorDialogListener {
|
CodelistSelectionListener, 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 static final String WIDTH = "640px";
|
protected static final String WIDTH = "640px";
|
||||||
protected static final String HEIGHT = "520px";
|
protected static final String HEIGHT = "520px";
|
||||||
|
|
||||||
|
@ -106,17 +111,16 @@ public class AddColumnPanel extends FramedPanel implements
|
||||||
protected ListStore<LocaleTypeElement> storeComboLocaleType;
|
protected ListStore<LocaleTypeElement> storeComboLocaleType;
|
||||||
|
|
||||||
protected AddColumnSession addColumnSession;
|
protected AddColumnSession addColumnSession;
|
||||||
|
|
||||||
protected TextButton btnAddColumn;
|
protected TextButton btnAddColumn;
|
||||||
|
|
||||||
protected TextField label;
|
protected TextField label;
|
||||||
protected TextField defaultValueString;
|
protected TextField defaultValueString;
|
||||||
protected DateField defaultValueDate;
|
protected DateField defaultValueDate;
|
||||||
|
|
||||||
protected FieldLabel defaultStringLabel;
|
protected FieldLabel defaultStringLabel;
|
||||||
protected FieldLabel defaultDateLabel;
|
protected FieldLabel defaultDateLabel;
|
||||||
|
|
||||||
|
|
||||||
private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,7 +138,7 @@ public class AddColumnPanel extends FramedPanel implements
|
||||||
init();
|
init();
|
||||||
create();
|
create();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
|
@ -149,7 +153,6 @@ public class AddColumnPanel extends FramedPanel implements
|
||||||
init();
|
init();
|
||||||
create();
|
create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void init() {
|
protected void init() {
|
||||||
setWidth(WIDTH);
|
setWidth(WIDTH);
|
||||||
|
@ -161,22 +164,22 @@ public class AddColumnPanel extends FramedPanel implements
|
||||||
protected void create() {
|
protected void create() {
|
||||||
// Label
|
// Label
|
||||||
label = new TextField();
|
label = new TextField();
|
||||||
|
|
||||||
//TODO
|
// TODO
|
||||||
// Default Value
|
// Default Value
|
||||||
defaultValueString = new TextField();
|
defaultValueString = new TextField();
|
||||||
defaultStringLabel= new FieldLabel(defaultValueString, "Default");
|
defaultStringLabel = new FieldLabel(defaultValueString, "Default");
|
||||||
|
|
||||||
defaultValueDate = new DateField();
|
defaultValueDate = new DateField();
|
||||||
defaultDateLabel = new FieldLabel(defaultValueDate, "Default");
|
defaultDateLabel = new FieldLabel(defaultValueDate, "Default");
|
||||||
|
|
||||||
|
|
||||||
// comboColumnTypeCode
|
// comboColumnTypeCode
|
||||||
ColumnTypeCodeProperties propsColumnTypeCode = GWT
|
ColumnTypeCodeProperties propsColumnTypeCode = GWT
|
||||||
.create(ColumnTypeCodeProperties.class);
|
.create(ColumnTypeCodeProperties.class);
|
||||||
ListStore<ColumnTypeCodeElement> storeComboTypeCode = new ListStore<ColumnTypeCodeElement>(
|
ListStore<ColumnTypeCodeElement> storeComboTypeCode = new ListStore<ColumnTypeCodeElement>(
|
||||||
propsColumnTypeCode.id());
|
propsColumnTypeCode.id());
|
||||||
storeComboTypeCode.addAll(ColumnTypeCodeStore.getColumnTypeCodesForAddColumn(trId));
|
storeComboTypeCode.addAll(ColumnTypeCodeStore
|
||||||
|
.getColumnTypeCodesForAddColumn(trId));
|
||||||
|
|
||||||
comboColumnTypeCode = new ComboBox<ColumnTypeCodeElement>(
|
comboColumnTypeCode = new ComboBox<ColumnTypeCodeElement>(
|
||||||
storeComboTypeCode, propsColumnTypeCode.label());
|
storeComboTypeCode, propsColumnTypeCode.label());
|
||||||
|
@ -318,15 +321,13 @@ public class AddColumnPanel extends FramedPanel implements
|
||||||
|
|
||||||
comboTimeDimensionTypeLabel = new FieldLabel(comboTimeDimensionType,
|
comboTimeDimensionTypeLabel = new FieldLabel(comboTimeDimensionType,
|
||||||
"Time Type");
|
"Time Type");
|
||||||
|
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
btnAddColumn = new TextButton("Add");
|
btnAddColumn = new TextButton("Add");
|
||||||
btnAddColumn.setIcon(ResourceBundle.INSTANCE.columnAdd());
|
btnAddColumn.setIcon(ResourceBundle.INSTANCE.columnAdd());
|
||||||
btnAddColumn.setIconAlign(IconAlign.RIGHT);
|
btnAddColumn.setIconAlign(IconAlign.RIGHT);
|
||||||
btnAddColumn.setTitle("Add Column");
|
btnAddColumn.setTitle("Add Column");
|
||||||
|
|
||||||
|
|
||||||
SelectHandler changeHandler = new SelectHandler() {
|
SelectHandler changeHandler = new SelectHandler() {
|
||||||
|
|
||||||
public void onSelect(SelectEvent event) {
|
public void onSelect(SelectEvent event) {
|
||||||
|
@ -353,13 +354,11 @@ public class AddColumnPanel extends FramedPanel implements
|
||||||
new Margins(1)));
|
new Margins(1)));
|
||||||
v.add(comboTimeDimensionTypeLabel, new VerticalLayoutData(1, -1,
|
v.add(comboTimeDimensionTypeLabel, new VerticalLayoutData(1, -1,
|
||||||
new Margins(1)));
|
new Margins(1)));
|
||||||
|
|
||||||
v.add(defaultStringLabel, new VerticalLayoutData(
|
v.add(defaultStringLabel, new VerticalLayoutData(1, -1, new Margins(1)));
|
||||||
1, -1, new Margins(1)));
|
v.add(defaultDateLabel, new VerticalLayoutData(1, -1, new Margins(1)));
|
||||||
v.add(defaultDateLabel, new VerticalLayoutData(
|
v.add(btnAddColumn, new VerticalLayoutData(-1, -1, new Margins(10, 0,
|
||||||
1, -1, new Margins(1)));
|
10, 0)));
|
||||||
v.add(btnAddColumn,
|
|
||||||
new VerticalLayoutData(-1, -1, new Margins(10, 0, 10, 0)));
|
|
||||||
add(v, new VerticalLayoutData(-1, -1, new Margins(0)));
|
add(v, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||||
|
|
||||||
comboMeasureTypeLabel.setVisible(false);
|
comboMeasureTypeLabel.setVisible(false);
|
||||||
|
@ -368,7 +367,7 @@ public class AddColumnPanel extends FramedPanel implements
|
||||||
comboColumnReferenceTypeLabel.setVisible(false);
|
comboColumnReferenceTypeLabel.setVisible(false);
|
||||||
comboTimeDimensionTypeLabel.setVisible(false);
|
comboTimeDimensionTypeLabel.setVisible(false);
|
||||||
comboLocaleTypeLabel.setVisible(false);
|
comboLocaleTypeLabel.setVisible(false);
|
||||||
|
|
||||||
defaultDateLabel.setVisible(false);
|
defaultDateLabel.setVisible(false);
|
||||||
defaultStringLabel.setVisible(false);
|
defaultStringLabel.setVisible(false);
|
||||||
|
|
||||||
|
@ -559,7 +558,7 @@ public class AddColumnPanel extends FramedPanel implements
|
||||||
comboTimeDimensionTypeLabel.setVisible(false);
|
comboTimeDimensionTypeLabel.setVisible(false);
|
||||||
defaultStringLabel.setVisible(false);
|
defaultStringLabel.setVisible(false);
|
||||||
defaultDateLabel.setVisible(false);
|
defaultDateLabel.setVisible(false);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MEASURE:
|
case MEASURE:
|
||||||
comboLocaleTypeLabel.setVisible(false);
|
comboLocaleTypeLabel.setVisible(false);
|
||||||
|
@ -632,7 +631,7 @@ public class AddColumnPanel extends FramedPanel implements
|
||||||
defaultDateLabel.setVisible(false);
|
defaultDateLabel.setVisible(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
forceLayout();
|
forceLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -692,28 +691,47 @@ public class AddColumnPanel extends FramedPanel implements
|
||||||
ColumnDataType dataType = columnDataTypeElement
|
ColumnDataType dataType = columnDataTypeElement
|
||||||
.getType();
|
.getType();
|
||||||
if (dataType != null) {
|
if (dataType != null) {
|
||||||
if(dataType==ColumnDataType.Date){
|
if (dataType == ColumnDataType.Geometry) {
|
||||||
Date d = defaultValueDate.getCurrentValue();
|
// TODO
|
||||||
if(d==null){
|
RegExp regExp = RegExp
|
||||||
UtilsGXT3.alert("Attention",
|
.compile(GEOMETRY_REGEXPR);
|
||||||
"Column data type not selected!");
|
MatchResult matcher = regExp.exec(defaultV);
|
||||||
} else {
|
boolean matchFound = matcher != null;
|
||||||
String dateS = sdf.format(d);
|
if (matchFound) {
|
||||||
defNewColumn = new DefNewColumn(labelS, type,
|
defNewColumn = new DefNewColumn(labelS,
|
||||||
dataType, dateS);
|
type, dataType, defaultV);
|
||||||
addColumnSession = new AddColumnSession(trId,
|
addColumnSession = new AddColumnSession(
|
||||||
defNewColumn);
|
trId, defNewColumn);
|
||||||
callAddColumm();
|
callAddColumm();
|
||||||
|
} else {
|
||||||
|
UtilsGXT3
|
||||||
|
.alert("Attention",
|
||||||
|
"The default value is not a valid text representation for geometry type ( e.g. POINT(34 56) or LINESTRING(65 34, 56.43 78.65)!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
defNewColumn = new DefNewColumn(labelS, type,
|
if (dataType == ColumnDataType.Date) {
|
||||||
dataType, defaultV);
|
Date d = defaultValueDate.getCurrentValue();
|
||||||
addColumnSession = new AddColumnSession(trId,
|
if (d == null) {
|
||||||
defNewColumn);
|
UtilsGXT3
|
||||||
callAddColumm();
|
.alert("Attention",
|
||||||
|
"Column data type not selected!");
|
||||||
|
} else {
|
||||||
|
String dateS = sdf.format(d);
|
||||||
|
defNewColumn = new DefNewColumn(labelS,
|
||||||
|
type, dataType, dateS);
|
||||||
|
addColumnSession = new AddColumnSession(
|
||||||
|
trId, defNewColumn);
|
||||||
|
callAddColumm();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
defNewColumn = new DefNewColumn(labelS,
|
||||||
|
type, dataType, defaultV);
|
||||||
|
addColumnSession = new AddColumnSession(
|
||||||
|
trId, defNewColumn);
|
||||||
|
callAddColumm();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
UtilsGXT3.alert("Attention",
|
UtilsGXT3.alert("Attention",
|
||||||
|
@ -928,15 +946,13 @@ public class AddColumnPanel extends FramedPanel implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
parent.close();
|
parent.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
// /
|
||||||
protected void openMonitorDialog(String taskId) {
|
protected void openMonitorDialog(String taskId) {
|
||||||
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
|
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
|
||||||
monitorDialog.addProgressDialogListener(this);
|
monitorDialog.addProgressDialogListener(this);
|
||||||
|
@ -980,5 +996,5 @@ public class AddColumnPanel extends FramedPanel implements
|
||||||
close();
|
close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue