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;
|
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.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 org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
@ -19,18 +23,6 @@ public class ColumnMappingCard extends WizardCard {
|
||||||
|
|
||||||
columnMappingPanel = new ColumnMappingPanel(thisCard,res);
|
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);
|
setContent(columnMappingPanel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -76,6 +68,19 @@ public class ColumnMappingCard extends WizardCard {
|
||||||
getWizardWindow().setEnableNextButton(false);
|
getWizardWindow().setEnableNextButton(false);
|
||||||
getWizardWindow().setEnableBackButton(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;
|
package org.gcube.portlets.user.td.unionwizardwidget.client;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
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.client.rpc.TDGWTServiceAsync;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
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.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.custom.IconButton;
|
||||||
import org.gcube.portlets.user.td.unionwizardwidget.client.properties.ColumnDataProperties;
|
import org.gcube.portlets.user.td.unionwizardwidget.client.properties.ColumnDataProperties;
|
||||||
import org.gcube.portlets.user.td.unionwizardwidget.client.resources.UnionResourceBundle;
|
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.ContentPanel;
|
||||||
import com.sencha.gxt.widget.core.client.Resizable;
|
import com.sencha.gxt.widget.core.client.Resizable;
|
||||||
import com.sencha.gxt.widget.core.client.Resizable.Dir;
|
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.BoxLayoutData;
|
||||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
||||||
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
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.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
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.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 {
|
public class ColumnMappingPanel extends ContentPanel {
|
||||||
|
|
||||||
private static final String COMBOWIDTH = "120px";
|
private static final String COMBOWIDTH = "120px";
|
||||||
|
private static final String COLUMNLABELWIDTH = "120px";
|
||||||
protected ResourceBundle res;
|
protected ResourceBundle res;
|
||||||
protected ColumnMappingCard parent;
|
protected ColumnMappingCard parent;
|
||||||
protected VerticalLayoutContainer vert;
|
protected VerticalLayoutContainer vert;
|
||||||
|
@ -54,13 +57,15 @@ public class ColumnMappingPanel extends ContentPanel {
|
||||||
protected ArrayList<ColumnData> unionColumns;
|
protected ArrayList<ColumnData> unionColumns;
|
||||||
protected ResizeContainer thisPanel;
|
protected ResizeContainer thisPanel;
|
||||||
|
|
||||||
|
protected HashMap<ColumnData,ColumnData> columnMap;
|
||||||
|
protected ArrayList<UnionColumnsMapping> listUnionColumnsMapping;
|
||||||
|
|
||||||
protected String itemIdSourceColumn = "itemIdSourceColumn";
|
protected String itemIdSourceColumn = "itemIdSourceColumn";
|
||||||
protected String itemIdUnionColumn = "itemIdUnionColumn";
|
protected String itemIdUnionColumn = "itemIdUnionColumn";
|
||||||
protected String itemIdLabelColumn = "itemIdLabelColumn";
|
protected String itemIdLabelColumn = "itemIdLabelColumn";
|
||||||
protected String itemIdBtnAdd = "itemIdBtnAdd";
|
protected String itemIdBtnAdd = "itemIdBtnAdd";
|
||||||
protected String itemIdBtnDel = "itemIdBtnDel";
|
protected String itemIdBtnDel = "itemIdBtnDel";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
|
@ -70,7 +75,7 @@ public class ColumnMappingPanel extends ContentPanel {
|
||||||
this.res = res;
|
this.res = res;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
thisPanel = this;
|
thisPanel = this;
|
||||||
|
parent.unionSession.getColumnsMatch();
|
||||||
Log.debug("ColumnMappingPanel");
|
Log.debug("ColumnMappingPanel");
|
||||||
init();
|
init();
|
||||||
retrieveSourceColumns();
|
retrieveSourceColumns();
|
||||||
|
@ -173,6 +178,12 @@ public class ColumnMappingPanel extends ContentPanel {
|
||||||
|
|
||||||
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
||||||
|
|
||||||
|
// Column Label
|
||||||
|
TextField columnLabel = new TextField();
|
||||||
|
columnLabel.setItemId(itemIdLabelColumn);
|
||||||
|
columnLabel.setAllowBlank(false);
|
||||||
|
columnLabel.setWidth(COLUMNLABELWIDTH);
|
||||||
|
|
||||||
// Source Combo
|
// Source Combo
|
||||||
ColumnDataProperties propsSourceColumn = GWT
|
ColumnDataProperties propsSourceColumn = GWT
|
||||||
.create(ColumnDataProperties.class);
|
.create(ColumnDataProperties.class);
|
||||||
|
@ -196,7 +207,7 @@ public class ColumnMappingPanel extends ContentPanel {
|
||||||
.create(ColumnDataProperties.class);
|
.create(ColumnDataProperties.class);
|
||||||
ListStore<ColumnData> storeComboUnionColumn = new ListStore<ColumnData>(
|
ListStore<ColumnData> storeComboUnionColumn = new ListStore<ColumnData>(
|
||||||
propsUnionColumn.id());
|
propsUnionColumn.id());
|
||||||
|
storeComboUnionColumn.addAll(unionColumns);
|
||||||
|
|
||||||
final ComboBox<ColumnData> comboUnionColumn = new ComboBox<ColumnData>(
|
final ComboBox<ColumnData> comboUnionColumn = new ComboBox<ColumnData>(
|
||||||
storeComboUnionColumn, propsUnionColumn.label());
|
storeComboUnionColumn, propsUnionColumn.label());
|
||||||
|
@ -209,14 +220,11 @@ public class ColumnMappingPanel extends ContentPanel {
|
||||||
comboUnionColumn.setEditable(false);
|
comboUnionColumn.setEditable(false);
|
||||||
comboUnionColumn.setTriggerAction(TriggerAction.ALL);
|
comboUnionColumn.setTriggerAction(TriggerAction.ALL);
|
||||||
|
|
||||||
|
|
||||||
final IconButton btnAdd = new IconButton();
|
final IconButton btnAdd = new IconButton();
|
||||||
btnAdd.setItemId(itemIdBtnAdd);
|
btnAdd.setItemId(itemIdBtnAdd);
|
||||||
btnAdd.setIcon(UnionResourceBundle.INSTANCE.add());
|
btnAdd.setIcon(UnionResourceBundle.INSTANCE.add());
|
||||||
btnAdd.addClickHandler(new ClickHandler() {
|
btnAdd.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
Log.debug("Clicked btnAdd");
|
Log.debug("Clicked btnAdd");
|
||||||
addColumnMap();
|
addColumnMap();
|
||||||
|
@ -251,6 +259,7 @@ public class ColumnMappingPanel extends ContentPanel {
|
||||||
horiz.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
horiz.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||||
horiz.setPack(BoxLayoutPack.START);
|
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(comboSourceColumn, new BoxLayoutData(new Margins(2, 1, 2, 1)));
|
||||||
horiz.add(comboUnionColumn, 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)));
|
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();
|
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
||||||
|
|
||||||
|
// Column Label
|
||||||
|
TextField columnLabel = new TextField();
|
||||||
|
columnLabel.setItemId(itemIdLabelColumn);
|
||||||
|
columnLabel.setAllowBlank(false);
|
||||||
|
columnLabel.setWidth(COLUMNLABELWIDTH);
|
||||||
|
|
||||||
// Source Combo
|
// Source Combo
|
||||||
ColumnDataProperties propsSourceColumn = GWT
|
ColumnDataProperties propsSourceColumn = GWT
|
||||||
.create(ColumnDataProperties.class);
|
.create(ColumnDataProperties.class);
|
||||||
ListStore<ColumnData> storeComboSourceColumn = new ListStore<ColumnData>(
|
ListStore<ColumnData> storeComboSourceColumn = new ListStore<ColumnData>(
|
||||||
propsSourceColumn.id());
|
propsSourceColumn.id());
|
||||||
|
storeComboSourceColumn.addAll(unionColumns);
|
||||||
|
|
||||||
final ComboBox<ColumnData> comboSourceColumn = new ComboBox<ColumnData>(
|
final ComboBox<ColumnData> comboSourceColumn = new ComboBox<ColumnData>(
|
||||||
storeComboSourceColumn, propsSourceColumn.label());
|
storeComboSourceColumn, propsSourceColumn.label());
|
||||||
|
@ -286,6 +302,7 @@ public class ColumnMappingPanel extends ContentPanel {
|
||||||
.create(ColumnDataProperties.class);
|
.create(ColumnDataProperties.class);
|
||||||
ListStore<ColumnData> storeComboUnionColumn = new ListStore<ColumnData>(
|
ListStore<ColumnData> storeComboUnionColumn = new ListStore<ColumnData>(
|
||||||
propsUnionColumn.id());
|
propsUnionColumn.id());
|
||||||
|
storeComboUnionColumn.addAll(unionColumns);
|
||||||
|
|
||||||
final ComboBox<ColumnData> comboUnionColumn = new ComboBox<ColumnData>(
|
final ComboBox<ColumnData> comboUnionColumn = new ComboBox<ColumnData>(
|
||||||
storeComboUnionColumn, propsUnionColumn.label());
|
storeComboUnionColumn, propsUnionColumn.label());
|
||||||
|
@ -298,14 +315,11 @@ public class ColumnMappingPanel extends ContentPanel {
|
||||||
comboUnionColumn.setEditable(false);
|
comboUnionColumn.setEditable(false);
|
||||||
comboUnionColumn.setTriggerAction(TriggerAction.ALL);
|
comboUnionColumn.setTriggerAction(TriggerAction.ALL);
|
||||||
|
|
||||||
|
|
||||||
final IconButton btnAdd = new IconButton();
|
final IconButton btnAdd = new IconButton();
|
||||||
btnAdd.setItemId(itemIdBtnAdd);
|
btnAdd.setItemId(itemIdBtnAdd);
|
||||||
btnAdd.setIcon(UnionResourceBundle.INSTANCE.add());
|
btnAdd.setIcon(UnionResourceBundle.INSTANCE.add());
|
||||||
btnAdd.addClickHandler(new ClickHandler() {
|
btnAdd.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
Log.debug("Clicked btnAdd");
|
Log.debug("Clicked btnAdd");
|
||||||
addColumnMap();
|
addColumnMap();
|
||||||
|
@ -336,10 +350,10 @@ public class ColumnMappingPanel extends ContentPanel {
|
||||||
});
|
});
|
||||||
btnDel.setVisible(false);
|
btnDel.setVisible(false);
|
||||||
|
|
||||||
|
|
||||||
horiz.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
horiz.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||||
horiz.setPack(BoxLayoutPack.START);
|
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(comboSourceColumn, new BoxLayoutData(new Margins(2, 1, 2, 1)));
|
||||||
horiz.add(comboUnionColumn, 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)));
|
horiz.add(btnAdd, new BoxLayoutData(new Margins(2, 1, 2, 1)));
|
||||||
|
@ -348,4 +362,39 @@ public class ColumnMappingPanel extends ContentPanel {
|
||||||
vert.add(horiz);
|
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