From 9601ce03dba5735eb028c2459cd25bbd791117d9 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 6 Feb 2015 09:27:56 +0000 Subject: [PATCH] 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 --- .../client/ChangeColumnTypePanel.java | 128 +++++++++++++++--- 1 file changed, 106 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/ChangeColumnTypePanel.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/ChangeColumnTypePanel.java index 94fb483..1286341 100644 --- a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/ChangeColumnTypePanel.java +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/ChangeColumnTypePanel.java @@ -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> valueDataFormatMap; + private String columnName; private ColumnData sourceColumnChangeType; private ColumnData columnRequested; @@ -127,7 +129,7 @@ public class ChangeColumnTypePanel extends FramedPanel implements private ListStore storeComboValueDataFormat; private ComboBox comboValueDataFormat; private FieldLabel comboValueDataFormatLabel; - + private ComboBox comboLocaleType = null; private FieldLabel comboLocaleTypeLabel; private ListStore 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>>() { + + @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> 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 labelProvider) { comboValueDataFormat .addSelectionHandler(new SelectionHandler() { - public void onSelection(SelectionEvent event) { + public void onSelection( + SelectionEvent 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 valueDataFormats = valueDataFormatMap + .get(type); + comboValueDataFormat.clear(); + comboValueDataFormat.reset(); + comboValueDataFormat.getStore().clear(); + comboValueDataFormat.getStore().addAll(valueDataFormats); + comboValueDataFormat.redraw(); } protected void updateAttributeType(ColumnDataType type) { + ArrayList 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 timeDataFormats = periodDataType + ArrayList 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 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 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 timeDataFormats = cd + ArrayList 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",