Fixed Final and Lock error

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-export-widget@100228 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-09-26 15:04:16 +00:00
parent d3645cb653
commit 2c74fac2d2
3 changed files with 55 additions and 41 deletions

View File

@ -122,9 +122,11 @@ public class CSVExportConfigCard extends WizardCard {
new SessionExpiredEvent( new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
GWT.log("Error loading charset list", caught);
Log.error("Error loading charset list", caught);
showErrorAndHide("Error loading charset list", showErrorAndHide("Error loading charset list",
"Error loading charset list", "", caught); "Error loading charset list", caught);
} }
} }
}); });
@ -192,7 +194,7 @@ public class CSVExportConfigCard extends WizardCard {
"The delimiter use to delimit the CSV fields")); "The delimiter use to delimit the CSV fields"));
content.add(new FieldLabel(delimitersPanel, "Delimiter")); content.add(new FieldLabel(delimitersPanel, "Delimiter"));
csvColumnGridPanel = new ColumnDataGridPanel(); csvColumnGridPanel = new ColumnDataGridPanel(this);
csvColumnGridPanel csvColumnGridPanel
.addSelectionHandler(new SelectionHandler<ColumnData>() { .addSelectionHandler(new SelectionHandler<ColumnData>() {

View File

@ -5,6 +5,7 @@ package org.gcube.portlets.user.td.csvexportwidget.client;
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.csv.CSVExportSession; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
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.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog; import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener; import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
@ -20,13 +21,10 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.FlexTable; import com.google.gwt.user.client.ui.FlexTable;
import com.sencha.gxt.core.client.util.Margins; import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel; import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
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.HtmlLayoutContainer; import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer; import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayoutAlign; import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayoutAlign;
import com.sencha.gxt.widget.core.client.event.HideEvent;
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
/** /**
* *
@ -102,11 +100,17 @@ public class CSVOperationInProgressCard extends WizardCard implements
new SessionExpiredEvent( new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
showErrorAndHide( if (caught instanceof TDGWTIsLockedException) {
"Error in exportCSV", Log.error(caught.getLocalizedMessage());
"An error occured in exportCSV: " showErrorAndHide("Error Locked",
+ caught.getLocalizedMessage(), caught.getLocalizedMessage(), caught);
caught.getStackTrace().toString(), caught); } else {
showErrorAndHide("Error in exportCSV",
"An error occured in exportCSV: "
+ caught.getLocalizedMessage(),
caught);
}
} }
} }
}); });
@ -175,13 +179,8 @@ public class CSVOperationInProgressCard extends WizardCard implements
new SessionExpiredEvent( new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
AlertMessageBox d = new AlertMessageBox("Error in CSV Export", showErrorAndHide("Error in CSV Export",
reason); reason,caught);
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
}
});
d.show();
} }
forceLayout(); forceLayout();

View File

@ -4,7 +4,12 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
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.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.gwtservice.shared.tr.ColumnData;
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.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
@ -40,27 +45,26 @@ public class ColumnDataGridPanel extends ContentPanel implements
protected final CheckBoxSelectionModel<ColumnData> sm; protected final CheckBoxSelectionModel<ColumnData> sm;
protected final Grid<ColumnData> grid; protected final Grid<ColumnData> grid;
private WizardCard parent;
public ColumnDataGridPanel() {
public ColumnDataGridPanel(WizardCard parent) {
this.parent=parent;
Log.debug("ColumnDataGridPanel"); Log.debug("ColumnDataGridPanel");
setHeadingText("Columns"); setHeadingText("Columns");
ColumnConfig<ColumnData, String> labelCol = new ColumnConfig<ColumnData, String>( ColumnConfig<ColumnData, String> labelCol = new ColumnConfig<ColumnData, String>(
props.label()); props.label());
IdentityValueProvider<ColumnData> identity = new IdentityValueProvider<ColumnData>(); IdentityValueProvider<ColumnData> identity = new IdentityValueProvider<ColumnData>();
sm = new CheckBoxSelectionModel<ColumnData>( sm = new CheckBoxSelectionModel<ColumnData>(identity);
identity);
List<ColumnConfig<ColumnData, ?>> l = new ArrayList<ColumnConfig<ColumnData, ?>>(); List<ColumnConfig<ColumnData, ?>> l = new ArrayList<ColumnConfig<ColumnData, ?>>();
l.add(sm.getColumn()); l.add(sm.getColumn());
l.add(labelCol); l.add(labelCol);
ColumnModel<ColumnData> cm = new ColumnModel<ColumnData>(l); ColumnModel<ColumnData> cm = new ColumnModel<ColumnData>(l);
ListStore<ColumnData> store = new ListStore<ColumnData>(props.id()); ListStore<ColumnData> store = new ListStore<ColumnData>(props.id());
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() { RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
@ -91,12 +95,11 @@ public class ColumnDataGridPanel extends ContentPanel implements
} }
}; };
sm.setSelectionMode(SelectionMode.MULTI); sm.setSelectionMode(SelectionMode.MULTI);
grid.setLoader(loader); grid.setLoader(loader);
grid.setSelectionModel(sm); grid.setSelectionModel(sm);
grid.setHeight(300); grid.setHeight(300);
//grid.getView().setAutoExpandColumn(labelCol); // grid.getView().setAutoExpandColumn(labelCol);
grid.getView().setStripeRows(true); grid.getView().setStripeRows(true);
grid.getView().setColumnLines(true); grid.getView().setColumnLines(true);
grid.getView().setAutoFill(true); grid.getView().setAutoFill(true);
@ -104,8 +107,6 @@ public class ColumnDataGridPanel extends ContentPanel implements
grid.setLoadMask(true); grid.setLoadMask(true);
grid.setColumnReordering(true); grid.setColumnReordering(true);
VerticalLayoutContainer con = new VerticalLayoutContainer(); VerticalLayoutContainer con = new VerticalLayoutContainer();
con.setScrollMode(ScrollMode.AUTO); con.setScrollMode(ScrollMode.AUTO);
con.add(grid, new VerticalLayoutData(-1, -1, new Margins(0))); con.add(grid, new VerticalLayoutData(-1, -1, new Margins(0)));
@ -122,10 +123,23 @@ public class ColumnDataGridPanel extends ContentPanel implements
TDGWTServiceAsync.INSTANCE TDGWTServiceAsync.INSTANCE
.getColumns(new AsyncCallback<ArrayList<ColumnData>>() { .getColumns(new AsyncCallback<ArrayList<ColumnData>>() {
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
Log.error("No load columns: " if (caught instanceof TDGWTSessionExpiredException) {
+ caught.getLocalizedMessage()); parent.getEventBus()
.fireEvent(
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
parent.showErrorAndHide("Error Locked",
caught.getLocalizedMessage(), caught);
} else {
Log.error("No load columns: "
+ caught.getLocalizedMessage());
}
}
callback.onFailure(caught); callback.onFailure(caught);
} }
@ -140,12 +154,11 @@ public class ColumnDataGridPanel extends ContentPanel implements
} }
public ArrayList<ColumnData> getSelectedItems() { public ArrayList<ColumnData> getSelectedItems() {
return new ArrayList<ColumnData>(grid return new ArrayList<ColumnData>(grid.getSelectionModel()
.getSelectionModel().getSelectedItems()); .getSelectedItems());
} }
public HandlerRegistration addSelectionHandler( public HandlerRegistration addSelectionHandler(
SelectionHandler<ColumnData> handler) { SelectionHandler<ColumnData> handler) {
return grid.getSelectionModel().addSelectionHandler(handler); return grid.getSelectionModel().addSelectionHandler(handler);