This is an automated email from the git hooks/post-receive script. New commit to branch feature/8159-rechargementSourceDeDonneesApresExpiration in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit a185b300d9244650a1e3c7d384193964f950fb30 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Mar 23 09:37:09 2016 +0100 Centralisation de la gestion des erreurs dans UIHelper, Ajout d'une modal pour proposer de ce recoonecter au serveur suite a une expiration (see #8159). --- .../main/java/fr/ird/observe/ObserveRunner.java | 16 +++--- .../observe/ObserveSwingApplicationContext.java | 11 +--- .../fr/ird/observe/db/ObserveSwingDataSource.java | 9 +++- .../fr/ird/observe/ui/ObserveMainUIHandler.java | 5 +- .../src/main/java/fr/ird/observe/ui/UIHelper.java | 62 ++++++++++++++++++++++ .../fr/ird/observe/ui/actions/GotoSiteAction.java | 6 +-- .../observe/ui/actions/ReloadStorageAction.java | 7 +-- .../observe/ui/actions/StartH2WebServerAction.java | 8 +-- .../fr/ird/observe/ui/admin/AdminUILauncher.java | 6 +-- .../observe/ui/admin/report/ReportUIHandler.java | 7 +-- .../ird/observe/ui/content/ContentUIHandler.java | 22 ++------ .../ird/observe/ui/content/ContentUIManager.java | 7 +-- .../content/impl/longline/BranchlineUIHandler.java | 8 +-- .../ui/content/open/ContentOpenableUIHandler.java | 17 ++---- .../ui/content/ref/ContentReferenceUIHandler.java | 6 +-- .../ui/content/table/ContentTableModel.java | 3 +- .../ui/content/table/ContentTableUIHandler.java | 7 +-- .../ird/observe/ui/storage/RemoteUILauncher.java | 17 ++---- .../ird/observe/ui/storage/StorageUIHandler.java | 49 ++++------------- .../ui/tree/NavigationTreeSelectionModel.java | 7 ++- .../observe-application-swing_en_GB.properties | 5 ++ .../observe-application-swing_es_ES.properties | 5 ++ .../observe-application-swing_fr_FR.properties | 5 ++ 23 files changed, 142 insertions(+), 153 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ObserveRunner.java b/observe-application-swing/src/main/java/fr/ird/observe/ObserveRunner.java index 94b6822..df46160 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ObserveRunner.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ObserveRunner.java @@ -29,7 +29,6 @@ import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.actions.StartServerModeAction; import fr.ird.observe.ui.util.FloatConverter; import jaxx.runtime.FileChooserUtil; -import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.swing.application.ApplicationRunner; import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.beanutils.Converter; @@ -63,7 +62,15 @@ import java.util.Map; import java.util.Properties; import static fr.ird.observe.ObserveResourceManager.Resource; -import static fr.ird.observe.configuration.ObserveSwingApplicationConfigOption.*; +import static fr.ird.observe.configuration.ObserveSwingApplicationConfigOption.BACKUP_DIRECTORY; +import static fr.ird.observe.configuration.ObserveSwingApplicationConfigOption.DATA_DIRECTORY; +import static fr.ird.observe.configuration.ObserveSwingApplicationConfigOption.DB_DIRECTORY; +import static fr.ird.observe.configuration.ObserveSwingApplicationConfigOption.INITIAL_DB_DUMP; +import static fr.ird.observe.configuration.ObserveSwingApplicationConfigOption.MAP_DIRECTORY; +import static fr.ird.observe.configuration.ObserveSwingApplicationConfigOption.REPORT_DIRECTORY; +import static fr.ird.observe.configuration.ObserveSwingApplicationConfigOption.RESOURCES_DIRECTORY; +import static fr.ird.observe.configuration.ObserveSwingApplicationConfigOption.TMP_DIRECTORY; +import static fr.ird.observe.configuration.ObserveSwingApplicationConfigOption.VALIDATION_REPORT_DIRECTORY; import static org.nuiton.i18n.I18n.t; /** @@ -407,10 +414,7 @@ public abstract class ObserveRunner extends ApplicationRunner { @Override protected void onError(Exception e) { - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error(e.getMessage(), e); - } + UIHelper.handlingError(e); } protected ObserveSwingApplicationConfig initConfig() throws Exception { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java b/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java index 636449c..02d084a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java @@ -88,7 +88,6 @@ import jaxx.runtime.JAXXUtil; import jaxx.runtime.context.DefaultApplicationContext; import jaxx.runtime.context.JAXXContextEntryDef; import jaxx.runtime.swing.CardLayout2; -import jaxx.runtime.swing.ErrorDialogUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -572,10 +571,7 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext im try { closed = ui.close(); } catch (Exception e) { - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error(e); - } + UIHelper.handlingError(e); } return closed; } @@ -751,10 +747,7 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext im // la base n'a pas pu être chargée proprement // ceci peut être due a une base dans une version pas // assez recente, on doit donc refermer cette base - if (log.isErrorEnabled()) { - log.error("Could not obtain open datas from " + source.getLabel(), e); - } - ErrorDialogUI.showError(e); + UIHelper.handlingError("Could not obtain open datas from " + source.getLabel(), e); // fermeture de la source source.close(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/db/ObserveSwingDataSource.java b/observe-application-swing/src/main/java/fr/ird/observe/db/ObserveSwingDataSource.java index af613a2..7c33dc1 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/db/ObserveSwingDataSource.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/db/ObserveSwingDataSource.java @@ -26,6 +26,7 @@ import fr.ird.observe.services.dto.constants.ReferentialLocale; import fr.ird.observe.services.dto.referential.ReferentialDto; import fr.ird.observe.services.dto.referential.ReferentialReference; import fr.ird.observe.services.dto.referential.ReferentialReferenceSet; +import fr.ird.observe.services.security.InvalidAuthenticationTokenException; import fr.ird.observe.services.service.BabModelVersionException; import fr.ird.observe.services.service.DataSourceService; import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException; @@ -175,7 +176,13 @@ public class ObserveSwingDataSource extends AbstractSerializableBean implements DataSourceService dataSourceService = newService(DataSourceService.class); - dataSourceService.close(); + try { + dataSourceService.close(); + } catch (InvalidAuthenticationTokenException e) { + if (log.isWarnEnabled()) { + log.warn("Connexion from server was already close"); + } + } connection = null; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUIHandler.java index 61e2938..4bdcd19 100755 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUIHandler.java @@ -123,10 +123,7 @@ public class ObserveMainUIHandler { doOpencontent(ui, path, manager, uiClass); } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error(e.getMessage(), e); - } - ErrorDialogUI.showError(e); + UIHelper.handlingError(e); } finally { ui.setBusy(false); String params; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java index 157f9ff..2aa5c2b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java @@ -27,10 +27,12 @@ import fr.ird.observe.services.dto.DataDto; import fr.ird.observe.services.dto.DataFileDto; import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.services.dto.referential.ReferentialDto; +import fr.ird.observe.services.security.InvalidAuthenticationTokenException; import fr.ird.observe.ui.util.table.ObserveBooleanTableCellRenderer; import jaxx.runtime.FileChooserUtil; import jaxx.runtime.JAXXObject; import jaxx.runtime.SwingUtil; +import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.swing.renderer.DecoratorTableCellRenderer; import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; @@ -514,4 +516,64 @@ public class UIHelper extends SwingUtil { return result; } + + public static void handlingError(Exception e) { + handlingError(e.getMessage(), e); + + } + + public static void handlingError(String message, Exception e) { + + if (log.isErrorEnabled()) { + log.error(message, e); + } + + if (containsExceptionInStack(e, InvalidAuthenticationTokenException.class)) { + + ObserveMainUI observeMainUI = ObserveSwingApplicationContext.get().getObserveMainUI(); + + int result = askUser(observeMainUI, + t("observe.storage.server.sessionExpire.title"), + t("observe.storage.server.sessionExpire"), + JOptionPane.OK_CANCEL_OPTION, + new Object[] { + t("observe.storage.server.sessionExpire.reload"), + t("observe.storage.server.sessionExpire.change"), + t("observe.storage.server.sessionExpire.close")}, + 0); + + + // FIXME SBavencoff 23/03/2016 est on sùr que l'erreur proviens du main storage ? + switch (result) { + case 0 : observeMainUI.getReloadStorageAction().run(); break; + case 1 : observeMainUI.getChangeStorageAction().run(); break; + default: observeMainUI.getCloseStorageAction().run(); break; + } + + } else { + ErrorDialogUI.showError(e); + } + + } + + static protected <E extends Throwable> boolean containsExceptionInStack(Throwable e, Class<E> type) { + + if (type.isInstance(e)) { + return true; + } + + while (e.getCause() != null) { + e = e.getCause(); + + if (type.isInstance(e)) { + return true; + } + + } + + return false; + + } + + } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/GotoSiteAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/GotoSiteAction.java index e0f1b04..af15e41 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/GotoSiteAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/GotoSiteAction.java @@ -26,7 +26,6 @@ import fr.ird.observe.configuration.ObserveSwingApplicationConfig; import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.UIHelper; import jaxx.runtime.SwingUtil; -import jaxx.runtime.swing.ErrorDialogUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -79,10 +78,7 @@ public class GotoSiteAction extends AbstractAction { try { Desktop.getDesktop().browse(siteURL.toURI()); } catch (Exception ex) { - if (log.isErrorEnabled()) { - log.error(ex.getMessage(), ex); - } - ErrorDialogUI.showError(ex); + UIHelper.handlingError(ex); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ReloadStorageAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ReloadStorageAction.java index 0a7491b..9bebcf0 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ReloadStorageAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ReloadStorageAction.java @@ -28,8 +28,8 @@ import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.services.configuration.ObserveDataSourceConfigurationTopiaH2; import fr.ird.observe.services.configuration.ObserveDataSourceConfigurationTopiaPG; import fr.ird.observe.ui.ObserveMainUI; +import fr.ird.observe.ui.UIHelper; import jaxx.runtime.SwingUtil; -import jaxx.runtime.swing.ErrorDialogUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -113,10 +113,7 @@ public class ReloadStorageAction extends AbstractObserveAction { // ouverture du service storage.open(); } catch (Exception e) { - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error(e.getMessage(), e); - } + UIHelper.handlingError(e); } } finally { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/StartH2WebServerAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/StartH2WebServerAction.java index 1b54dce..d3cc916 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/StartH2WebServerAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/StartH2WebServerAction.java @@ -23,9 +23,8 @@ package fr.ird.observe.ui.actions; */ import fr.ird.observe.ui.ObserveMainUI; -import fr.ird.observe.ui.ObserveMainUIHandler; +import fr.ird.observe.ui.UIHelper; import jaxx.runtime.SwingUtil; -import jaxx.runtime.swing.ErrorDialogUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -86,10 +85,7 @@ public class StartH2WebServerAction extends AbstractAction { } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Could not start h2 web server ", e); - } - ErrorDialogUI.showError(e); + UIHelper.handlingError("Could not start h2 web server ", e); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUILauncher.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUILauncher.java index c5a6a5e..c02d2bd 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUILauncher.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUILauncher.java @@ -27,7 +27,6 @@ import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.ObserveUIMode; import fr.ird.observe.ui.UIHelper; import jaxx.runtime.JAXXContext; -import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.swing.wizard.BusyChangeListener; import jaxx.runtime.swing.wizard.WizardUILancher; import jaxx.runtime.swing.wizard.ext.WizardState; @@ -272,10 +271,7 @@ public class AdminUILauncher extends WizardUILancher<AdminStep, AdminUIModel, Ad } catch (Exception e) { // on a pas reussit a reouvrir la base precedente - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error("Could not close", e); - } + UIHelper.handlingError("Could not close", e); if (mainUI != null) { mainUI.setMode(ObserveUIMode.NO_DB); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java index de04c66..6e6b40b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java @@ -41,7 +41,6 @@ import fr.ird.observe.ui.admin.config.ConfigUI; import fr.ird.observe.ui.admin.config.SelectDataUI; import fr.ird.observe.ui.storage.tabs.DataSelectionModel; import jaxx.runtime.context.JAXXInitialContext; -import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.swing.editor.bean.BeanComboBox; import jaxx.runtime.swing.wizard.ext.WizardState; import org.apache.commons.logging.Log; @@ -477,10 +476,8 @@ public class ReportUIHandler extends AdminTabUIHandler { } } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Could not obtain report data", e); - } - ErrorDialogUI.showError(e); + + UIHelper.handlingError("Could not obtain report data", e); model.getResultModel().clear(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java index fe3b9b5..368b106 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java @@ -53,7 +53,6 @@ import fr.ird.observe.ui.util.decorator.DataReferenceDecorator; import fr.ird.observe.ui.util.decorator.ReferentialReferenceDecorator; import fr.ird.observe.validation.ValidationContext; import jaxx.runtime.JAXXContext; -import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.swing.JAXXButtonGroup; import jaxx.runtime.swing.editor.bean.BeanComboBox; import jaxx.runtime.swing.editor.bean.BeanListHeader; @@ -392,10 +391,7 @@ public abstract class ContentUIHandler<E extends IdDto> { try { openUI(); } catch (Exception ex) { - ErrorDialogUI.showError(ex); - if (log.isErrorEnabled()) { - log.error(ex.getMessage(), ex); - } + UIHelper.handlingError(ex); stopEditUI(); } } @@ -438,10 +434,7 @@ public abstract class ContentUIHandler<E extends IdDto> { ok = doSave(getBean()); } catch (Exception e) { - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error(e); - } + UIHelper.handlingError(e); } finally { if (ok) { afterSave(refresh); @@ -469,10 +462,7 @@ public abstract class ContentUIHandler<E extends IdDto> { ok = doDelete(getBean()); } catch (Exception e) { - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error(e); - } + UIHelper.handlingError(e); } finally { if (ok) { afterDelete(); @@ -522,11 +512,7 @@ public abstract class ContentUIHandler<E extends IdDto> { UIHelper.openLink(url); } catch (Exception e) { - - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error(e); - } + UIHelper.handlingError(e); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIManager.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIManager.java index 9ac0caf..a534be1 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIManager.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIManager.java @@ -44,6 +44,7 @@ import fr.ird.observe.services.dto.seine.SetSeineSchoolEstimateDto; import fr.ird.observe.services.dto.seine.SetSeineTargetCatchDto; import fr.ird.observe.services.dto.seine.TripSeineDto; import fr.ird.observe.ui.ObserveMainUI; +import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.impl.longline.LonglineDetailCompositionUI; import fr.ird.observe.ui.content.impl.longline.LonglineGlobalCompositionUI; import fr.ird.observe.ui.content.impl.longline.SetLonglineUI; @@ -82,7 +83,6 @@ import fr.ird.observe.ui.tree.ObserveNode; import jaxx.runtime.JAXXContext; import jaxx.runtime.context.JAXXInitialContext; import jaxx.runtime.swing.CardLayout2; -import jaxx.runtime.swing.ErrorDialogUI; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -334,10 +334,7 @@ public class ContentUIManager { content.open(); } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("", e); - } - ErrorDialogUI.showError(e); + UIHelper.handlingError(e); } finally { // on affiche l'ui quoi qu'il arrive ? diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java index 694e34b..c88ac61 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java @@ -23,15 +23,14 @@ package fr.ird.observe.ui.content.impl.longline; */ import fr.ird.observe.db.DataContext; -import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.db.ObserveSwingDataSource; +import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.longline.BranchlineDto; import fr.ird.observe.services.dto.longline.BranchlineDtos; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.ContentUIHandler; import fr.ird.observe.ui.content.ContentUIModel; -import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.validator.swing.SwingValidatorMessage; import jaxx.runtime.validator.swing.SwingValidatorMessageTableModel; import org.apache.commons.logging.Log; @@ -241,10 +240,7 @@ public class BranchlineUIHandler extends ContentUIHandler<BranchlineDto> { try { openUI(); } catch (Exception ex) { - ErrorDialogUI.showError(ex); - if (log.isErrorEnabled()) { - log.error(ex.getMessage(), ex); - } + UIHelper.handlingError(ex); stopEditUI(); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/ContentOpenableUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/ContentOpenableUIHandler.java index 7f43399..16ffa3d 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/ContentOpenableUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/ContentOpenableUIHandler.java @@ -27,12 +27,12 @@ import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.services.dto.longline.TripLonglineDto; import fr.ird.observe.services.dto.seine.TripSeineDto; +import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.ContentUIHandler; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; import fr.ird.observe.validation.ValidationContext; -import jaxx.runtime.swing.ErrorDialogUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.validator.NuitonValidatorScope; @@ -84,10 +84,7 @@ public abstract class ContentOpenableUIHandler<E extends IdDto> extends ContentU try { ok = doOpenData(); } catch (Exception e) { - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error(e); - } + UIHelper.handlingError(e); } finally { if (ok) { @@ -121,10 +118,7 @@ public abstract class ContentOpenableUIHandler<E extends IdDto> extends ContentU try { ok = doCloseData(); } catch (Exception e) { - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error(e); - } + UIHelper.handlingError(e); } finally { if (ok) { @@ -244,10 +238,7 @@ public abstract class ContentOpenableUIHandler<E extends IdDto> extends ContentU return; } } catch (Exception eee) { - if (log.isErrorEnabled()) { - log.error("Could not close current data", eee); - } - ErrorDialogUI.showError(eee); + UIHelper.handlingError("Could not close current data", eee); } stopEditUI(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java index da303ce..1b72126 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java @@ -49,7 +49,6 @@ import fr.ird.observe.ui.util.decorator.ReferentialReferenceDecorator; import fr.ird.observe.validation.ValidationContext; import jaxx.runtime.JAXXContext; import jaxx.runtime.swing.CardLayout2Ext; -import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.swing.editor.bean.BeanListHeader; import jaxx.runtime.validator.swing.SwingValidatorUtil; import org.apache.commons.collections.MapUtils; @@ -364,10 +363,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content usages = getReferentialService().findAllUsages(bean); } catch (DataNotFoundException e) { - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error(e); - } + UIHelper.handlingError(e); return; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableModel.java index 72b15fe..3a18e97 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableModel.java @@ -24,7 +24,6 @@ package fr.ird.observe.ui.content.table; import fr.ird.observe.services.dto.AbstractObserveDto; import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.ui.UIHelper; -import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.logging.Log; @@ -212,7 +211,7 @@ public abstract class ContentTableModel<P extends IdDto, B extends IdDto> extend try { bean = getModel().newTableEditBean(); } catch (Exception e) { - ErrorDialogUI.showError(e); + UIHelper.handlingError(e); } data.add(bean); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java index f3681b9..0777d3b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java @@ -30,6 +30,7 @@ import fr.ird.observe.services.dto.referential.ReferentialReference; import fr.ird.observe.services.dto.referential.SpeciesDto; import fr.ird.observe.services.dto.referential.seine.WeightCategoryDto; import fr.ird.observe.services.dto.seine.TargetCatchDto; +import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.ContentUIHandler; import fr.ird.observe.ui.content.ContentUIModel; @@ -37,7 +38,6 @@ import fr.ird.observe.ui.content.table.impl.longline.WeightMeasuresTableModel; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.util.table.EditableTableModelSupport; import fr.ird.observe.ui.util.table.InlineTableAutotSelectRowAndShowPopupAction; -import jaxx.runtime.swing.ErrorDialogUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.validator.NuitonValidatorScope; @@ -351,10 +351,7 @@ public abstract class ContentTableUIHandler<E extends IdDto, D extends IdDto> ex try { canContinue = prepareSave(bean, objets); } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error(e); - } - ErrorDialogUI.showError(e); + UIHelper.handlingError(e); canContinue = false; } if (!canContinue) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/RemoteUILauncher.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/RemoteUILauncher.java index 5083c20..c35ee38 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/RemoteUILauncher.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/RemoteUILauncher.java @@ -22,9 +22,9 @@ package fr.ird.observe.ui.storage; import fr.ird.observe.db.constants.DbMode; +import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.storage.tabs.SecurityModel; import jaxx.runtime.JAXXContext; -import jaxx.runtime.swing.ErrorDialogUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -102,10 +102,7 @@ public abstract class RemoteUILauncher extends StorageUILauncher { initTask(model); } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Could not init task.", e); - } - ErrorDialogUI.showError(e); + UIHelper.handlingError("Could not init task.", e); throw new RuntimeException(e); } @@ -113,20 +110,14 @@ public abstract class RemoteUILauncher extends StorageUILauncher { execute(); } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Could not create db.", e); - } - ErrorDialogUI.showError(e); + UIHelper.handlingError("Could not create db.", e); throw new RuntimeException(e); } try { applySecurity(); } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Could not apply security to db.", e); - } - ErrorDialogUI.showError(e); + UIHelper.handlingError("Could not apply security to db.", e); throw new RuntimeException(e); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java index c88317d..e2548ef 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java @@ -58,7 +58,6 @@ import fr.ird.observe.ui.storage.tabs.SelectDataUI; import fr.ird.observe.ui.storage.tabs.StorageTabUI; import jaxx.runtime.JAXXContext; import jaxx.runtime.context.DefaultApplicationContext.AutoLoad; -import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.swing.wizard.WizardUILancher; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -393,11 +392,7 @@ public class StorageUIHandler { // cela ne doit pas empécher de continuer // il faut juste supprimer physiquement le repertoire // de la base - Exception e2 = new Exception(t("observe.error.storage.could.not.load.local.db", e.getMessage()), e); - ErrorDialogUI.showError(e2); - if (log.isErrorEnabled()) { - log.error(e2.getMessage(), e2); - } + UIHelper.handlingError(t("observe.error.storage.could.not.load.local.db", e.getMessage()), e); // on conserve l'état localDbIsSane = false; @@ -414,7 +409,7 @@ public class StorageUIHandler { // la base locale n'est pas saine, on doit arrêter l'objectOperation // de changement de base sous peine de perdre la base. Exception e = new Exception(t("observe.error.storage.could.not.backup.unsane.local.db")); - ErrorDialogUI.showError(e); + UIHelper.handlingError(e); return; } // effectue la backup de la base locale existante @@ -426,10 +421,7 @@ public class StorageUIHandler { SqlScriptProducerService dumpProducerService = localDataSource.newSqlScriptProducerService(); backupLocalDatabase(dumpProducerService, f); } catch (Exception e) { - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error(e.getMessage(), e); - } + UIHelper.handlingError(e); return; } } @@ -448,19 +440,13 @@ public class StorageUIHandler { try { FileUtils.deleteDirectory(localDBDirectory); } catch (IOException e) { - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error(e.getMessage(), e); - } + UIHelper.handlingError(e); } } else { try { localDataSource.destroy(); } catch (Exception e) { - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error(e.getMessage(), e); - } + UIHelper.handlingError(e); return; } } @@ -529,10 +515,7 @@ public class StorageUIHandler { try { FileUtils.deleteDirectory(localDBDirectory); } catch (IOException e2) { - ErrorDialogUI.showError(e2); - if (log.isErrorEnabled()) { - log.error(e.getMessage(), e); - } + UIHelper.handlingError(e2); } config.setLocalStorageExist(false); @@ -569,10 +552,7 @@ public class StorageUIHandler { backupLocalDatabase(dumpProducerService, f); config.setInitialDumpExist(true); } catch (Exception e) { - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error(e.getMessage(), e); - } + UIHelper.handlingError(e); } } @@ -585,10 +565,7 @@ public class StorageUIHandler { } } catch (Exception ex) { - ErrorDialogUI.showError(ex); - if (log.isErrorEnabled()) { - log.error(ex.getMessage(), ex); - } + UIHelper.handlingError(ex); throw new RuntimeException(ex); } } @@ -639,10 +616,7 @@ public class StorageUIHandler { outputStream.write(dataDump); } catch (Exception e) { - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error(e); - } + UIHelper.handlingError(e); } } @@ -696,10 +670,7 @@ public class StorageUIHandler { IOUtils.write(dump, fileOutputStream); } catch (IOException e) { - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error(e); - } + UIHelper.handlingError(e); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/NavigationTreeSelectionModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/NavigationTreeSelectionModel.java index 8adcd91..1467d5b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/NavigationTreeSelectionModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/NavigationTreeSelectionModel.java @@ -22,6 +22,7 @@ package fr.ird.observe.ui.tree; import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.ui.UIHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -89,7 +90,11 @@ public class NavigationTreeSelectionModel extends DefaultTreeSelectionModel { if (log.isTraceEnabled()) { log.trace("will select path " + newPath); } - super.setSelectionPath(newPath); + try { + super.setSelectionPath(newPath); + } catch (Exception e) { + UIHelper.handlingError(e); + } } protected boolean beforeSelectionPath(TreePath oldPath, TreePath newPath) { diff --git a/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties b/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties index 9bc4a76..e500afe 100644 --- a/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties +++ b/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties @@ -1950,6 +1950,11 @@ observe.storage.selected.dbMode= observe.storage.selectedCreationMode= observe.storage.server.dataBase= observe.storage.server.db= +observe.storage.server.sessionExpire= +observe.storage.server.sessionExpire.change= +observe.storage.server.sessionExpire.close= +observe.storage.server.sessionExpire.reload= +observe.storage.server.sessionExpire.title= observe.storage.showMigrationProgression= observe.storage.showMigrationSql= observe.storage.step.backup= diff --git a/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties b/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties index 787b8d1..f66dd5a 100644 --- a/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties +++ b/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties @@ -1952,6 +1952,11 @@ observe.storage.selected.dbMode=Tipo de origen de datos seleccionado observe.storage.selectedCreationMode=Modo de creación seleccionada observe.storage.server.dataBase= observe.storage.server.db= +observe.storage.server.sessionExpire= +observe.storage.server.sessionExpire.change= +observe.storage.server.sessionExpire.close= +observe.storage.server.sessionExpire.reload= +observe.storage.server.sessionExpire.title= observe.storage.showMigrationProgression=Mostrar el progreso de las actualizaciones observe.storage.showMigrationSql=Mostrar las consultas sql de las actualizaciones observe.storage.step.backup=Copia de seguridad diff --git a/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties b/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties index 428dad6..6c7c649 100644 --- a/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties +++ b/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties @@ -1942,6 +1942,11 @@ observe.storage.selected.dbMode=Type de source de données sélectionné observe.storage.selectedCreationMode=Mode de création sélectionné observe.storage.server.dataBase=Base de données observe.storage.server.db=(serveur distant) +observe.storage.server.sessionExpire=La connexion avec le serveur n'est plus active. Que voulez-faire ?\n\n\t - Fermer la connexion avec le serveur, \n\t - Changer de source de données, \n\t - Se re-conncter au serveur. +observe.storage.server.sessionExpire.change=Changer +observe.storage.server.sessionExpire.close=Fermer +observe.storage.server.sessionExpire.reload=Re-connecter +observe.storage.server.sessionExpire.title=Connexion perdue observe.storage.showMigrationProgression=Afficher la progression lors des mises à jour observe.storage.showMigrationSql=Afficher les requêtes sql lors des mises à jour observe.storage.step.backup=Sauvegarde -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.