From 1b9ae4254bfb9a16c037f135937dbfe6528af8f8 Mon Sep 17 00:00:00 2001 From: Cherian Mathew Date: Fri, 15 Aug 2014 16:14:57 +0000 Subject: [PATCH] MessagingUtils : added option for displaying contact message in the error dialog ApplicationWorkbenchAdvisor : using new method with contact message AbstractBulkEditorInput : added errorDialog for MergeException --- .../taxeditor/ApplicationWorkbenchAdvisor.java | 5 +++-- .../bulkeditor/input/AbstractBulkEditorInput.java | 10 ++++++++-- .../etaxonomy/taxeditor/model/MessagingUtils.java | 15 +++++++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/ApplicationWorkbenchAdvisor.java b/eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/ApplicationWorkbenchAdvisor.java index 6de492486..18ac99ecf 100644 --- a/eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/ApplicationWorkbenchAdvisor.java +++ b/eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/ApplicationWorkbenchAdvisor.java @@ -163,9 +163,10 @@ public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { if(t != null && t instanceof RuntimeException) { MessagingUtils.errorDialog("Unexpected error", null, - MessagingUtils.UNEXPECTED_ERROR_MESSAGE + MessagingUtils.CONTACT_MESSAGE, + MessagingUtils.UNEXPECTED_ERROR_MESSAGE, statusAdapter.getStatus().getPlugin(), - t); + t, + true); } } } diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java index 8936ca856..f9d5845cc 100644 --- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java +++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java @@ -34,6 +34,7 @@ import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorQuery; import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider; import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.CdmBaseSortProvider; import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.TitleCacheComparator; +import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin; import eu.etaxonomy.taxeditor.model.MessagingUtils; import eu.etaxonomy.taxeditor.store.CdmStore; @@ -224,9 +225,14 @@ public abstract class AbstractBulkEditorInput implements IEd public boolean merge(T entity, T mergeTarget) { if (entity instanceof IMergable) { try { - CdmStore.getService(ICommonService.class).merge((IMergable)mergeTarget, (IMergable)entity, null); + CdmStore.getService(ICommonService.class).merge((IMergable)mergeTarget, (IMergable)entity, null); } catch (MergeException e) { - MessagingUtils.error(getClass(), e); + MessagingUtils.errorDialog("Bulk Editor Merge Error", + this, + "Could not merge chosen objects of type " + entity.getClass().getName(), + TaxeditorBulkeditorPlugin.PLUGIN_ID, + e, + true); } } return true; diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java index 8c7cc4d9d..0e8e2c456 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java @@ -193,19 +193,26 @@ public class MessagingUtils { final Object source, final String message, final String pluginId, - final Throwable t) { + final Throwable t, + boolean addContactMesg) { // Usually the status contains only the first line of the stack trace. // For the unexpected messages we need the entire stack trace so we // create a new status with the entire stacktrace StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); + String finalMessage = t.getMessage(); + if(addContactMesg) { + finalMessage += MessagingUtils.CONTACT_MESSAGE; + } IStatus status = new Status(IStatus.ERROR, pluginId, - t.getMessage(), + finalMessage, new Exception(sw.toString())); errorDialog(title, source, message, status); } + + /** * Displays a {@link eu.etaxonomy.taxeditor.model.CdmErrorDialog}. * @@ -222,7 +229,7 @@ public class MessagingUtils { final IStatus status, final boolean showStackTrace) { if(showStackTrace && status.getException() != null) { - errorDialog(title, source, status.getPlugin(), message, status.getException()); + errorDialog(title, source, status.getPlugin(), message, status.getException(),true); } else { errorDialog(title, source, message, status); } @@ -283,7 +290,7 @@ public class MessagingUtils { warningDialog(title, source, String.format("You are missing sufficient permissions for the operation \"%s\". %s", operationlabel, hint)); } else { title = "Error executing operation"; - errorDialog(title, source, String.format("An error occured while executing %s. %s", operationlabel, hint), PID, ex); + errorDialog(title, source, String.format("An error occured while executing %s. %s", operationlabel, hint), PID, ex, true); } -- 2.34.1