Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-unionwizard-widget@98758 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f07724e032
commit
a77671d6b3
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||
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.unionwizardwidget.client.properties.ColumnDataProperties;
|
||||
import org.gcube.portlets.user.td.unionwizardwidget.client.utils.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
|
@ -12,31 +13,55 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
|||
import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
||||
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
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;
|
||||
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign;
|
||||
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ColumnMappingPanel extends ContentPanel {
|
||||
|
||||
|
||||
private static final String COMBOWIDTH = null;
|
||||
protected ResourceBundle res;
|
||||
protected ColumnMappingCard parent;
|
||||
protected VerticalLayoutContainer vert;
|
||||
|
||||
protected ArrayList<ColumnData> sourceColumns;
|
||||
protected ArrayList<ColumnData> unionColumns;
|
||||
protected String itemIdSourceColumn = "itemIdSourceColumn";
|
||||
protected String itemIdUnionColumn = "itemIdUnionColumn";
|
||||
protected String itemIdLabelColumn = "itemIdLabelColumn";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parent
|
||||
* @param res
|
||||
*/
|
||||
public ColumnMappingPanel(ColumnMappingCard parent, ResourceBundle res) {
|
||||
this.res = res;
|
||||
this.parent = parent;
|
||||
|
||||
|
||||
Log.debug("ColumnMappingPanel");
|
||||
init();
|
||||
retrieveColumns();
|
||||
retrieveSourceColumns();
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
|
@ -46,17 +71,14 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
}
|
||||
|
||||
protected void create() {
|
||||
|
||||
//itemIdSourceValueArg = "SourceArg" + selectedColumn.getName();
|
||||
//itemIdTargetValueArg = "TargetArg" + selectedColumn.getName();
|
||||
|
||||
SimpleContainer container = new SimpleContainer();
|
||||
|
||||
|
||||
vert = new VerticalLayoutContainer();
|
||||
vert.setScrollMode(ScrollMode.AUTO);
|
||||
vert.setAdjustForScroll(true);
|
||||
|
||||
//setColumnMappingData();
|
||||
// setColumnMappingData();
|
||||
|
||||
container.add(vert);
|
||||
container.forceLayout();
|
||||
|
@ -70,11 +92,11 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
|
||||
add(vPanel);
|
||||
forceLayout();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void retrieveColumns() {
|
||||
TRId trId=parent.unionSession.getTrId();
|
||||
private void retrieveSourceColumns() {
|
||||
TRId trId = parent.unionSession.getTrId();
|
||||
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
||||
|
@ -86,15 +108,49 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.debug("Error retrieving columns: "
|
||||
Log.debug("Error retrieving source columns: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error retrieving columns",
|
||||
"Error retrieving columns on server!");
|
||||
UtilsGXT3
|
||||
.alert("Error retrieving source columns",
|
||||
"Error retrieving source columns on server!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<ColumnData> result) {
|
||||
sourceColumns = result;
|
||||
retrieveUnionColumns();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void retrieveUnionColumns() {
|
||||
TRId trId = parent.unionSession.getUnionTabularResource().getTrId();
|
||||
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
parent.getEventBus()
|
||||
.fireEvent(
|
||||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.debug("Error retrieving union columns: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3
|
||||
.alert("Error retrieving union columns",
|
||||
"Error retrieving union columns on server!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<ColumnData> result) {
|
||||
unionColumns = result;
|
||||
create();
|
||||
/*
|
||||
* comboColumnReferenceType.reset();
|
||||
* storeComboColumnReferenceType.clear();
|
||||
|
@ -108,4 +164,88 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
|
||||
}
|
||||
|
||||
protected void setColumnMappingData() {
|
||||
|
||||
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
||||
|
||||
// Source Combo
|
||||
ColumnDataProperties propsSourceColumn = GWT
|
||||
.create(ColumnDataProperties.class);
|
||||
ListStore<ColumnData> storeComboSourceColumn = new ListStore<ColumnData>(
|
||||
propsSourceColumn.id());
|
||||
|
||||
final ComboBox<ColumnData> comboSourceColumn = new ComboBox<ColumnData>(
|
||||
storeComboSourceColumn, propsSourceColumn.label());
|
||||
comboSourceColumn.setItemId(itemIdSourceColumn);
|
||||
|
||||
Log.debug("ComboSourceColumn created");
|
||||
|
||||
comboSourceColumn.setEmptyText("Select a column...");
|
||||
comboSourceColumn.setWidth(COMBOWIDTH);
|
||||
comboSourceColumn.setEditable(false);
|
||||
comboSourceColumn.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
//Union Combo
|
||||
ColumnDataProperties propsUnionColumn = GWT
|
||||
.create(ColumnDataProperties.class);
|
||||
ListStore<ColumnData> storeComboUnionColumn = new ListStore<ColumnData>(
|
||||
propsUnionColumn.id());
|
||||
|
||||
final ComboBox<ColumnData> comboUnionColumn = new ComboBox<ColumnData>(
|
||||
storeComboUnionColumn, propsUnionColumn.label());
|
||||
comboUnionColumn.setItemId(itemIdUnionColumn);
|
||||
|
||||
Log.debug("ComboUnionColumn created");
|
||||
|
||||
comboUnionColumn.setEmptyText("Select a column...");
|
||||
comboUnionColumn.setWidth(COMBOWIDTH);
|
||||
comboUnionColumn.setEditable(false);
|
||||
comboUnionColumn.setTriggerAction(TriggerAction.ALL);
|
||||
/*
|
||||
final IconButton btnAdd = new IconButton();
|
||||
btnAdd.setItemId(itemIdBtnAdd);
|
||||
btnAdd.setIcon(ResourceBundle.INSTANCE.add());
|
||||
btnAdd.addClickHandler(new ClickHandler() {
|
||||
|
||||
public void onClick(ClickEvent event) {
|
||||
Log.debug("Clicked btnAdd");
|
||||
addColumnMappingData();
|
||||
thisPanel.forceLayout();
|
||||
vert.forceLayout();
|
||||
|
||||
}
|
||||
});
|
||||
btnAdd.setVisible(true);
|
||||
|
||||
final IconButton btnDel = new IconButton();
|
||||
btnDel.setItemId(itemIdBtnDel);
|
||||
btnDel.setIcon(ResourceBundle.INSTANCE.delete());
|
||||
btnDel.addClickHandler(new ClickHandler() {
|
||||
|
||||
public void onClick(ClickEvent event) {
|
||||
Log.debug("Clicked btnDel");
|
||||
vert.remove(horiz);
|
||||
if (vert.getWidgetCount() == 0) {
|
||||
setColumnMappingData();
|
||||
} else {
|
||||
|
||||
}
|
||||
thisPanel.forceLayout();
|
||||
vert.forceLayout();
|
||||
|
||||
}
|
||||
});
|
||||
btnDel.setVisible(false);
|
||||
*/
|
||||
horiz.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||
horiz.setPack(BoxLayoutPack.START);
|
||||
|
||||
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)));
|
||||
horiz.add(btnDel, new BoxLayoutData(new Margins(2, 1, 2, 1)));*/
|
||||
|
||||
vert.add(horiz);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,156 +0,0 @@
|
|||
package org.gcube.portlets.user.td.unionwizardwidget.client.grid;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.Scheduler;
|
||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||
import com.google.gwt.event.logical.shared.HasSelectionHandlers;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.event.shared.HandlerRegistration;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sencha.gxt.core.client.IdentityValueProvider;
|
||||
import com.sencha.gxt.core.client.Style.SelectionMode;
|
||||
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.data.client.loader.RpcProxy;
|
||||
import com.sencha.gxt.data.shared.ListStore;
|
||||
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
|
||||
import com.sencha.gxt.data.shared.loader.ListLoadResult;
|
||||
import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
|
||||
import com.sencha.gxt.data.shared.loader.ListLoader;
|
||||
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
|
||||
import com.sencha.gxt.widget.core.client.ContentPanel;
|
||||
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.grid.CheckBoxSelectionModel;
|
||||
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
|
||||
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
|
||||
import com.sencha.gxt.widget.core.client.grid.Grid;
|
||||
|
||||
public class ColumnDataGridPanel extends ContentPanel implements
|
||||
HasSelectionHandlers<ColumnData> {
|
||||
protected static final int GRIDHEIGHT = 360;
|
||||
|
||||
protected static final ColumnDataProperties props = GWT
|
||||
.create(ColumnDataProperties.class);
|
||||
|
||||
protected final CheckBoxSelectionModel<ColumnData> sm;
|
||||
|
||||
protected final Grid<ColumnData> grid;
|
||||
protected TRId trId;
|
||||
|
||||
public ColumnDataGridPanel(TRId trId) {
|
||||
Log.debug("ColumnDataGridPanel");
|
||||
if(trId==null){
|
||||
Log.error("ColumnDataGridPanel: TRId is null");
|
||||
}
|
||||
Log.debug("ColumnDataGridPanel: "+trId.toString());
|
||||
this.trId=trId;
|
||||
setHeaderVisible(false);
|
||||
//setHeadingText("Columns");
|
||||
|
||||
ColumnConfig<ColumnData, String> labelCol = new ColumnConfig<ColumnData, String>(
|
||||
props.label(), 120,"Column");
|
||||
|
||||
IdentityValueProvider<ColumnData> identity = new IdentityValueProvider<ColumnData>();
|
||||
|
||||
sm = new CheckBoxSelectionModel<ColumnData>(identity);
|
||||
|
||||
List<ColumnConfig<ColumnData, ?>> l = new ArrayList<ColumnConfig<ColumnData, ?>>();
|
||||
|
||||
l.add(labelCol);
|
||||
ColumnModel<ColumnData> cm = new ColumnModel<ColumnData>(l);
|
||||
|
||||
ListStore<ColumnData> store = new ListStore<ColumnData>(props.id());
|
||||
|
||||
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
|
||||
|
||||
public void load(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
||||
loadData(loadConfig, callback);
|
||||
}
|
||||
};
|
||||
final ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader = new ListLoader<ListLoadConfig, ListLoadResult<ColumnData>>(
|
||||
proxy);
|
||||
|
||||
loader.setRemoteSort(false);
|
||||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ColumnData, ListLoadResult<ColumnData>>(
|
||||
store) {
|
||||
});
|
||||
|
||||
grid = new Grid<ColumnData>(store, cm) {
|
||||
@Override
|
||||
protected void onAfterFirstAttach() {
|
||||
super.onAfterFirstAttach();
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
|
||||
public void execute() {
|
||||
loader.load();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||
grid.setLoader(loader);
|
||||
grid.setSelectionModel(sm);
|
||||
grid.setHeight(GRIDHEIGHT);
|
||||
grid.getView().setStripeRows(true);
|
||||
grid.getView().setColumnLines(true);
|
||||
grid.getView().setAutoFill(true);
|
||||
grid.setBorders(false);
|
||||
grid.setLoadMask(true);
|
||||
grid.setColumnReordering(true);
|
||||
|
||||
VerticalLayoutContainer con = new VerticalLayoutContainer();
|
||||
con.setScrollMode(ScrollMode.AUTO);
|
||||
con.add(grid, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||
setWidget(con);
|
||||
|
||||
}
|
||||
|
||||
public Grid<ColumnData> getGrid() {
|
||||
return grid;
|
||||
}
|
||||
|
||||
protected void loadData(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
||||
TDGWTServiceAsync.INSTANCE
|
||||
.getColumns(trId, new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.error("No load columns: "
|
||||
+ caught.getLocalizedMessage());
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
|
||||
public void onSuccess(ArrayList<ColumnData> result) {
|
||||
Log.trace("loaded " + result.size() + " columns");
|
||||
callback.onSuccess(new ListLoadResultBean<ColumnData>(
|
||||
result));
|
||||
sm.selectAll();
|
||||
forceLayout();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ColumnData getSelectedItem() {
|
||||
return grid.getSelectionModel().getSelectedItem();
|
||||
|
||||
}
|
||||
|
||||
public HandlerRegistration addSelectionHandler(
|
||||
SelectionHandler<ColumnData> handler) {
|
||||
return grid.getSelectionModel().addSelectionHandler(handler);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package org.gcube.portlets.user.td.unionwizardwidget.client.grid;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
|
||||
import com.google.gwt.editor.client.Editor.Path;
|
||||
import com.sencha.gxt.core.client.ValueProvider;
|
||||
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||
import com.sencha.gxt.data.shared.PropertyAccess;
|
||||
|
||||
public interface ColumnDataProperties extends PropertyAccess<ColumnData> {
|
||||
|
||||
@Path("id")
|
||||
ModelKeyProvider<ColumnData> id();
|
||||
|
||||
ValueProvider<ColumnData, String> label();
|
||||
|
||||
// ValueProvider<ColumnData, String> typeName();
|
||||
|
||||
// ValueProvider<ColumnData, String> typeCode();
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package org.gcube.portlets.user.td.unionwizardwidget.client.properties;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
|
||||
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"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface ColumnDataProperties extends
|
||||
PropertyAccess<ColumnData> {
|
||||
|
||||
@Path("id")
|
||||
ModelKeyProvider<ColumnData> id();
|
||||
|
||||
LabelProvider<ColumnData> label();
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue