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.SelectionHandler;
|
||||
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.web.bindery.event.shared.EventBus;
|
||||
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
|
||||
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 HEIGHT = "520px";
|
||||
|
||||
|
@ -116,7 +121,6 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
protected FieldLabel defaultStringLabel;
|
||||
protected FieldLabel defaultDateLabel;
|
||||
|
||||
|
||||
private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
||||
|
||||
/**
|
||||
|
@ -150,7 +154,6 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
create();
|
||||
}
|
||||
|
||||
|
||||
protected void init() {
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
|
@ -162,21 +165,21 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
// Label
|
||||
label = new TextField();
|
||||
|
||||
//TODO
|
||||
// TODO
|
||||
// Default Value
|
||||
defaultValueString = new TextField();
|
||||
defaultStringLabel= new FieldLabel(defaultValueString, "Default");
|
||||
defaultStringLabel = new FieldLabel(defaultValueString, "Default");
|
||||
|
||||
defaultValueDate = new DateField();
|
||||
defaultDateLabel = new FieldLabel(defaultValueDate, "Default");
|
||||
|
||||
|
||||
// comboColumnTypeCode
|
||||
ColumnTypeCodeProperties propsColumnTypeCode = GWT
|
||||
.create(ColumnTypeCodeProperties.class);
|
||||
ListStore<ColumnTypeCodeElement> storeComboTypeCode = new ListStore<ColumnTypeCodeElement>(
|
||||
propsColumnTypeCode.id());
|
||||
storeComboTypeCode.addAll(ColumnTypeCodeStore.getColumnTypeCodesForAddColumn(trId));
|
||||
storeComboTypeCode.addAll(ColumnTypeCodeStore
|
||||
.getColumnTypeCodesForAddColumn(trId));
|
||||
|
||||
comboColumnTypeCode = new ComboBox<ColumnTypeCodeElement>(
|
||||
storeComboTypeCode, propsColumnTypeCode.label());
|
||||
|
@ -319,14 +322,12 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
comboTimeDimensionTypeLabel = new FieldLabel(comboTimeDimensionType,
|
||||
"Time Type");
|
||||
|
||||
|
||||
// Save
|
||||
btnAddColumn = new TextButton("Add");
|
||||
btnAddColumn.setIcon(ResourceBundle.INSTANCE.columnAdd());
|
||||
btnAddColumn.setIconAlign(IconAlign.RIGHT);
|
||||
btnAddColumn.setTitle("Add Column");
|
||||
|
||||
|
||||
SelectHandler changeHandler = new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
|
@ -354,12 +355,10 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
v.add(comboTimeDimensionTypeLabel, new VerticalLayoutData(1, -1,
|
||||
new Margins(1)));
|
||||
|
||||
v.add(defaultStringLabel, new VerticalLayoutData(
|
||||
1, -1, new Margins(1)));
|
||||
v.add(defaultDateLabel, new VerticalLayoutData(
|
||||
1, -1, new Margins(1)));
|
||||
v.add(btnAddColumn,
|
||||
new VerticalLayoutData(-1, -1, new Margins(10, 0, 10, 0)));
|
||||
v.add(defaultStringLabel, new VerticalLayoutData(1, -1, new Margins(1)));
|
||||
v.add(defaultDateLabel, new VerticalLayoutData(1, -1, new Margins(1)));
|
||||
v.add(btnAddColumn, new VerticalLayoutData(-1, -1, new Margins(10, 0,
|
||||
10, 0)));
|
||||
add(v, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||
|
||||
comboMeasureTypeLabel.setVisible(false);
|
||||
|
@ -692,29 +691,48 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
ColumnDataType dataType = columnDataTypeElement
|
||||
.getType();
|
||||
if (dataType != null) {
|
||||
if(dataType==ColumnDataType.Date){
|
||||
Date d = defaultValueDate.getCurrentValue();
|
||||
if(d==null){
|
||||
UtilsGXT3.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);
|
||||
if (dataType == ColumnDataType.Geometry) {
|
||||
// TODO
|
||||
RegExp regExp = RegExp
|
||||
.compile(GEOMETRY_REGEXPR);
|
||||
MatchResult matcher = regExp.exec(defaultV);
|
||||
boolean matchFound = matcher != null;
|
||||
if (matchFound) {
|
||||
defNewColumn = new DefNewColumn(labelS,
|
||||
type, dataType, defaultV);
|
||||
addColumnSession = new AddColumnSession(
|
||||
trId, defNewColumn);
|
||||
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 {
|
||||
defNewColumn = new DefNewColumn(labelS, type,
|
||||
dataType, defaultV);
|
||||
addColumnSession = new AddColumnSession(trId,
|
||||
defNewColumn);
|
||||
callAddColumm();
|
||||
if (dataType == ColumnDataType.Date) {
|
||||
Date d = defaultValueDate.getCurrentValue();
|
||||
if (d == null) {
|
||||
UtilsGXT3
|
||||
.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 {
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Column data type not selected!");
|
||||
|
@ -928,15 +946,13 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void close() {
|
||||
if (parent != null) {
|
||||
parent.close();
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
// /
|
||||
protected void openMonitorDialog(String taskId) {
|
||||
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
|
||||
monitorDialog.addProgressDialogListener(this);
|
||||
|
|
Loading…
Reference in New Issue