MessagingUtils : added option for displaying contact message in the error dialog
authorCherian Mathew <c.mathew@bgbm.org>
Fri, 15 Aug 2014 16:14:57 +0000 (16:14 +0000)
committerCherian Mathew <c.mathew@bgbm.org>
Fri, 15 Aug 2014 16:14:57 +0000 (16:14 +0000)
ApplicationWorkbenchAdvisor : using new method with contact message
AbstractBulkEditorInput : added errorDialog for MergeException

eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/ApplicationWorkbenchAdvisor.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java

index 6de492486c1fbff9f58e26dd7894e0e8fa334e64..18ac99ecf3935013e0d38fe0baebc4a78d044b35 100644 (file)
@@ -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);                                          
                        }                           
                    }
                }
index 8936ca8560c3e9d81c6170248160973188304e95..f9d5845ccfce29db85ab0997ad1cb3124dcbac3f 100644 (file)
@@ -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<T extends ICdmBase> 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;
index 8c7cc4d9ddce81b56a0672f788303dc5bcfeee47..0e8e2c456115beb5d056246130d5ae3d4717d0d3 100644 (file)
@@ -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);
                                
                        }