Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-unionwizard-widget@98773 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c4e051d0b9
commit
696c7af409
|
@ -1,6 +1,10 @@
|
|||
package org.gcube.portlets.user.td.unionwizardwidget.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionColumnsMapping;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionSession;
|
||||
import org.gcube.portlets.user.td.unionwizardwidget.client.utils.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -19,18 +23,6 @@ public class ColumnMappingCard extends WizardCard {
|
|||
|
||||
columnMappingPanel = new ColumnMappingPanel(thisCard,res);
|
||||
|
||||
/*
|
||||
columnMappingPanel
|
||||
.addSelectionHandler(new SelectionHandler<TabResource>() {
|
||||
|
||||
public void onSelection(SelectionEvent<TabResource> event) {
|
||||
codelistMappingSession.setConnectedTR(tabResourcesSelectionPanel
|
||||
.getSelectedItem());
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
}
|
||||
|
||||
});
|
||||
*/
|
||||
setContent(columnMappingPanel);
|
||||
|
||||
}
|
||||
|
@ -76,6 +68,19 @@ public class ColumnMappingCard extends WizardCard {
|
|||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
|
||||
ArrayList<UnionColumnsMapping> mapMatch=columnMappingPanel.getSelectedMap();
|
||||
if(mapMatch==null){
|
||||
Log.debug("No column match created: "
|
||||
+mapMatch);
|
||||
UtilsGXT3
|
||||
.info("Attentions",
|
||||
"Creates a valid map");
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
getWizardWindow().setEnableBackButton(true);
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package org.gcube.portlets.user.td.unionwizardwidget.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionColumnsMapping;
|
||||
import org.gcube.portlets.user.td.unionwizardwidget.client.custom.IconButton;
|
||||
import org.gcube.portlets.user.td.unionwizardwidget.client.properties.ColumnDataProperties;
|
||||
import org.gcube.portlets.user.td.unionwizardwidget.client.resources.UnionResourceBundle;
|
||||
|
@ -26,7 +28,6 @@ import com.sencha.gxt.data.shared.ListStore;
|
|||
import com.sencha.gxt.widget.core.client.ContentPanel;
|
||||
import com.sencha.gxt.widget.core.client.Resizable;
|
||||
import com.sencha.gxt.widget.core.client.Resizable.Dir;
|
||||
|
||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
||||
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
||||
|
@ -37,6 +38,7 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
|||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -47,6 +49,7 @@ import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
|||
public class ColumnMappingPanel extends ContentPanel {
|
||||
|
||||
private static final String COMBOWIDTH = "120px";
|
||||
private static final String COLUMNLABELWIDTH = "120px";
|
||||
protected ResourceBundle res;
|
||||
protected ColumnMappingCard parent;
|
||||
protected VerticalLayoutContainer vert;
|
||||
|
@ -54,12 +57,14 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
protected ArrayList<ColumnData> unionColumns;
|
||||
protected ResizeContainer thisPanel;
|
||||
|
||||
protected HashMap<ColumnData,ColumnData> columnMap;
|
||||
protected ArrayList<UnionColumnsMapping> listUnionColumnsMapping;
|
||||
|
||||
protected String itemIdSourceColumn = "itemIdSourceColumn";
|
||||
protected String itemIdUnionColumn = "itemIdUnionColumn";
|
||||
protected String itemIdLabelColumn = "itemIdLabelColumn";
|
||||
protected String itemIdBtnAdd="itemIdBtnAdd";
|
||||
protected String itemIdBtnDel="itemIdBtnDel";
|
||||
|
||||
protected String itemIdBtnAdd = "itemIdBtnAdd";
|
||||
protected String itemIdBtnDel = "itemIdBtnDel";
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -69,8 +74,8 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
public ColumnMappingPanel(ColumnMappingCard parent, ResourceBundle res) {
|
||||
this.res = res;
|
||||
this.parent = parent;
|
||||
thisPanel=this;
|
||||
|
||||
thisPanel = this;
|
||||
parent.unionSession.getColumnsMatch();
|
||||
Log.debug("ColumnMappingPanel");
|
||||
init();
|
||||
retrieveSourceColumns();
|
||||
|
@ -173,6 +178,12 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
|
||||
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
||||
|
||||
// Column Label
|
||||
TextField columnLabel = new TextField();
|
||||
columnLabel.setItemId(itemIdLabelColumn);
|
||||
columnLabel.setAllowBlank(false);
|
||||
columnLabel.setWidth(COLUMNLABELWIDTH);
|
||||
|
||||
// Source Combo
|
||||
ColumnDataProperties propsSourceColumn = GWT
|
||||
.create(ColumnDataProperties.class);
|
||||
|
@ -191,12 +202,12 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
comboSourceColumn.setEditable(false);
|
||||
comboSourceColumn.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
//Union Combo
|
||||
// Union Combo
|
||||
ColumnDataProperties propsUnionColumn = GWT
|
||||
.create(ColumnDataProperties.class);
|
||||
ListStore<ColumnData> storeComboUnionColumn = new ListStore<ColumnData>(
|
||||
propsUnionColumn.id());
|
||||
|
||||
storeComboUnionColumn.addAll(unionColumns);
|
||||
|
||||
final ComboBox<ColumnData> comboUnionColumn = new ComboBox<ColumnData>(
|
||||
storeComboUnionColumn, propsUnionColumn.label());
|
||||
|
@ -209,14 +220,11 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
comboUnionColumn.setEditable(false);
|
||||
comboUnionColumn.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
|
||||
final IconButton btnAdd = new IconButton();
|
||||
btnAdd.setItemId(itemIdBtnAdd);
|
||||
btnAdd.setIcon(UnionResourceBundle.INSTANCE.add());
|
||||
btnAdd.addClickHandler(new ClickHandler() {
|
||||
|
||||
|
||||
|
||||
public void onClick(ClickEvent event) {
|
||||
Log.debug("Clicked btnAdd");
|
||||
addColumnMap();
|
||||
|
@ -251,6 +259,7 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
horiz.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||
horiz.setPack(BoxLayoutPack.START);
|
||||
|
||||
horiz.add(columnLabel, new BoxLayoutData(new Margins(2, 1, 2, 1)));
|
||||
horiz.add(comboSourceColumn, new BoxLayoutData(new Margins(2, 1, 2, 1)));
|
||||
horiz.add(comboUnionColumn, new BoxLayoutData(new Margins(2, 1, 2, 1)));
|
||||
horiz.add(btnAdd, new BoxLayoutData(new Margins(2, 1, 2, 1)));
|
||||
|
@ -264,11 +273,18 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
|
||||
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
||||
|
||||
// Column Label
|
||||
TextField columnLabel = new TextField();
|
||||
columnLabel.setItemId(itemIdLabelColumn);
|
||||
columnLabel.setAllowBlank(false);
|
||||
columnLabel.setWidth(COLUMNLABELWIDTH);
|
||||
|
||||
// Source Combo
|
||||
ColumnDataProperties propsSourceColumn = GWT
|
||||
.create(ColumnDataProperties.class);
|
||||
ListStore<ColumnData> storeComboSourceColumn = new ListStore<ColumnData>(
|
||||
propsSourceColumn.id());
|
||||
storeComboSourceColumn.addAll(unionColumns);
|
||||
|
||||
final ComboBox<ColumnData> comboSourceColumn = new ComboBox<ColumnData>(
|
||||
storeComboSourceColumn, propsSourceColumn.label());
|
||||
|
@ -281,11 +297,12 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
comboSourceColumn.setEditable(false);
|
||||
comboSourceColumn.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
//Union Combo
|
||||
// Union Combo
|
||||
ColumnDataProperties propsUnionColumn = GWT
|
||||
.create(ColumnDataProperties.class);
|
||||
ListStore<ColumnData> storeComboUnionColumn = new ListStore<ColumnData>(
|
||||
propsUnionColumn.id());
|
||||
storeComboUnionColumn.addAll(unionColumns);
|
||||
|
||||
final ComboBox<ColumnData> comboUnionColumn = new ComboBox<ColumnData>(
|
||||
storeComboUnionColumn, propsUnionColumn.label());
|
||||
|
@ -298,14 +315,11 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
comboUnionColumn.setEditable(false);
|
||||
comboUnionColumn.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
|
||||
final IconButton btnAdd = new IconButton();
|
||||
btnAdd.setItemId(itemIdBtnAdd);
|
||||
btnAdd.setIcon(UnionResourceBundle.INSTANCE.add());
|
||||
btnAdd.addClickHandler(new ClickHandler() {
|
||||
|
||||
|
||||
|
||||
public void onClick(ClickEvent event) {
|
||||
Log.debug("Clicked btnAdd");
|
||||
addColumnMap();
|
||||
|
@ -336,10 +350,10 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
});
|
||||
btnDel.setVisible(false);
|
||||
|
||||
|
||||
horiz.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||
horiz.setPack(BoxLayoutPack.START);
|
||||
|
||||
horiz.add(columnLabel, new BoxLayoutData(new Margins(2, 1, 2, 1)));
|
||||
horiz.add(comboSourceColumn, new BoxLayoutData(new Margins(2, 1, 2, 1)));
|
||||
horiz.add(comboUnionColumn, new BoxLayoutData(new Margins(2, 1, 2, 1)));
|
||||
horiz.add(btnAdd, new BoxLayoutData(new Margins(2, 1, 2, 1)));
|
||||
|
@ -348,4 +362,39 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
vert.add(horiz);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected ArrayList<UnionColumnsMapping> getSelectedMap() {
|
||||
listUnionColumnsMapping=new ArrayList<UnionColumnsMapping>();
|
||||
|
||||
int lenght = vert.getWidgetCount();
|
||||
int i = 0;
|
||||
for (; i < lenght; i++) {
|
||||
HBoxLayoutContainer h = (HBoxLayoutContainer) vert.getWidget(i);
|
||||
if (h != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ComboBox<ColumnData> comboSourceColumn = (ComboBox<ColumnData>) h
|
||||
.getItemByItemId(itemIdSourceColumn);
|
||||
ColumnData sourceColumn = comboSourceColumn.getCurrentValue();
|
||||
if (sourceColumn != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ComboBox<ColumnData> comboUnionColumn= (ComboBox<ColumnData>) h
|
||||
.getItemByItemId(itemIdUnionColumn);
|
||||
ColumnData unionColumn = comboUnionColumn.getCurrentValue();
|
||||
if (unionColumn != null) {
|
||||
UnionColumnsMapping colMatch= new UnionColumnsMapping(sourceColumn, unionColumn);
|
||||
listUnionColumnsMapping.add(colMatch);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return listUnionColumnsMapping;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue