From 6c74b412fee3eac7d5d06cdfbab4141dbe6b6abb Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 27 Jun 2014 10:15:54 +0000 Subject: [PATCH] Minor Update git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@97890 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/ChangeColumnTypePanel.java | 97 ++++++++++++++++++- .../client/mapping/ColumnMappingList.java | 51 ++++++---- .../mapping/ColumnMappingListProperties.java | 28 ++++++ .../client/mapping/ColumnMappingPanel.java | 2 +- 4 files changed, 157 insertions(+), 21 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingListProperties.java 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 2fcc55c..4915f47 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 @@ -4,6 +4,10 @@ import java.util.ArrayList; import org.gcube.portlets.user.td.columnwidget.client.dimension.CodelistSelectionDialog; import org.gcube.portlets.user.td.columnwidget.client.dimension.CodelistSelectionListener; +import org.gcube.portlets.user.td.columnwidget.client.mapping.ColumnMappingDialog; +import org.gcube.portlets.user.td.columnwidget.client.mapping.ColumnMappingList; +import org.gcube.portlets.user.td.columnwidget.client.mapping.ColumnMappingListProperties; +import org.gcube.portlets.user.td.columnwidget.client.mapping.ColumnMappingListener; import org.gcube.portlets.user.td.columnwidget.client.progress.ChangeColumnTypeProgressDialog; import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnDataPropertiesCombo; import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnDataTypeProperties; @@ -73,7 +77,7 @@ import com.sencha.gxt.widget.core.client.info.Info; * */ public class ChangeColumnTypePanel extends FramedPanel implements - CodelistSelectionListener { + CodelistSelectionListener, ColumnMappingListener { protected String WIDTH = "640px"; protected String HEIGHT = "520px"; protected EventBus eventBus; @@ -97,7 +101,11 @@ public class ChangeColumnTypePanel extends FramedPanel implements protected ComboBox comboColumnReferenceType = null; protected FieldLabel comboColumnReferenceTypeLabel; protected ListStore storeComboColumnReferenceType; - + + protected ComboBox comboColumnMapping = null; + protected FieldLabel comboColumnMappingLabel; + protected ListStore storeComboColumnMapping; + protected ComboBox comboTimeDimensionType = null; protected FieldLabel comboTimeDimensionTypeLabel; @@ -309,6 +317,28 @@ public class ChangeColumnTypePanel extends FramedPanel implements comboColumnReferenceTypeLabel = new FieldLabel( comboColumnReferenceType, "Column"); + //TODO + // ColumnMapping + ColumnMappingListProperties propsColumnMapping = GWT + .create(ColumnMappingListProperties.class); + storeComboColumnMapping = new ListStore( + propsColumnMapping.id()); + + comboColumnMapping = new ComboBox( + storeComboColumnMapping, propsColumnMapping.name()); + Log.trace("ComboColumnMapping created"); + + + addHandlersForComboColumnMapping(propsColumnMapping.name()); + + comboColumnMapping.setEmptyText("Select optional mapping..."); + comboColumnMapping.setWidth(191); + comboColumnMapping.setEditable(false); + comboColumnMapping.setTriggerAction(TriggerAction.ALL); + + comboColumnMappingLabel = new FieldLabel( + comboColumnMapping, "Mapping"); + // comboTimeDimensionType TimeDimensionTypeProperties propsTimeDimensionType = GWT .create(TimeDimensionTypeProperties.class); @@ -364,6 +394,8 @@ public class ChangeColumnTypePanel extends FramedPanel implements new Margins(1))); v.add(comboColumnReferenceTypeLabel, new VerticalLayoutData(1, -1, new Margins(1))); + v.add(comboColumnMappingLabel, new VerticalLayoutData(1, -1, + new Margins(1))); v.add(comboTimeDimensionTypeLabel, new VerticalLayoutData(1, -1, new Margins(1))); v.add(change, new VerticalLayoutData(-1, -1, new Margins(10, 0, 10, 0))); @@ -373,6 +405,7 @@ public class ChangeColumnTypePanel extends FramedPanel implements comboAttributeTypeLabel.setVisible(false); comboDimensionTypeLabel.setVisible(false); comboColumnReferenceTypeLabel.setVisible(false); + comboColumnMappingLabel.setVisible(false); comboTimeDimensionTypeLabel.setVisible(false); comboLocaleTypeLabel.setVisible(false); @@ -526,6 +559,24 @@ public class ChangeColumnTypePanel extends FramedPanel implements }); } + + protected void addHandlersForComboColumnMapping( + final LabelProvider labelProvider) { + + comboColumnMapping.addTriggerClickHandler(new TriggerClickHandler() { + + @Override + public void onTriggerClick(TriggerClickEvent event) { + Log.debug("ComboColumnMapping TriggerClickEvent"); + callColumnMappingDialog(); + comboColumnMapping.collapse(); + + } + + }); + + } + protected void addHandlersForComboTimeDimensionType( final LabelProvider labelProvider) { @@ -559,6 +610,7 @@ public class ChangeColumnTypePanel extends FramedPanel implements comboAttributeTypeLabel.setVisible(false); comboDimensionTypeLabel.setVisible(false); comboColumnReferenceTypeLabel.setVisible(false); + comboColumnMappingLabel.setVisible(false); comboTimeDimensionTypeLabel.setVisible(false); break; case ATTRIBUTE: @@ -567,6 +619,7 @@ public class ChangeColumnTypePanel extends FramedPanel implements comboAttributeTypeLabel.setVisible(true); comboDimensionTypeLabel.setVisible(false); comboColumnReferenceTypeLabel.setVisible(false); + comboColumnMappingLabel.setVisible(false); comboTimeDimensionTypeLabel.setVisible(false); break; case DIMENSION: @@ -575,6 +628,7 @@ public class ChangeColumnTypePanel extends FramedPanel implements comboAttributeTypeLabel.setVisible(false); comboDimensionTypeLabel.setVisible(true); comboColumnReferenceTypeLabel.setVisible(false); + comboColumnMappingLabel.setVisible(false); comboTimeDimensionTypeLabel.setVisible(false); break; case MEASURE: @@ -583,6 +637,7 @@ public class ChangeColumnTypePanel extends FramedPanel implements comboAttributeTypeLabel.setVisible(false); comboDimensionTypeLabel.setVisible(false); comboColumnReferenceTypeLabel.setVisible(false); + comboColumnMappingLabel.setVisible(false); comboTimeDimensionTypeLabel.setVisible(false); break; case TIMEDIMENSION: @@ -591,6 +646,7 @@ public class ChangeColumnTypePanel extends FramedPanel implements comboAttributeTypeLabel.setVisible(false); comboDimensionTypeLabel.setVisible(false); comboColumnReferenceTypeLabel.setVisible(false); + comboColumnMappingLabel.setVisible(false); comboTimeDimensionTypeLabel.setVisible(true); break; default: @@ -599,6 +655,7 @@ public class ChangeColumnTypePanel extends FramedPanel implements comboAttributeTypeLabel.setVisible(false); comboDimensionTypeLabel.setVisible(false); comboColumnReferenceTypeLabel.setVisible(false); + comboColumnMappingLabel.setVisible(false); comboTimeDimensionTypeLabel.setVisible(false); break; } @@ -873,7 +930,7 @@ public class ChangeColumnTypePanel extends FramedPanel implements @Override public void selected(TabResource tabResource) { Log.debug("Selected Codelist: " + tabResource); - comboDimensionType.setValue(tabResource); + comboDimensionType.setValue(tabResource,true); retrieveColumnData(tabResource); } @@ -963,5 +1020,39 @@ public class ChangeColumnTypePanel extends FramedPanel implements } } } + + //TODO + protected void callColumnMappingDialog() { + ColumnData referenceColumn=comboColumnReferenceType.getCurrentValue(); + if(referenceColumn==null){ + + } + + + /*ColumnMappingDialog columnMappingDialog = new ColumnMappingDialog( + eventBus); + columnMappingDialog.addColumnMappingListener(this); + columnMappingDialog.show();*/ + } + + @Override + public void selectedColumnMapping(ColumnMappingList columnMappingList) { + Log.debug("Selected ColumnMapping: " + columnMappingList); + comboColumnMapping.setValue(columnMappingList,true); + + } + + @Override + public void abortedColumnMapping() { + Log.debug("Column Mapping selection Aborted"); + + } + + @Override + public void failedColumnMapping(String reason, String detail) { + Log.error("Error selecting Column Mapping:"+reason+" "+detail); + + } + } diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingList.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingList.java index adaf4d0..5b62608 100644 --- a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingList.java +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingList.java @@ -5,30 +5,49 @@ import java.util.ArrayList; /** * - * @author "Giancarlo Panichi" - * email: g.panichi@isti.cnr.it - * + * @author "Giancarlo Panichi" email: g.panichi@isti.cnr.it + * */ -public class ColumnMappingList implements Serializable{ - +public class ColumnMappingList implements Serializable { + private static final long serialVersionUID = 733237646914552402L; - + + protected String id; + protected String name; protected ArrayList mapping; /** * */ - public ColumnMappingList(){ - + public ColumnMappingList() { + } - + /** * * @param mapping */ - public ColumnMappingList(ArrayList mapping){ - this.mapping=mapping; - + public ColumnMappingList(String id, String name, + ArrayList mapping) { + this.mapping = mapping; + + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; } public ArrayList getMapping() { @@ -41,10 +60,8 @@ public class ColumnMappingList implements Serializable{ @Override public String toString() { - return "ColumnMappingList [mapping=" + mapping + "]"; + return "ColumnMappingList [id=" + id + ", name=" + name + ", mapping=" + + mapping + "]"; } - - - - + } diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingListProperties.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingListProperties.java new file mode 100644 index 0000000..c6e6108 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingListProperties.java @@ -0,0 +1,28 @@ +/** + * + */ +package org.gcube.portlets.user.td.columnwidget.client.mapping; + + +import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow; + +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 Panichi" + * g.panichi@isti.cnr.it + * + */ +public interface ColumnMappingListProperties extends PropertyAccess { + + @Path("id") + ModelKeyProvider id(); + + LabelProvider name(); + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingPanel.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingPanel.java index 55ad836..bd967bc 100644 --- a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingPanel.java @@ -183,7 +183,7 @@ public class ColumnMappingPanel extends FramedPanel { } } if(mapping.size()>0){ - columnMappingList=new ColumnMappingList(mapping); + columnMappingList=new ColumnMappingList("1","Mapping", mapping); if(parent!=null){ parent.saveMapping(columnMappingList); }