Updated Replace by External Column
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-replacebyexternal-widget@101526 82a268e6-3cf1-43bd-a215-b396298e98cf
|
@ -60,6 +60,17 @@ public class ColumnMappingCard extends WizardCard {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ReplaceByExternalSession getReplaceByExternalSession() {
|
||||
return replaceByExternalSession;
|
||||
}
|
||||
|
||||
public void setReplaceByExternalSession(
|
||||
ReplaceByExternalSession replaceByExternalSession) {
|
||||
this.replaceByExternalSession = replaceByExternalSession;
|
||||
}
|
||||
|
||||
protected void setMapping() {
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
|
|
|
@ -82,7 +82,8 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
|
||||
Log.debug("ColumnMappingPanel");
|
||||
init();
|
||||
retrieveSourceColumns();
|
||||
currentColumns=parent.getReplaceByExternalSession().getCurrentColumns();
|
||||
retrieveExternalColumns();
|
||||
}
|
||||
|
||||
public ArrayList<ColumnData> getCurrentColumns() {
|
||||
|
@ -148,45 +149,9 @@ public class ColumnMappingPanel extends ContentPanel {
|
|||
|
||||
}
|
||||
|
||||
private void retrieveSourceColumns() {
|
||||
TRId trId = parent.replaceByExternalSession.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 {
|
||||
if (caught instanceof TDGWTIsLockedException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
|
||||
} else {
|
||||
Log.debug("Error retrieving source columns: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3
|
||||
.alert("Error retrieving current columns",
|
||||
"Error retrieving current columns on server!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<ColumnData> result) {
|
||||
currentColumns = result;
|
||||
retrieveUnionColumns();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void retrieveUnionColumns() {
|
||||
private void retrieveExternalColumns() {
|
||||
TRId trId = parent.replaceByExternalSession.getExternalTabularResource().getTrId();
|
||||
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
package org.gcube.portlets.user.td.replacebyexternalwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.replacebyexternal.ReplaceByExternalSession;
|
||||
import org.gcube.portlets.user.td.replacebyexternalwidget.client.grid.CurrentColumnGridPanel;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.sencha.gxt.core.client.util.Padding;
|
||||
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
||||
import com.sencha.gxt.widget.core.client.form.FormPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CurrentColumnSelectionCard extends WizardCard {
|
||||
|
||||
protected ReplaceByExternalSession replaceByExternalSession;
|
||||
private CurrentColumnSelectionCard thisCard;
|
||||
private CurrentColumnGridPanel currentColumnGridPanel;
|
||||
|
||||
public ReplaceByExternalSession getReplaceByExternalSession() {
|
||||
return replaceByExternalSession;
|
||||
}
|
||||
|
||||
public CurrentColumnSelectionCard(
|
||||
final ReplaceByExternalSession replaceByExternalSession) {
|
||||
super("Current Column Selection", "");
|
||||
this.thisCard=this;
|
||||
if (replaceByExternalSession == null) {
|
||||
Log.error("ReplaceByExternalSession is null");
|
||||
}
|
||||
this.replaceByExternalSession = replaceByExternalSession;
|
||||
|
||||
FormPanel panel = createPanel();
|
||||
setContent(panel);
|
||||
|
||||
}
|
||||
|
||||
protected FormPanel createPanel() {
|
||||
FormPanel panel = new FormPanel();
|
||||
panel.setLabelWidth(90);
|
||||
panel.getElement().setPadding(new Padding(5));
|
||||
|
||||
VerticalLayoutContainer content = new VerticalLayoutContainer();
|
||||
panel.add(content);
|
||||
|
||||
// Column Selection Grid
|
||||
currentColumnGridPanel = new CurrentColumnGridPanel(this);
|
||||
|
||||
currentColumnGridPanel
|
||||
.addSelectionHandler(new SelectionHandler<ColumnData>() {
|
||||
|
||||
public void onSelection(SelectionEvent<ColumnData> event) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
content.add(currentColumnGridPanel);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
Log.debug("ReplaceColumnSelectionCard Setup");
|
||||
Command sayNextCard = new Command() {
|
||||
|
||||
public void execute() {
|
||||
Log.debug("ReplaceColumnSelectionCard Call sayNextCard");
|
||||
checkData();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Command sayPreviousCard = new Command() {
|
||||
public void execute() {
|
||||
try {
|
||||
getWizardWindow().previousCard();
|
||||
getWizardWindow().removeCard(thisCard);
|
||||
Log.info("Remove ReplaceColumnSelectionCard");
|
||||
} catch (Exception e) {
|
||||
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||
|
||||
setEnableBackButton(false);
|
||||
setEnableNextButton(true);
|
||||
}
|
||||
|
||||
protected void checkData() {
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
AlertMessageBox d;
|
||||
HideHandler hideHandler = new HideHandler() {
|
||||
|
||||
public void onHide(HideEvent event) {
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
ColumnData currentColumn = currentColumnGridPanel.getSelectedItem();
|
||||
if (currentColumn == null) {
|
||||
d = new AlertMessageBox("Attention", "No columns selected");
|
||||
d.addHideHandler(hideHandler);
|
||||
d.setModal(false);
|
||||
d.show();
|
||||
} else {
|
||||
replaceByExternalSession.setCurrentColumn(currentColumn);
|
||||
goNext();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void goNext() {
|
||||
try {
|
||||
Log.info("NextCard TabResourcesSelectionCard");
|
||||
TabResourcesSelectionCard tabResourcesSelectionCard = new TabResourcesSelectionCard(
|
||||
replaceByExternalSession);
|
||||
getWizardWindow().addCard(
|
||||
tabResourcesSelectionCard);
|
||||
getWizardWindow().nextCard();
|
||||
} catch (Throwable e) {
|
||||
Log.error("goNext: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -28,7 +28,7 @@ public class ReplaceByExternalTD extends WizardWindow {
|
|||
*/
|
||||
public ReplaceByExternalTD(TRId trId, String title, EventBus eventBus) {
|
||||
super(title, eventBus);
|
||||
Log.debug("UnionWizardTD: " + trId);
|
||||
Log.debug("ReplaceByExternalTD: " + trId);
|
||||
setWidth(WITHWIZARD);
|
||||
setHeight(HEIGHTWIZARD);
|
||||
|
||||
|
@ -36,11 +36,13 @@ public class ReplaceByExternalTD extends WizardWindow {
|
|||
replaceByExternalSession = new ReplaceByExternalSession();
|
||||
replaceByExternalSession.setTrId(trId);
|
||||
|
||||
TabResourcesSelectionCard tabResourcesSelection = new TabResourcesSelectionCard(
|
||||
CurrentColumnSelectionCard currentColumnSelectionCard = new CurrentColumnSelectionCard(
|
||||
replaceByExternalSession);
|
||||
addCard(tabResourcesSelection);
|
||||
tabResourcesSelection.setup();
|
||||
|
||||
addCard(currentColumnSelectionCard);
|
||||
currentColumnSelectionCard.setup();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -89,7 +89,7 @@ public class TabResourcesSelectionCard extends WizardCard {
|
|||
|
||||
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
getWizardWindow().setEnableBackButton(true);
|
||||
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ public class TabResourcesSelectionCard extends WizardCard {
|
|||
} else if (mb.getHideButton() == mb
|
||||
.getButtonById(PredefinedButton.NO.name())) {
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
getWizardWindow().setEnableBackButton(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -168,7 +168,7 @@ public class TabResourcesSelectionCard extends WizardCard {
|
|||
UtilsGXT3.alert("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
getWizardWindow().setEnableBackButton(true);
|
||||
} else {
|
||||
|
||||
AlertMessageBox d = new AlertMessageBox(
|
||||
|
@ -179,7 +179,7 @@ public class TabResourcesSelectionCard extends WizardCard {
|
|||
|
||||
public void onHide(HideEvent event) {
|
||||
getWizardWindow().setEnableNextButton(
|
||||
true);
|
||||
false);
|
||||
getWizardWindow().setEnableBackButton(
|
||||
true);
|
||||
|
||||
|
@ -196,7 +196,7 @@ public class TabResourcesSelectionCard extends WizardCard {
|
|||
public void onSuccess(Void result) {
|
||||
tabResourcesSelectionPanel.gridReload();
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
getWizardWindow().setEnableBackButton(true);
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -235,13 +235,13 @@ public class TabResourcesSelectionCard extends WizardCard {
|
|||
UtilsGXT3.alert("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
getWizardWindow().setEnableBackButton(true);
|
||||
} else {
|
||||
UtilsGXT3
|
||||
.alert("Error",
|
||||
"Error retrienving information on current tabular resource: ");
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
getWizardWindow().setEnableBackButton(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
package org.gcube.portlets.user.td.replacebyexternalwidget.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.exception.TDGWTIsLockedException;
|
||||
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.replacebyexternalwidget.client.CurrentColumnSelectionCard;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class CurrentColumnGridPanel extends ContentPanel implements
|
||||
HasSelectionHandlers<ColumnData> {
|
||||
// private static final String GRID_WIDTH ="524px";
|
||||
private static final String GRID_HEIGHT = "340px";
|
||||
protected static final ColumnDataProperties props = GWT
|
||||
.create(ColumnDataProperties.class);
|
||||
protected CheckBoxSelectionModel<ColumnData> sm;
|
||||
|
||||
protected final Grid<ColumnData> grid;
|
||||
protected final CurrentColumnSelectionCard parent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public CurrentColumnGridPanel(CurrentColumnSelectionCard parent) {
|
||||
this.parent = parent;
|
||||
Log.debug("CurrentColumnGridPanel");
|
||||
setHeadingText("Columns");
|
||||
|
||||
ColumnConfig<ColumnData, String> labelCol = new ColumnConfig<ColumnData, String>(
|
||||
props.label());
|
||||
|
||||
IdentityValueProvider<ColumnData> identity = new IdentityValueProvider<ColumnData>();
|
||||
|
||||
sm = new CheckBoxSelectionModel<ColumnData>(identity);
|
||||
|
||||
List<ColumnConfig<ColumnData, ?>> l = new ArrayList<ColumnConfig<ColumnData, ?>>();
|
||||
l.add(sm.getColumn());
|
||||
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.setSelectionModel(sm);
|
||||
grid.setLoader(loader);
|
||||
grid.setHeight(GRID_HEIGHT);
|
||||
// grid.setWidth(GRID_WIDTH);
|
||||
// grid.getView().setAutoExpandColumn(labelCol);
|
||||
grid.getView().setStripeRows(true);
|
||||
grid.getView().setColumnLines(true);
|
||||
grid.getView().setAutoFill(true);
|
||||
grid.setBorders(false);
|
||||
grid.setLoadMask(true);
|
||||
grid.setColumnReordering(false);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public ColumnData getSelectedItem() {
|
||||
return grid.getSelectionModel().getSelectedItem();
|
||||
|
||||
}
|
||||
|
||||
public HandlerRegistration addSelectionHandler(
|
||||
SelectionHandler<ColumnData> handler) {
|
||||
return grid.getSelectionModel().addSelectionHandler(handler);
|
||||
}
|
||||
|
||||
protected void loadData(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
||||
TRId trId=parent.getReplaceByExternalSession().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 {
|
||||
if (caught instanceof TDGWTIsLockedException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
|
||||
} else {
|
||||
Log.debug("Error retrieving source columns: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3
|
||||
.alert("Error retrieving current columns",
|
||||
"Error retrieving current columns on server!");
|
||||
}
|
||||
}
|
||||
callback.onFailure(caught);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<ColumnData> result) {
|
||||
parent.getReplaceByExternalSession().setCurrentColumns(result);
|
||||
callback.onSuccess(new ListLoadResultBean<ColumnData>(
|
||||
result));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -47,10 +47,10 @@ public interface ReplaceByExternalResourceBundle extends ClientBundle {
|
|||
@Source("delete_32.png")
|
||||
ImageResource delete32();
|
||||
|
||||
@Source("table-replace-by-external.png")
|
||||
@Source("table-replace-by-external-col.png")
|
||||
ImageResource tableReplaceByExternal();
|
||||
|
||||
@Source("table-replace-by-external_32.png")
|
||||
@Source("table-replace-by-external-col_32.png")
|
||||
ImageResource tableReplaceByExternal32();
|
||||
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 872 B After Width: | Height: | Size: 873 B |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 872 B After Width: | Height: | Size: 873 B |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.7 KiB |