Updated PeriodDataType

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@111677 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-02-04 17:09:16 +00:00
parent 28f2cefd80
commit c8b2e4c86a
2 changed files with 163 additions and 77 deletions

View File

@ -13,6 +13,7 @@ import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnTypeCodeP
import org.gcube.portlets.user.td.columnwidget.client.properties.LocaleTypeProperties;
import org.gcube.portlets.user.td.columnwidget.client.properties.PeriodDataTypeProperties;
import org.gcube.portlets.user.td.columnwidget.client.properties.TabResourceProperties;
import org.gcube.portlets.user.td.columnwidget.client.properties.TimeDataFormatProperties;
import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.columnwidget.client.store.ColumnDataTypeElement;
import org.gcube.portlets.user.td.columnwidget.client.store.ColumnDataTypeStore;
@ -28,6 +29,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.PeriodDataType;
import org.gcube.portlets.user.td.gwtservice.shared.tr.RefColumn;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TimeDataFormat;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.mapping.ColumnMappingList;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeSession;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
@ -118,9 +120,13 @@ public class ChangeColumnTypePanel extends FramedPanel implements
private FieldLabel comboColumnMappingLabel;
private ListStore<ColumnMappingList> storeComboColumnMapping;
private ComboBox<PeriodDataType> comboTimeDimensionType = null;
private FieldLabel comboTimeDimensionTypeLabel;
private ListStore<PeriodDataType> storeComboTimeDimensionType;
private ComboBox<PeriodDataType> comboPeriodType = null;
private FieldLabel comboPeriodTypeLabel;
private ListStore<PeriodDataType> storeComboPeriodType;
private ListStore<TimeDataFormat> storeComboTimeDataFormat;
private ComboBox<TimeDataFormat> comboTimeDataFormat;
private FieldLabel comboTimeDataFormatLabel;
private ComboBox<LocaleTypeElement> comboLocaleType = null;
private FieldLabel comboLocaleTypeLabel;
@ -133,7 +139,6 @@ public class ChangeColumnTypePanel extends FramedPanel implements
private ChangeColumnTypeSession changeColumnTypeSession;
private boolean panelCreated;
public ChangeColumnTypePanel(TRId trId, String columnName, EventBus eventBus) {
setWidth(WIDTH);
setHeight(HEIGHT);
@ -410,14 +415,14 @@ public class ChangeColumnTypePanel extends FramedPanel implements
comboColumnMappingLabel = new FieldLabel(comboColumnMapping, "Mapping");
// comboTimeDimensionType
PeriodDataTypeProperties propsTimeDimensionType = GWT
// comboPeriodType
PeriodDataTypeProperties propsPeriodDataType = GWT
.create(PeriodDataTypeProperties.class);
storeComboTimeDimensionType = new ListStore<PeriodDataType>(
propsTimeDimensionType.name());
storeComboPeriodType = new ListStore<PeriodDataType>(
propsPeriodDataType.name());
comboTimeDimensionType = new ComboBox<PeriodDataType>(
storeComboTimeDimensionType, propsTimeDimensionType.label()){
comboPeriodType = new ComboBox<PeriodDataType>(storeComboPeriodType,
propsPeriodDataType.label()) {
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@ -428,18 +433,35 @@ public class ChangeColumnTypePanel extends FramedPanel implements
}
};
Log.trace("ComboTimeDimensionType created");
Log.trace("ComboPeriodType created");
addHandlersForComboTimeDimensionType(propsTimeDimensionType.label());
addHandlersForComboPeriodType(propsPeriodDataType.label());
comboTimeDimensionType.setEmptyText("Select a time dimension type...");
comboTimeDimensionType.setWidth(191);
comboTimeDimensionType.setTypeAhead(true);
comboTimeDimensionType.setTriggerAction(TriggerAction.ALL);
// comboTimeDimensionType.getListView().getElement().applyStyles("width:170px;");
comboPeriodType.setEmptyText("Select a period type...");
comboPeriodType.setWidth(191);
comboPeriodType.setTypeAhead(true);
comboPeriodType.setTriggerAction(TriggerAction.ALL);
comboPeriodTypeLabel = new FieldLabel(comboPeriodType, "Period Type");
comboTimeDimensionTypeLabel = new FieldLabel(comboTimeDimensionType,
"Time Type");
// comboTimeDataFormat
TimeDataFormatProperties propsTimeDataFormat = GWT
.create(TimeDataFormatProperties.class);
storeComboTimeDataFormat = new ListStore<TimeDataFormat>(
propsTimeDataFormat.id());
comboTimeDataFormat = new ComboBox<TimeDataFormat>(
storeComboTimeDataFormat, propsTimeDataFormat.example());
Log.trace("ComboTimeDataFormat created");
addHandlersForComboTimeDataFormat(propsTimeDataFormat.example());
comboTimeDataFormat.setEmptyText("Select a time format...");
comboTimeDataFormat.setWidth(191);
comboTimeDataFormat.setTypeAhead(true);
comboTimeDataFormat.setTriggerAction(TriggerAction.ALL);
comboTimeDataFormatLabel = new FieldLabel(comboTimeDataFormat,
"Time Format");
// Change
change = new TextButton("Change");
@ -475,7 +497,9 @@ public class ChangeColumnTypePanel extends FramedPanel implements
* v.add(comboColumnMappingLabel, new VerticalLayoutData(1, -1, new
* Margins(1)));
*/
v.add(comboTimeDimensionTypeLabel, new VerticalLayoutData(1, -1,
v.add(comboPeriodTypeLabel, new VerticalLayoutData(1, -1,
new Margins(1)));
v.add(comboTimeDataFormatLabel, new VerticalLayoutData(1, -1,
new Margins(1)));
v.add(change, new VerticalLayoutData(-1, -1, new Margins(10, 0, 10, 0)));
add(v, new VerticalLayoutData(1, 1, new Margins(0)));
@ -491,7 +515,8 @@ public class ChangeColumnTypePanel extends FramedPanel implements
comboDimensionTypeLabel.setVisible(false);
comboColumnReferenceTypeLabel.setVisible(false);
comboColumnMappingLabel.setVisible(false);
comboTimeDimensionTypeLabel.setVisible(false);
comboPeriodTypeLabel.setVisible(false);
comboTimeDataFormat.setValidateOnBlur(false);
comboLocaleTypeLabel.setVisible(false);
}
@ -638,20 +663,6 @@ public class ChangeColumnTypePanel extends FramedPanel implements
Log.debug("ComboColumnReferenceType selected: "
+ event.getSelectedItem());
//Change column enables the Change Button
//ColumnData columnReference = event.getSelectedItem();
//updateConfBtnChange(columnReference);
// TODO Mapping fix
/*
* comboColumnMapping.reset();
* storeComboColumnMapping.clear();
* storeComboColumnMapping.commitChanges();
* comboColumnMappingLabel.setVisible(true);
* forceLayout();
*/
}
});
@ -675,30 +686,48 @@ public class ChangeColumnTypePanel extends FramedPanel implements
}
protected void addHandlersForComboTimeDimensionType(
protected void addHandlersForComboPeriodType(
final LabelProvider<PeriodDataType> labelProvider) {
comboTimeDimensionType
comboPeriodType
.addSelectionHandler(new SelectionHandler<PeriodDataType>() {
public void onSelection(
SelectionEvent<PeriodDataType> event) {
public void onSelection(SelectionEvent<PeriodDataType> event) {
Info.display(
"Time Dimension Type Selected",
"Period Type Selected",
"You selected "
+ (event.getSelectedItem() == null ? "nothing"
: labelProvider.getLabel(event
.getSelectedItem())
+ "!"));
Log.debug("ComboTimeDimensionType selected: "
Log.debug("ComboPeriodType selected: "
+ event.getSelectedItem());
PeriodDataType timeDimensionType = event
.getSelectedItem();
updateTimeDimensionType(timeDimensionType);
PeriodDataType periodDataType = event.getSelectedItem();
updatePeriodType(periodDataType);
}
});
}
protected void addHandlersForComboTimeDataFormat(
final LabelProvider<TimeDataFormat> labelProvider) {
comboTimeDataFormat
.addSelectionHandler(new SelectionHandler<TimeDataFormat>() {
public void onSelection(SelectionEvent<TimeDataFormat> event) {
Info.display(
"Time Format Selected",
"You selected "
+ (event.getSelectedItem() == null ? "nothing"
: labelProvider.getLabel(event
.getSelectedItem())
+ "!"));
Log.debug("ComboTimeDataFormat selected: "
+ event.getSelectedItem());
TimeDataFormat timeDataFormat = event.getSelectedItem();
updateTimeDataFormat(timeDataFormat);
}
});
}
// TODO
protected void updateColumnType(ColumnTypeCode type) {
Log.debug("Update ColumnTypeCode: " + type);
switch (type) {
@ -709,7 +738,8 @@ public class ChangeColumnTypePanel extends FramedPanel implements
comboDimensionTypeLabel.setVisible(false);
comboColumnReferenceTypeLabel.setVisible(false);
comboColumnMappingLabel.setVisible(false);
comboTimeDimensionTypeLabel.setVisible(false);
comboPeriodTypeLabel.setVisible(false);
comboTimeDataFormatLabel.setVisible(false);
break;
case ATTRIBUTE:
comboLocaleTypeLabel.setVisible(false);
@ -718,7 +748,8 @@ public class ChangeColumnTypePanel extends FramedPanel implements
comboDimensionTypeLabel.setVisible(false);
comboColumnReferenceTypeLabel.setVisible(false);
comboColumnMappingLabel.setVisible(false);
comboTimeDimensionTypeLabel.setVisible(false);
comboPeriodTypeLabel.setVisible(false);
comboTimeDataFormatLabel.setVisible(false);
break;
case DIMENSION:
comboLocaleTypeLabel.setVisible(false);
@ -727,7 +758,8 @@ public class ChangeColumnTypePanel extends FramedPanel implements
comboDimensionTypeLabel.setVisible(true);
comboColumnReferenceTypeLabel.setVisible(false);
comboColumnMappingLabel.setVisible(false);
comboTimeDimensionTypeLabel.setVisible(false);
comboPeriodTypeLabel.setVisible(false);
comboTimeDataFormatLabel.setVisible(false);
break;
case MEASURE:
comboLocaleTypeLabel.setVisible(false);
@ -736,7 +768,8 @@ public class ChangeColumnTypePanel extends FramedPanel implements
comboDimensionTypeLabel.setVisible(false);
comboColumnReferenceTypeLabel.setVisible(false);
comboColumnMappingLabel.setVisible(false);
comboTimeDimensionTypeLabel.setVisible(false);
comboPeriodTypeLabel.setVisible(false);
comboTimeDataFormatLabel.setVisible(false);
break;
case TIMEDIMENSION:
comboLocaleTypeLabel.setVisible(false);
@ -745,7 +778,8 @@ public class ChangeColumnTypePanel extends FramedPanel implements
comboDimensionTypeLabel.setVisible(false);
comboColumnReferenceTypeLabel.setVisible(false);
comboColumnMappingLabel.setVisible(false);
comboTimeDimensionTypeLabel.setVisible(true);
comboPeriodTypeLabel.setVisible(true);
comboTimeDataFormatLabel.setVisible(true);
break;
default:
comboLocaleTypeLabel.setVisible(false);
@ -754,7 +788,8 @@ public class ChangeColumnTypePanel extends FramedPanel implements
comboDimensionTypeLabel.setVisible(false);
comboColumnReferenceTypeLabel.setVisible(false);
comboColumnMappingLabel.setVisible(false);
comboTimeDimensionTypeLabel.setVisible(false);
comboPeriodTypeLabel.setVisible(false);
comboTimeDataFormatLabel.setVisible(false);
break;
}
@ -777,7 +812,18 @@ public class ChangeColumnTypePanel extends FramedPanel implements
}
protected void updateTimeDimensionType(PeriodDataType type) {
protected void updatePeriodType(PeriodDataType periodDataType) {
ArrayList<TimeDataFormat> timeDataFormats = periodDataType
.getTimeDataFormats();
comboTimeDataFormat.clear();
comboTimeDataFormat.reset();
comboTimeDataFormat.getStore().clear();
comboTimeDataFormat.getStore().addAll(timeDataFormats);
comboTimeDataFormat.redraw();
}
protected void updateTimeDataFormat(TimeDataFormat type) {
}
@ -879,11 +925,16 @@ public class ChangeColumnTypePanel extends FramedPanel implements
} else {
if (type == ColumnTypeCode.TIMEDIMENSION) {
changeColumnTypeSession
.setTimeDimensionType(cd
.getPeriodDataType());
comboTimeDimensionType.setValue(cd
changeColumnTypeSession.setPeriodDataType(cd
.getPeriodDataType());
comboPeriodType.setValue(cd.getPeriodDataType());
ArrayList<TimeDataFormat> timeDataFormats = cd
.getPeriodDataType().getTimeDataFormats();
comboTimeDataFormat.clear();
comboTimeDataFormat.reset();
comboTimeDataFormat.getStore().clear();
comboTimeDataFormat.getStore().addAll(timeDataFormats);
comboTimeDataFormat.redraw();
} else {
// TODO
if (type == ColumnTypeCode.DIMENSION) {
@ -1146,17 +1197,25 @@ public class ChangeColumnTypePanel extends FramedPanel implements
break;
case TIMEDIMENSION:
changeColumnTypeSession.setColumnTypeCodeTarget(type);
PeriodDataType periodDataType = comboTimeDimensionType
PeriodDataType periodDataType = comboPeriodType
.getCurrentValue();
if (periodDataType != null) {
changeColumnTypeSession
.setTimeDimensionType(periodDataType);
.setPeriodDataType(periodDataType);
TimeDataFormat timeDataFormat = comboTimeDataFormat
.getCurrentValue();
if (timeDataFormat != null) {
changeColumnTypeSession
.setTimeDataFormat(timeDataFormat);
callChangeColumnType();
} else {
UtilsGXT3.alert("Attention",
"Time Format not selected!");
}
} else {
UtilsGXT3.alert("Attention",
"Time Dimension type not selected!");
"Period Type not selected!");
}
break;
default:
@ -1434,7 +1493,8 @@ public class ChangeColumnTypePanel extends FramedPanel implements
caught.getLocalizedMessage());
} else {
Log.debug(caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving period type",
UtilsGXT3.alert(
"Error retrieving period type",
caught.getLocalizedMessage());
}
}
@ -1444,16 +1504,15 @@ public class ChangeColumnTypePanel extends FramedPanel implements
@Override
public void onSuccess(ArrayList<PeriodDataType> result) {
storeComboTimeDimensionType.clear();
storeComboTimeDimensionType.addAll(result);
storeComboTimeDimensionType.commitChanges();
storeComboPeriodType.clear();
storeComboPeriodType.addAll(result);
storeComboPeriodType.commitChanges();
}
});
}
protected void setLocale(String locale) {
for (LocaleTypeElement loc : storeComboLocaleType.getAll()) {
if (loc.getLocaleName().compareTo(locale) == 0) {
@ -1525,7 +1584,8 @@ public class ChangeColumnTypePanel extends FramedPanel implements
public void operationComplete(OperationResult operationResult) {
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.CHANGECOLUMNTYPE, operationResult.getTrId(), why);
ChangeTableRequestType.CHANGECOLUMNTYPE,
operationResult.getTrId(), why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@ -1538,10 +1598,12 @@ public class ChangeColumnTypePanel extends FramedPanel implements
}
@Override
public void operationStopped(OperationResult operationResult, String reason, String details) {
public void operationStopped(OperationResult operationResult,
String reason, String details) {
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.CHANGECOLUMNTYPE, operationResult.getTrId(), why);
ChangeTableRequestType.CHANGECOLUMNTYPE,
operationResult.getTrId(), why);
eventBus.fireEvent(changeTableRequestEvent);
close();

View File

@ -0,0 +1,24 @@
package org.gcube.portlets.user.td.columnwidget.client.properties;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TimeDataFormat;
import com.google.gwt.editor.client.Editor.Path;
import com.sencha.gxt.data.shared.LabelProvider;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.PropertyAccess;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface TimeDataFormatProperties extends
PropertyAccess<TimeDataFormat> {
@Path("id")
ModelKeyProvider<TimeDataFormat> id();
LabelProvider<TimeDataFormat> example();
}