From ca68d2872a11f352d674c2802d21806d0f612fd5 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 16 May 2014 14:04:49 +0000 Subject: [PATCH] Added SessionExpiredShow git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-sdmx-import-widget@95790 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/CodelistSelectionPanel.java | 20 ++++++++- .../client/DatasetSelectionPanel.java | 24 +++++++++-- .../client/SDMXCodelistSelectionCard.java | 2 +- .../client/SDMXDatasetSelectionCard.java | 2 +- .../client/SDMXImportWizardTD.java | 6 ++- .../client/SDMXImportWizardTDEntry.java | 4 +- .../client/SDMXOperationInProgressCard.java | 42 ++++++++++++++----- .../client/SDMXRegistrySelectionCard.java | 11 +++++ 8 files changed, 90 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/CodelistSelectionPanel.java b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/CodelistSelectionPanel.java index 530dc1a..cb3a058 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/CodelistSelectionPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/CodelistSelectionPanel.java @@ -8,7 +8,11 @@ import java.util.Arrays; import java.util.List; 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.type.Codelist; +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 org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle; @@ -67,11 +71,13 @@ public class CodelistSelectionPanel extends ContentPanel implements HasSelection protected Grid grid; protected ResourceBundle res; + + private WizardCard parent; - @SuppressWarnings("unchecked") - public CodelistSelectionPanel(ResourceBundle res) + public CodelistSelectionPanel(WizardCard parent,ResourceBundle res) { + this.parent=parent; this.res=res; setHeaderVisible(false); new Resizable(this, Dir.E, Dir.SE, Dir.S); @@ -186,6 +192,16 @@ public class CodelistSelectionPanel extends ContentPanel implements HasSelection TDGWTServiceAsync.INSTANCE.getCodelists(new AsyncCallback>() { public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + parent.getEventBus() + .fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.error("No codelists retrieved"); + } + + callback.onFailure(caught); } diff --git a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/DatasetSelectionPanel.java b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/DatasetSelectionPanel.java index 9cbed0b..627a97b 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/DatasetSelectionPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/DatasetSelectionPanel.java @@ -8,8 +8,12 @@ import java.util.Arrays; import java.util.List; 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.type.Dataset; - +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 org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.GWT; @@ -61,10 +65,16 @@ public class DatasetSelectionPanel extends ContentPanel implements HasSelectionH protected static final ColumnConfig descriptionColumn = new ColumnConfig(properties.description(), 50, "Description"); protected Grid grid; + + private WizardCard parent; + + @SuppressWarnings("unused") + private ResourceBundle res; - @SuppressWarnings("unchecked") - public DatasetSelectionPanel() + public DatasetSelectionPanel(WizardCard parent, ResourceBundle res) { + this.parent=parent; + this.res=res; setHeaderVisible(false); new Resizable(this, Dir.E, Dir.SE, Dir.S); buildPanel(properties.key(), Arrays.>asList(nameColumn, agencyIdColumn, versionColumn, descriptionColumn), nameColumn); @@ -161,6 +171,14 @@ public class DatasetSelectionPanel extends ContentPanel implements HasSelectionH TDGWTServiceAsync.INSTANCE.getDatasets(new AsyncCallback>() { public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + parent.getEventBus() + .fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.error("No datases retrieved"); + } callback.onFailure(caught); } diff --git a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXCodelistSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXCodelistSelectionCard.java index 9f1babb..8415cc9 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXCodelistSelectionCard.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXCodelistSelectionCard.java @@ -30,7 +30,7 @@ public class SDMXCodelistSelectionCard extends WizardCard { this.importSession = importSession; thisCard=this; - this.codelistSelectionPanel=new CodelistSelectionPanel(res); + this.codelistSelectionPanel=new CodelistSelectionPanel(thisCard,res); codelistSelectionPanel.addSelectionHandler(new SelectionHandler() { diff --git a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXDatasetSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXDatasetSelectionCard.java index cf73940..c8a12a4 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXDatasetSelectionCard.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXDatasetSelectionCard.java @@ -29,7 +29,7 @@ public class SDMXDatasetSelectionCard extends WizardCard { thisCard=this; - this.datasetSelectionPanel=new DatasetSelectionPanel(); + this.datasetSelectionPanel=new DatasetSelectionPanel(thisCard,res); setContent(datasetSelectionPanel); diff --git a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXImportWizardTD.java b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXImportWizardTD.java index 607f5ed..259f678 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXImportWizardTD.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXImportWizardTD.java @@ -3,6 +3,8 @@ package org.gcube.portlets.user.td.sdmximportwidget.client; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession; import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow; +import com.google.web.bindery.event.shared.EventBus; + @@ -20,8 +22,8 @@ public class SDMXImportWizardTD extends WizardWindow { * @param targetId */ - public SDMXImportWizardTD(String title) { - super(title); + public SDMXImportWizardTD(String title,EventBus eventBus) { + super(title,eventBus); setWidth(550); setHeight(520); diff --git a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXImportWizardTDEntry.java b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXImportWizardTDEntry.java index 3a532f0..ed9cfaf 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXImportWizardTDEntry.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXImportWizardTDEntry.java @@ -4,12 +4,14 @@ package org.gcube.portlets.user.td.sdmximportwidget.client; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.EntryPoint; +import com.google.web.bindery.event.shared.SimpleEventBus; public class SDMXImportWizardTDEntry implements EntryPoint { public void onModuleLoad() { - SDMXImportWizardTD importWizard= new SDMXImportWizardTD("SDMXImport"); + SimpleEventBus eventBus=new SimpleEventBus(); + SDMXImportWizardTD importWizard= new SDMXImportWizardTD("SDMXImport",eventBus); Log.info(importWizard.getId()); } } diff --git a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXOperationInProgressCard.java b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXOperationInProgressCard.java index 1880149..1e5a2d2 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXOperationInProgressCard.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXOperationInProgressCard.java @@ -4,8 +4,11 @@ package org.gcube.portlets.user.td.sdmximportwidget.client; 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.sdmx.SDMXImportSession; import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource; +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.WizardCard; import org.gcube.portlets.user.td.sdmximportwidget.client.progress.ImportProgressBarUpdater; @@ -144,8 +147,17 @@ public class SDMXOperationInProgressCard extends WizardCard implements } public void onFailure(Throwable caught) { - showErrorAndHide("Error in importSDMX", - "An error occured in importSDMX", "", caught); + if (caught instanceof TDGWTSessionExpiredException) { + getEventBus() + .fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + + showErrorAndHide("Error in importSDMX", + "An error occured in importSDMX", "", + caught); + } } }); } @@ -194,15 +206,23 @@ public class SDMXOperationInProgressCard extends WizardCard implements public void operationFailed(Throwable caught, String reason, String failureDetails) { - AlertMessageBox d = new AlertMessageBox("Error in SDMX Import", reason); - d.addHideHandler(new HideHandler() { + if (caught instanceof TDGWTSessionExpiredException) { + getEventBus() + .fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + AlertMessageBox d = new AlertMessageBox("Error in SDMX Import", + reason); + d.addHideHandler(new HideHandler() { - public void onHide(HideEvent event) { - // - } + public void onHide(HideEvent event) { + // + } - }); - d.show(); + }); + d.show(); + } } @Override @@ -234,13 +254,13 @@ public class SDMXOperationInProgressCard extends WizardCard implements @Override public void operationGeneratingView() { // TODO Auto-generated method stub - + } @Override public void operationValidate(float elaborated) { // TODO Auto-generated method stub - + } } diff --git a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXRegistrySelectionCard.java b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXRegistrySelectionCard.java index a15397c..73a828f 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXRegistrySelectionCard.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmximportwidget/client/SDMXRegistrySelectionCard.java @@ -4,8 +4,11 @@ package org.gcube.portlets.user.td.sdmximportwidget.client; 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.sdmx.SDMXImportSession; import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource; +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; @@ -146,8 +149,16 @@ public class SDMXRegistrySelectionCard extends WizardCard { ((SDMXRegistrySource)importSession.getSource()), new AsyncCallback() { public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + getEventBus() + .fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.error("SDMXImportSession do not stored " + caught.getLocalizedMessage()); + } } public void onSuccess(Void result) {