Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@96384 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4c77dd7c1e
commit
58b1a982f5
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.td.columnwidget.client.create;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.CodelistSelectionDialog;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.CodelistSelectionListener;
|
||||
|
@ -43,6 +44,7 @@ import com.google.gwt.core.client.Scheduler;
|
|||
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.user.client.rpc.AsyncCallback;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
||||
|
@ -59,6 +61,7 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
|||
import com.sencha.gxt.widget.core.client.event.TriggerClickEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.TriggerClickEvent.TriggerClickHandler;
|
||||
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
||||
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.TextField;
|
||||
import com.sencha.gxt.widget.core.client.info.Info;
|
||||
|
@ -108,7 +111,14 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
protected TextButton btnAddColumn;
|
||||
|
||||
protected TextField label;
|
||||
protected TextField defaultValue;
|
||||
protected TextField defaultValueString;
|
||||
protected DateField defaultValueDate;
|
||||
|
||||
protected FieldLabel defaultStringLabel;
|
||||
protected FieldLabel defaultDateLabel;
|
||||
|
||||
|
||||
private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -152,10 +162,16 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
protected void create() {
|
||||
// Label
|
||||
label = new TextField();
|
||||
|
||||
|
||||
//TODO
|
||||
// Default Value
|
||||
defaultValue = new TextField();
|
||||
|
||||
defaultValueString = new TextField();
|
||||
defaultStringLabel= new FieldLabel(defaultValueString, "Default");
|
||||
|
||||
defaultValueDate = new DateField();
|
||||
defaultDateLabel = new FieldLabel(defaultValueDate, "Default");
|
||||
|
||||
|
||||
// comboColumnTypeCode
|
||||
ColumnTypeCodeProperties propsColumnTypeCode = GWT
|
||||
.create(ColumnTypeCodeProperties.class);
|
||||
|
@ -338,7 +354,10 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
new Margins(1)));
|
||||
v.add(comboTimeDimensionTypeLabel, new VerticalLayoutData(1, -1,
|
||||
new Margins(1)));
|
||||
v.add(new FieldLabel(defaultValue, "Default"), new VerticalLayoutData(
|
||||
|
||||
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)));
|
||||
|
@ -350,6 +369,9 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
comboColumnReferenceTypeLabel.setVisible(false);
|
||||
comboTimeDimensionTypeLabel.setVisible(false);
|
||||
comboLocaleTypeLabel.setVisible(false);
|
||||
|
||||
defaultDateLabel.setVisible(false);
|
||||
defaultStringLabel.setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
|
@ -516,6 +538,8 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
comboDimensionTypeLabel.setVisible(false);
|
||||
comboColumnReferenceTypeLabel.setVisible(false);
|
||||
comboTimeDimensionTypeLabel.setVisible(false);
|
||||
defaultStringLabel.setVisible(true);
|
||||
defaultDateLabel.setVisible(false);
|
||||
break;
|
||||
case ATTRIBUTE:
|
||||
comboLocaleTypeLabel.setVisible(false);
|
||||
|
@ -524,6 +548,8 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
comboDimensionTypeLabel.setVisible(false);
|
||||
comboColumnReferenceTypeLabel.setVisible(false);
|
||||
comboTimeDimensionTypeLabel.setVisible(false);
|
||||
defaultStringLabel.setVisible(false);
|
||||
defaultDateLabel.setVisible(false);
|
||||
break;
|
||||
case DIMENSION:
|
||||
comboLocaleTypeLabel.setVisible(false);
|
||||
|
@ -532,6 +558,9 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
comboDimensionTypeLabel.setVisible(true);
|
||||
comboColumnReferenceTypeLabel.setVisible(false);
|
||||
comboTimeDimensionTypeLabel.setVisible(false);
|
||||
defaultStringLabel.setVisible(false);
|
||||
defaultDateLabel.setVisible(false);
|
||||
|
||||
break;
|
||||
case MEASURE:
|
||||
comboLocaleTypeLabel.setVisible(false);
|
||||
|
@ -540,6 +569,8 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
comboDimensionTypeLabel.setVisible(false);
|
||||
comboColumnReferenceTypeLabel.setVisible(false);
|
||||
comboTimeDimensionTypeLabel.setVisible(false);
|
||||
defaultStringLabel.setVisible(true);
|
||||
defaultDateLabel.setVisible(false);
|
||||
break;
|
||||
case TIMEDIMENSION:
|
||||
comboLocaleTypeLabel.setVisible(false);
|
||||
|
@ -548,6 +579,8 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
comboDimensionTypeLabel.setVisible(false);
|
||||
comboColumnReferenceTypeLabel.setVisible(false);
|
||||
comboTimeDimensionTypeLabel.setVisible(true);
|
||||
defaultStringLabel.setVisible(false);
|
||||
defaultDateLabel.setVisible(false);
|
||||
break;
|
||||
default:
|
||||
comboLocaleTypeLabel.setVisible(false);
|
||||
|
@ -556,6 +589,8 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
comboDimensionTypeLabel.setVisible(false);
|
||||
comboColumnReferenceTypeLabel.setVisible(false);
|
||||
comboTimeDimensionTypeLabel.setVisible(false);
|
||||
defaultStringLabel.setVisible(true);
|
||||
defaultDateLabel.setVisible(false);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -567,6 +602,37 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
}
|
||||
|
||||
protected void updateAttributeType(ColumnDataType type) {
|
||||
Log.debug("Update ColumnTypeCode " + type.toString());
|
||||
switch (type) {
|
||||
case Boolean:
|
||||
defaultStringLabel.setVisible(true);
|
||||
defaultDateLabel.setVisible(false);
|
||||
break;
|
||||
case Date:
|
||||
defaultStringLabel.setVisible(false);
|
||||
defaultDateLabel.setVisible(true);
|
||||
break;
|
||||
case Geometry:
|
||||
defaultStringLabel.setVisible(true);
|
||||
defaultDateLabel.setVisible(false);
|
||||
break;
|
||||
case Integer:
|
||||
defaultStringLabel.setVisible(true);
|
||||
defaultDateLabel.setVisible(false);
|
||||
break;
|
||||
case Numeric:
|
||||
defaultStringLabel.setVisible(true);
|
||||
defaultDateLabel.setVisible(false);
|
||||
break;
|
||||
case Text:
|
||||
defaultStringLabel.setVisible(true);
|
||||
defaultDateLabel.setVisible(false);
|
||||
break;
|
||||
default:
|
||||
defaultStringLabel.setVisible(true);
|
||||
defaultDateLabel.setVisible(false);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -587,7 +653,7 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
protected void save() {
|
||||
DefNewColumn defNewColumn;
|
||||
|
||||
String defaultV = defaultValue.getCurrentValue();
|
||||
String defaultV = defaultValueString.getCurrentValue();
|
||||
String labelS = label.getCurrentValue();
|
||||
|
||||
if (labelS != null && !labelS.isEmpty()) {
|
||||
|
@ -625,11 +691,28 @@ public class AddColumnPanel extends FramedPanel implements
|
|||
ColumnDataType dataType = columnDataTypeElement
|
||||
.getType();
|
||||
if (dataType != null) {
|
||||
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",
|
||||
|
|
Loading…
Reference in New Issue