Author: tchemit Date: 2013-02-11 21:56:49 +0100 (Mon, 11 Feb 2013) New Revision: 400 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/400 Log: fixes #1849: [ERGO] - Gestion des messages d'erreur Added: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiBusinessException.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiTechnicalException.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiErrorHelper.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiExceptionHandler.java Removed: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceTechnicalException.java Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/AbstractTuttiService.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceContext.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/TuttiReferentialImportExportService.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiBeanUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfig.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-warning-validation.xml trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/AbstractTuttiService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/AbstractTuttiService.java 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/AbstractTuttiService.java 2013-02-11 20:56:49 UTC (rev 400) @@ -72,7 +72,7 @@ } } catch (IOException e) { - throw new TuttiServiceTechnicalException("Could not compress directory", e); + throw new TuttiTechnicalException("Could not compress directory", e); } } } Added: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiBusinessException.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiBusinessException.java (rev 0) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiBusinessException.java 2013-02-11 20:56:49 UTC (rev 400) @@ -0,0 +1,48 @@ +package fr.ifremer.tutti.service; + +/* + * #%L + * Tutti :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +/** + * To box any business exception. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0 + */ +public class TuttiBusinessException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + public TuttiBusinessException(String message) { + super(message); + } + + public TuttiBusinessException(String message, Throwable cause) { + super(message, cause); + } + + public TuttiBusinessException(Throwable cause) { + super(cause); + } +} Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiBusinessException.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceContext.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceContext.java 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceContext.java 2013-02-11 20:56:49 UTC (rev 400) @@ -92,7 +92,7 @@ S s = (S) services.get(serviceType); return s; } catch (ExecutionException e) { - throw new TuttiServiceTechnicalException( + throw new TuttiTechnicalException( "Could not instanciate service " + serviceType, e); } } Deleted: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceTechnicalException.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceTechnicalException.java 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceTechnicalException.java 2013-02-11 20:56:49 UTC (rev 400) @@ -1,51 +0,0 @@ -package fr.ifremer.tutti.service; - -/* - * #%L - * Tutti :: Application - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -/** - * Any techincal exception of service should be boxed in a such exception. - * - * @author tchemit <chemit@codelutin.com/> - * @since 0.1 - */ -public class TuttiServiceTechnicalException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - public TuttiServiceTechnicalException() { - } - - public TuttiServiceTechnicalException(String message) { - super(message); - } - - public TuttiServiceTechnicalException(String message, Throwable cause) { - super(message, cause); - } - - public TuttiServiceTechnicalException(Throwable cause) { - super(cause); - } -} Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiTechnicalException.java (from rev 398, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceTechnicalException.java) =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiTechnicalException.java (rev 0) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiTechnicalException.java 2013-02-11 20:56:49 UTC (rev 400) @@ -0,0 +1,51 @@ +package fr.ifremer.tutti.service; + +/* + * #%L + * Tutti :: Application + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +/** + * Any techincal exception should be boxed in a such exception. + * + * @author tchemit <chemit@codelutin.com/> + * @since 0.1 + */ +public class TuttiTechnicalException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + public TuttiTechnicalException() { + } + + public TuttiTechnicalException(String message) { + super(message); + } + + public TuttiTechnicalException(String message, Throwable cause) { + super(message, cause); + } + + public TuttiTechnicalException(Throwable cause) { + super(cause); + } +} Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/TuttiReferentialImportExportService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/TuttiReferentialImportExportService.java 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/referential/TuttiReferentialImportExportService.java 2013-02-11 20:56:49 UTC (rev 400) @@ -38,7 +38,7 @@ import fr.ifremer.tutti.service.AbstractTuttiService; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.TuttiServiceContext; -import fr.ifremer.tutti.service.TuttiServiceTechnicalException; +import fr.ifremer.tutti.service.TuttiTechnicalException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.csv.Export; @@ -270,7 +270,7 @@ } catch (IOException e) { throw e; } catch (Exception e) { - throw new TuttiServiceTechnicalException("Could not export species to file: " + file, e); + throw new TuttiTechnicalException("Could not export species to file: " + file, e); } finally { Closeables.closeQuietly(writer); } @@ -316,7 +316,7 @@ } catch (IOException e) { throw e; } catch (Exception e) { - throw new TuttiServiceTechnicalException("Could not export species to file: " + file, e); + throw new TuttiTechnicalException("Could not export species to file: " + file, e); } finally { Closeables.closeQuietly(writer); } @@ -353,7 +353,7 @@ } catch (IOException e) { throw e; } catch (Exception e) { - throw new TuttiServiceTechnicalException("Could not export species to file: " + file, e); + throw new TuttiTechnicalException("Could not export species to file: " + file, e); } finally { Closeables.closeQuietly(writer); } @@ -396,7 +396,7 @@ } catch (IOException e) { throw e; } catch (Exception e) { - throw new TuttiServiceTechnicalException("Could not export species to file: " + file, e); + throw new TuttiTechnicalException("Could not export species to file: " + file, e); } finally { Closeables.closeQuietly(writer); } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java 2013-02-11 20:56:49 UTC (rev 400) @@ -30,7 +30,6 @@ import fr.ifremer.tutti.service.TuttiService; import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig; import jaxx.runtime.SwingUtil; -import jaxx.runtime.swing.ErrorDialogUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jdesktop.beans.AbstractBean; @@ -176,9 +175,7 @@ if (log.isErrorEnabled()) { log.error("Task [" + this + "] error: " + e.getMessage(), e); } - if (e instanceof Exception) { - ErrorDialogUI.showError((Exception) e); - } + throw new TuttiExceptionHandler.TuttiActionException(e); } finally { if (log.isInfoEnabled()) { log.info("Task [" + this + "] done"); @@ -192,7 +189,6 @@ this.releaseAction(event); } finally { - synchronized (lock) { actions.remove(AbstractTuttiAction.this); } @@ -236,8 +232,6 @@ protected boolean canceled; - private final String actionName; - private final String actionDescription; private JDialog d; @@ -246,7 +240,6 @@ public ActionTimerTask(A action) { this.action = action; - this.actionName = action.getActionName(); this.actionDescription = action.getActionDescription(); } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiBeanUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiBeanUIModel.java 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiBeanUIModel.java 2013-02-11 20:56:49 UTC (rev 400) @@ -25,7 +25,7 @@ */ import fr.ifremer.tutti.persistence.entities.IdAware; -import fr.ifremer.tutti.service.TuttiServiceTechnicalException; +import fr.ifremer.tutti.service.TuttiTechnicalException; import org.jdesktop.beans.AbstractSerializableBean; import org.nuiton.util.beans.Binder; @@ -80,7 +80,7 @@ E result = entityType.newInstance(); return result; } catch (Exception e) { - throw new TuttiServiceTechnicalException( + throw new TuttiTechnicalException( "Could not instanciate entity of type " + entityType.getName(), e); } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2013-02-11 20:56:49 UTC (rev 400) @@ -37,7 +37,6 @@ import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI; import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUI; import jaxx.runtime.swing.AboutPanel; -import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -108,9 +107,6 @@ @Override public void afterInitUI() { - // Sync to error dialog - ErrorDialogUI.init(ui); - initUI(ui); // Init SwingSession @@ -130,7 +126,6 @@ screen = TuttiScreen.SELECT_CRUISE; context.setScreen(screen); - } @Override @@ -256,8 +251,8 @@ try { Desktop.getDesktop().browse(siteURL.toURI()); } catch (Exception e) { - log.error("Failed to open '" + siteURL + "' in browser", e); - ErrorDialogUI.showError(e); + TuttiUIContext.getErrorHelper().showErrorDialog( + "Failed to open '" + siteURL + "' in browser", e); } } } @@ -398,10 +393,8 @@ } } catch (Exception e) { - ErrorDialogUI.showError(e); - if (log.isErrorEnabled()) { - log.error("Could not change to screen " + screen, e); - } + TuttiUIContext.getErrorHelper().showErrorDialog( + "Could not change to screen " + screen, e); // go back to home context.setScreen(TuttiScreen.SELECT_CRUISE); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2013-02-11 20:56:49 UTC (rev 400) @@ -52,6 +52,11 @@ if (log.isInfoEnabled()) { log.info("Starting Tutti with arguments: " + Arrays.toString(args)); } + + // override default exception management (after config init) + Thread.setDefaultUncaughtExceptionHandler(new TuttiExceptionHandler()); + System.setProperty("sun.awt.exception.handler", TuttiExceptionHandler.class.getName()); + // Create configuration TuttiApplicationConfig config = new TuttiApplicationConfig("tutti.config", args); Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiErrorHelper.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiErrorHelper.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiErrorHelper.java 2013-02-11 20:56:49 UTC (rev 400) @@ -0,0 +1,90 @@ +package fr.ifremer.tutti.ui.swing; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.service.TuttiBusinessException; +import org.jdesktop.swingx.JXErrorPane; +import org.jdesktop.swingx.error.ErrorInfo; +import org.jdesktop.swingx.error.ErrorReporter; + +import javax.swing.JOptionPane; + +import static org.nuiton.i18n.I18n._; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0 + */ +public class TuttiErrorHelper implements ErrorReporter { + + protected TuttiUIContext context; + + public TuttiErrorHelper(TuttiUIContext context) { + this.context = context; + } + + /** + * Display a user friendly error frame. + * + * @param message message for user + * @param cause exception cause + */ + public void showErrorDialog(String message, Throwable cause) { + + if (cause instanceof TuttiBusinessException) { + JOptionPane.showMessageDialog(context.getMainUI(), cause.getMessage(), + _("tutti.ui.common.error"), + JOptionPane.ERROR_MESSAGE); + } else { + + JXErrorPane pane = new JXErrorPane(); + ErrorInfo info = new ErrorInfo(_("tutti.common.error"), + _("tutti.error.errorpane.htmlmessage", message), null, null, + cause, null, null); + pane.setErrorInfo(info); + pane.setErrorReporter(this); + JXErrorPane.showDialog(context.getMainUI(), pane); + } + + } + + /** + * Display a user friendly error frame. + * + * @param message message for user + */ + public void showErrorDialog(String message) { + showErrorDialog(message, null); + } + + @Override + public void reportError(ErrorInfo errorInfo) throws NullPointerException { + + showErrorDialog(errorInfo.getBasicErrorMessage(), errorInfo.getErrorException()); + } + +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiErrorHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiExceptionHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiExceptionHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiExceptionHandler.java 2013-02-11 20:56:49 UTC (rev 400) @@ -0,0 +1,85 @@ +package fr.ifremer.tutti.ui.swing; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.service.TuttiTechnicalException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Tutti global exception handler. + * <p/> + * Catch all application uncaught and display it in a custom JoptionPane + * or JXErrorPane. + * <p/> + * See http://stackoverflow.com/a/4448569/1165234 for details. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0 + */ +public class TuttiExceptionHandler implements Thread.UncaughtExceptionHandler { + + private static final Log log = + LogFactory.getLog(TuttiExceptionHandler.class); + + public static class TuttiActionException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + public TuttiActionException(Throwable cause) { + super(cause); + } + } + + @Override + public void uncaughtException(Thread t, Throwable ex) { + handleException(t.getName(), ex); + } + + public void handle(Throwable thrown) { + // for EDT exceptions + handleException(Thread.currentThread().getName(), thrown); + } + + protected void handleException(String tname, Throwable ex) { + if (log.isErrorEnabled()) { + log.error("Global application exception [" + tname + "]", ex); + } + + Throwable cause = ex; + + + if (cause instanceof TuttiTechnicalException || + cause instanceof TuttiActionException) { + cause = cause.getCause(); + } +// while (cause != null && !(cause instanceof TuttiTechnicalException)) { +// cause = cause.getCause(); +// } + + TuttiUIContext.getErrorHelper().showErrorDialog(cause.getMessage(), ex); + } + +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiExceptionHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-02-11 20:56:49 UTC (rev 400) @@ -125,6 +125,8 @@ */ protected final SwingSession swingSession; + protected final TuttiErrorHelper errorHelper; + /** * Id of last selected program (can be null if none ever selected). * @@ -177,11 +179,20 @@ return applicationContext; } + public static TuttiUIContext getApplicationContext() { + return applicationContext; + } + + public static TuttiErrorHelper getErrorHelper() { + return applicationContext.errorHelper; + } + protected TuttiUIContext(TuttiApplicationConfig config) { this.config = config; this.resourceLoader = new RessourceClassLoader(Thread.currentThread().getContextClassLoader()); this.serviceContext = new TuttiServiceContext(resourceLoader, config.getServiceConfig()); this.swingSession = new SwingSession(getConfig().getUIConfigFile(), false); + this.errorHelper= new TuttiErrorHelper(this); UIMessageNotifier logMessageNotifier = new UIMessageNotifier() { @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfig.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfig.java 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiApplicationConfig.java 2013-02-11 20:56:49 UTC (rev 400) @@ -25,7 +25,7 @@ */ import com.google.common.base.Charsets; -import fr.ifremer.tutti.service.TuttiServiceTechnicalException; +import fr.ifremer.tutti.service.TuttiTechnicalException; import fr.ifremer.tutti.service.config.TuttiServiceConfig; import fr.ifremer.tutti.service.config.TuttiServiceConfigOption; import fr.ifremer.tutti.ui.swing.util.editor.CoordinateEditorType; @@ -106,7 +106,7 @@ applicationConfig.parse(args); } catch (ArgumentsParserException e) { - throw new TuttiServiceTechnicalException( + throw new TuttiTechnicalException( "Could not parse configuration", e); } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-02-11 20:56:49 UTC (rev 400) @@ -31,7 +31,6 @@ import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.ui.swing.AbstractTuttiAction; import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; -import jaxx.runtime.swing.ErrorDialogUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXTable; @@ -108,44 +107,39 @@ // remove selected batch and all his children - try { + // remove parent batch (will destroy all his childs from db) + persistenceService.deleteSpeciesBatch(selectedBatch.getId()); - // remove parent batch (will destroy all his childs from db) - persistenceService.deleteSpeciesBatch(selectedBatch.getId()); + // update speciesUsed + handler.removeFromSpeciesUsed(selectedBatch); - // update speciesUsed - handler.removeFromSpeciesUsed(selectedBatch); + // collect of rows to remove from model + Set<SpeciesBatchRowModel> rowToRemove = + Sets.newHashSet(selectedBatch); - // collect of rows to remove from model - Set<SpeciesBatchRowModel> rowToRemove = - Sets.newHashSet(selectedBatch); + handler.collectChilds(selectedBatch, rowToRemove); - handler.collectChilds(selectedBatch, rowToRemove); + // remove all rows from the model + getModel().getRows().removeAll(rowToRemove); - // remove all rows from the model - getModel().getRows().removeAll(rowToRemove); + // refresh table from parent batch row index to the end + tableModel.fireTableDataChanged(); - // refresh table from parent batch row index to the end - tableModel.fireTableDataChanged(); + if (tableModel.getRowCount() > 0) { - if (tableModel.getRowCount() > 0) { + // select first row + AbstractSelectTableAction.doSelectCell(table, 0, 0); + } else { - // select first row - AbstractSelectTableAction.doSelectCell(table, 0, 0); - } else { + table.clearSelection(); + } - table.clearSelection(); - } + if (table.isEditing()) { - if (table.isEditing()) { - - // but no edit it - table.getCellEditor().stopCellEditing(); - } - } catch (Exception e) { - - ErrorDialogUI.showError(e); + // but no edit it + table.getCellEditor().stopCellEditing(); } + } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java 2013-02-11 20:56:49 UTC (rev 400) @@ -31,7 +31,6 @@ import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.ui.swing.AbstractTuttiAction; import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; -import jaxx.runtime.swing.ErrorDialogUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXTable; @@ -87,42 +86,36 @@ Preconditions.checkState(!TuttiEntities.isNew(parentBatch), "Can't remove sub batch if batch is not persisted"); - try { + // save parent batch (will destroy all his childs from db) + persistenceService.deleteSpeciesSubBatch(parentBatch.getId()); - // save parent batch (will destroy all his childs from db) - persistenceService.deleteSpeciesSubBatch(parentBatch.getId()); + if (parentBatch.isBatchRoot()) { - if (parentBatch.isBatchRoot()) { + // update speciesUsed + handler.removeFromSpeciesUsed(parentBatch); + } - // update speciesUsed - handler.removeFromSpeciesUsed(parentBatch); - } + // collect of rows to remove from model + Set<SpeciesBatchRowModel> rowToRemove = Sets.newHashSet(); - // collect of rows to remove from model - Set<SpeciesBatchRowModel> rowToRemove = Sets.newHashSet(); + handler.collectChilds(parentBatch, rowToRemove); - handler.collectChilds(parentBatch, rowToRemove); + // remove all rows from the model + getModel().getRows().removeAll(rowToRemove); - // remove all rows from the model - getModel().getRows().removeAll(rowToRemove); + // remove childs from parent batch + parentBatch.setBatchChilds(null); - // remove childs from parent batch - parentBatch.setBatchChilds(null); + // refresh table from parent batch row index to the end + handler.getTableModel().fireTableDataChanged(); - // refresh table from parent batch row index to the end - handler.getTableModel().fireTableDataChanged(); + // select parent batch row + AbstractSelectTableAction.doSelectCell(table, rowIndex, 0); - // select parent batch row - AbstractSelectTableAction.doSelectCell(table, rowIndex, 0); + if (table.isEditing()) { - if (table.isEditing()) { - - // but no edit it - table.getCellEditor().stopCellEditing(); - } - } catch (Exception e) { - - ErrorDialogUI.showError(e); + // but no edit it + table.getCellEditor().stopCellEditing(); } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java 2013-02-11 20:56:49 UTC (rev 400) @@ -1,6 +1,30 @@ package fr.ifremer.tutti.ui.swing.util; +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + /** * * @author kmorin <kmorin@codelutin.com> Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-02-11 20:56:49 UTC (rev 400) @@ -28,7 +28,7 @@ import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.Program; import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; -import fr.ifremer.tutti.service.TuttiServiceTechnicalException; +import fr.ifremer.tutti.service.TuttiTechnicalException; import fr.ifremer.tutti.ui.swing.TuttiUIContext; import jaxx.runtime.JAXXUtil; import jaxx.runtime.context.JAXXContextEntryDef; @@ -293,7 +293,7 @@ try { PropertyUtils.setSimpleProperty(bean, property, value); } catch (Exception e) { - throw new TuttiServiceTechnicalException("Could not set property '" + property + "' on object of type '" + bean.getClass().getName() + "'", e); + throw new TuttiTechnicalException("Could not set property '" + property + "' on object of type '" + bean.getClass().getName() + "'", e); } } @@ -303,7 +303,7 @@ try { return PropertyUtils.getSimpleProperty(bean, property); } catch (Exception e) { - throw new TuttiServiceTechnicalException("Could not get property '" + property + "' on object of type '" + bean.getClass().getName() + "'", e); + throw new TuttiTechnicalException("Could not get property '" + property + "' on object of type '" + bean.getClass().getName() + "'", e); } } Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-warning-validation.xml =================================================================== --- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-warning-validation.xml 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-warning-validation.xml 2013-02-11 20:56:49 UTC (rev 400) @@ -1,5 +1,29 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Tutti :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 - 2013 Ifremer + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + <!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN" "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> Property changes on: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-warning-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-11 17:33:57 UTC (rev 399) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-11 20:56:49 UTC (rev 400) @@ -136,6 +136,7 @@ tutti.action.validateCatches.tip=Valider les captures tutti.application.config=Configuration de l'application Tutti tutti.application.name=Tutti +tutti.common.error=Erreur tutti.config.category.applications=Application tutti.config.category.applications.description=Application tutti.config.category.shortcuts=Raccourcis @@ -151,6 +152,7 @@ tutti.dialog.catches.species.split.weightNotNull.message=Pour catégoriser un lot, il ne doit pas avoir de poids sous-échantillonné. Catégoriser le lot mettra le poids sous-échantillonné à nul. tutti.dialog.catches.species.split.weightNotNull.title=Poids sous-échantillonné non nul tutti.duration.format=dj Hh m'm' +tutti.error.errorpane.htmlmessage=<html><body><b>Une erreur s'est produite</b>\:<br/>%s</body></html> tutti.file.csv=Extension d'un fichier csv tutti.file.protocol=Extension d'un fichier de protocole Tutti tutti.flash.information.all.caractristic.exported=Toutes les caractéristiques exportées dans le fichier %s. @@ -442,6 +444,7 @@ tutti.to.be.done=< A FAIRE > tutti.tooltip.attachment.none=Pas de pièce-jointes tutti.tooltip.comment.none=Pas de commentaire +tutti.ui.common.error=Erreur tutti.validator.error.comment.too.long=Taille de commentaire trop longue (limitée à %s caractères) tutti.validator.error.createSpeciesBatch.batchWeight.invalidValue=Le poids du lot doit être strictement positif tutti.validator.error.createSpeciesBatch.sortedUnsortedCategory.required=La catégorie Vrac / Hors Vrac est obligatoire