Updated ValueDataTypeFormat in Change Column Type

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@111759 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-02-06 09:27:56 +00:00
parent a5a9eec7dc
commit 9601ce03db
1 changed files with 106 additions and 22 deletions

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.td.columnwidget.client;
import java.util.ArrayList;
import java.util.HashMap;
import org.gcube.portlets.user.td.columnwidget.client.dimension.CodelistSelectionDialog;
import org.gcube.portlets.user.td.columnwidget.client.dimension.CodelistSelectionListener;
@ -43,7 +44,6 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.OperationResult;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeMap;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
@ -93,6 +93,8 @@ public class ChangeColumnTypePanel extends FramedPanel implements
private EventBus eventBus;
private ChangeColumnTypeDialog parent;
private TRId trId;
private HashMap<ColumnDataType, ArrayList<ValueDataFormat>> valueDataFormatMap;
private String columnName;
private ColumnData sourceColumnChangeType;
private ColumnData columnRequested;
@ -127,7 +129,7 @@ public class ChangeColumnTypePanel extends FramedPanel implements
private ListStore<ValueDataFormat> storeComboValueDataFormat;
private ComboBox<ValueDataFormat> comboValueDataFormat;
private FieldLabel comboValueDataFormatLabel;
private ComboBox<LocaleTypeElement> comboLocaleType = null;
private FieldLabel comboLocaleTypeLabel;
private ListStore<LocaleTypeElement> storeComboLocaleType;
@ -148,13 +150,44 @@ public class ChangeColumnTypePanel extends FramedPanel implements
this.columnName = columnName;
this.eventBus = eventBus;
panelCreated = false;
retrieveValueDataFormatMap();
}
protected void retrieveValueDataFormatMap() {
TDGWTServiceAsync.INSTANCE
.getValueDataFormatsMap(new AsyncCallback<HashMap<ColumnDataType, ArrayList<ValueDataFormat>>>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.debug("Error retrieving value data formats map: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error",
"Error retrieving value data formats map!");
}
}
@Override
public void onSuccess(
HashMap<ColumnDataType, ArrayList<ValueDataFormat>> result) {
valueDataFormatMap = result;
if (columnName != null && !columnName.isEmpty()) {
retrieveColumnRequested();
} else {
panelCreated = true;
create();
}
}
});
if (columnName != null && !columnName.isEmpty()) {
retrieveColumnRequested();
} else {
panelCreated = true;
create();
}
}
protected void retrieveColumnRequested() {
@ -711,7 +744,8 @@ public class ChangeColumnTypePanel extends FramedPanel implements
final LabelProvider<ValueDataFormat> labelProvider) {
comboValueDataFormat
.addSelectionHandler(new SelectionHandler<ValueDataFormat>() {
public void onSelection(SelectionEvent<ValueDataFormat> event) {
public void onSelection(
SelectionEvent<ValueDataFormat> event) {
Info.display(
"Time Format Selected",
"You selected "
@ -721,7 +755,8 @@ public class ChangeColumnTypePanel extends FramedPanel implements
+ "!"));
Log.debug("ComboTimeDataFormat selected: "
+ event.getSelectedItem());
ValueDataFormat timeDataFormat = event.getSelectedItem();
ValueDataFormat timeDataFormat = event
.getSelectedItem();
updateTimeDataFormat(timeDataFormat);
}
@ -749,7 +784,7 @@ public class ChangeColumnTypePanel extends FramedPanel implements
comboColumnReferenceTypeLabel.setVisible(false);
comboColumnMappingLabel.setVisible(false);
comboPeriodTypeLabel.setVisible(false);
comboValueDataFormatLabel.setVisible(false);
comboValueDataFormatLabel.setVisible(true);
break;
case DIMENSION:
comboLocaleTypeLabel.setVisible(false);
@ -769,7 +804,7 @@ public class ChangeColumnTypePanel extends FramedPanel implements
comboColumnReferenceTypeLabel.setVisible(false);
comboColumnMappingLabel.setVisible(false);
comboPeriodTypeLabel.setVisible(false);
comboValueDataFormatLabel.setVisible(false);
comboValueDataFormatLabel.setVisible(true);
break;
case TIMEDIMENSION:
comboLocaleTypeLabel.setVisible(false);
@ -801,10 +836,23 @@ public class ChangeColumnTypePanel extends FramedPanel implements
}
protected void updateMeasureType(ColumnDataType type) {
ArrayList<ValueDataFormat> valueDataFormats = valueDataFormatMap
.get(type);
comboValueDataFormat.clear();
comboValueDataFormat.reset();
comboValueDataFormat.getStore().clear();
comboValueDataFormat.getStore().addAll(valueDataFormats);
comboValueDataFormat.redraw();
}
protected void updateAttributeType(ColumnDataType type) {
ArrayList<ValueDataFormat> valueDataFormats = valueDataFormatMap
.get(type);
comboValueDataFormat.clear();
comboValueDataFormat.reset();
comboValueDataFormat.getStore().clear();
comboValueDataFormat.getStore().addAll(valueDataFormats);
comboValueDataFormat.redraw();
}
@ -813,12 +861,12 @@ public class ChangeColumnTypePanel extends FramedPanel implements
}
protected void updatePeriodType(PeriodDataType periodDataType) {
ArrayList<ValueDataFormat> timeDataFormats = periodDataType
ArrayList<ValueDataFormat> valueDataFormats = periodDataType
.getTimeDataFormats();
comboValueDataFormat.clear();
comboValueDataFormat.reset();
comboValueDataFormat.getStore().clear();
comboValueDataFormat.getStore().addAll(timeDataFormats);
comboValueDataFormat.getStore().addAll(valueDataFormats);
comboValueDataFormat.redraw();
}
@ -912,6 +960,15 @@ public class ChangeColumnTypePanel extends FramedPanel implements
.selectedMeasure(cd.getDataTypeName()));
comboMeasureType.setValue(ColumnDataTypeStore
.selectedMeasureElement(cd.getDataTypeName()));
ColumnDataType columnDataType = ColumnDataType
.getColumnDataTypeFromId(cd.getDataTypeName());
ArrayList<ValueDataFormat> valueDataFormats = valueDataFormatMap
.get(columnDataType);
comboValueDataFormat.clear();
comboValueDataFormat.reset();
comboValueDataFormat.getStore().clear();
comboValueDataFormat.getStore().addAll(valueDataFormats);
comboValueDataFormat.redraw();
} else {
if (type == ColumnTypeCode.ATTRIBUTE) {
@ -919,6 +976,15 @@ public class ChangeColumnTypePanel extends FramedPanel implements
.selectedAttribute(cd.getDataTypeName()));
comboAttributeType.setValue(ColumnDataTypeStore
.selectedAttributeElement(cd.getDataTypeName()));
ColumnDataType columnDataType = ColumnDataType
.getColumnDataTypeFromId(cd.getDataTypeName());
ArrayList<ValueDataFormat> valueDataFormats = valueDataFormatMap
.get(columnDataType);
comboValueDataFormat.clear();
comboValueDataFormat.reset();
comboValueDataFormat.getStore().clear();
comboValueDataFormat.getStore().addAll(valueDataFormats);
comboValueDataFormat.redraw();
} else {
if (type == ColumnTypeCode.CODENAME) {
setLocale(cd.getLocale());
@ -928,12 +994,13 @@ public class ChangeColumnTypePanel extends FramedPanel implements
changeColumnTypeSession.setPeriodDataType(cd
.getPeriodDataType());
comboPeriodType.setValue(cd.getPeriodDataType());
ArrayList<ValueDataFormat> timeDataFormats = cd
ArrayList<ValueDataFormat> valueDataFormats = cd
.getPeriodDataType().getTimeDataFormats();
comboValueDataFormat.clear();
comboValueDataFormat.reset();
comboValueDataFormat.getStore().clear();
comboValueDataFormat.getStore().addAll(timeDataFormats);
comboValueDataFormat.getStore()
.addAll(valueDataFormats);
comboValueDataFormat.redraw();
} else {
// TODO
@ -1057,8 +1124,8 @@ public class ChangeColumnTypePanel extends FramedPanel implements
// TODO
protected void configureBtnChange(ColumnTypeCode columnTypeCode) {
ColumnTypeCode sourceTypeCode = ColumnTypeMap
.getColumnTypeCode(sourceColumnChangeType.getTypeCode());
ColumnTypeCode sourceTypeCode = ColumnTypeCode
.getColumnTypeCodeFromId(sourceColumnChangeType.getTypeCode());
switch (sourceTypeCode) {
case ANNOTATION:
@ -1121,7 +1188,16 @@ public class ChangeColumnTypePanel extends FramedPanel implements
if (dataType != null) {
changeColumnTypeSession
.setColumnDataTypeTarget(dataType);
callChangeColumnType();
ValueDataFormat valueDataFormat = comboValueDataFormat
.getCurrentValue();
if (valueDataFormat != null) {
changeColumnTypeSession.setValueDataFormat(valueDataFormat);
callChangeColumnType();
} else {
UtilsGXT3.alert("Attention",
"Type format not selected!");
}
} else {
UtilsGXT3.alert("Attention",
"Column data type not selected!");
@ -1142,7 +1218,15 @@ public class ChangeColumnTypePanel extends FramedPanel implements
if (dataType != null) {
changeColumnTypeSession
.setColumnDataTypeTarget(dataType);
callChangeColumnType();
ValueDataFormat valueDataFormat = comboValueDataFormat
.getCurrentValue();
if (valueDataFormat != null) {
changeColumnTypeSession.setValueDataFormat(valueDataFormat);
callChangeColumnType();
} else {
UtilsGXT3.alert("Attention",
"Type format not selected!");
}
} else {
UtilsGXT3.alert("Attention",
"Column data type not selected!");
@ -1206,7 +1290,7 @@ public class ChangeColumnTypePanel extends FramedPanel implements
.getCurrentValue();
if (timeDataFormat != null) {
changeColumnTypeSession
.setTimeDataFormat(timeDataFormat);
.setValueDataFormat(timeDataFormat);
callChangeColumnType();
} else {
UtilsGXT3.alert("Attention",