rename AbstractCdmEditorPartE4 -> AbstractCdmEditorPart
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / model / DeleteResultMessagingUtils.java
index 66874f128c32cfaffb6dd8d63d2d5beafd580556..51471d425ecb13016ff1bdb35f08b10fa49e0ed2 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$
 /**
 * Copyright (C) 2015 EDIT
 * European Distributed Institute of Taxonomy
@@ -14,12 +13,12 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
 import org.eclipse.core.runtime.Status;
 
 import eu.etaxonomy.cdm.api.service.DeleteResult;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
+import eu.etaxonomy.taxeditor.l10n.Messages;
 
 /**
  * @author k.luther
@@ -27,6 +26,10 @@ import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
  *
  */
 public class DeleteResultMessagingUtils extends MessagingUtils {
+
+    private static final String DELETE_WAS_ABORTED = Messages.DeleteResultMessagingUtils_ABORT;
+    private static final String DELETE_WAS_SUCCESSFULL = Messages.DeleteResultMessagingUtils_SUCCES;
+
     /**
      * Displays a message {@link org.eclipse.jface.dialogs.MessageDialog}.
      *
@@ -39,16 +42,16 @@ public class DeleteResultMessagingUtils extends MessagingUtils {
             return;
         }
         List<String> details = new ArrayList<String>();
-        String title= "";
+        String title= ""; //$NON-NLS-1$
 
         if (result.getExceptions().size() > 0){
             for (Exception e:result.getExceptions()){
                 details.add(e.getMessage());
             }
             if (result.isOk()){
-                title = "Delete was successfull.";
+                title = DELETE_WAS_SUCCESSFULL;
             } else {
-                title = "Delete was aborted.";
+                title = DELETE_WAS_ABORTED;
             }
         }
         StringBuffer relatedObjectsString = new StringBuffer();
@@ -63,7 +66,6 @@ public class DeleteResultMessagingUtils extends MessagingUtils {
                 } else{
                     relatedObjects.add(object.getUserFriendlyTypeName());
                 }
-
             }
 
             for (String relatedObject: relatedObjects){
@@ -72,44 +74,35 @@ public class DeleteResultMessagingUtils extends MessagingUtils {
                 relatedObjectsString.append(System.lineSeparator());
             }
         }
-        message = message + "\n" ;
+        message = message + "\n" ; //$NON-NLS-1$
         String stackTraceWithContext = getContextInfo(details);
-        CdmDeleteErrorDialog ced = new CdmDeleteErrorDialog(AbstractUtility.getShell(), title, message,new Status(IStatus.INFO, pluginId, relatedObjectsString.toString(), result.getExceptions().iterator().next()), stackTraceWithContext, result.getUpdatedObjects().toArray());
+        CdmDeleteErrorDialog ced = new CdmDeleteErrorDialog(AbstractUtility.getShell(), title, message,new Status(IStatus.INFO, pluginId, relatedObjectsString.toString(), result.getExceptions() != null? result.getExceptions().iterator().next(): null), stackTraceWithContext, result.getUpdatedObjects().toArray());
 
         ced.open();
-
-
-
     }
-    
+
     public static void messageDialogWithDetails(IStatus result, String message, String pluginId) {
-       
+
         List<String> details = new ArrayList<String>();
-        String title= "";
+        String title= ""; //$NON-NLS-1$
         Throwable e = null;
         if (result.isMultiStatus()){
             for (IStatus childStatus:result.getChildren()){
                 details.add(childStatus.getMessage());
             }
             e = result.getChildren()[0].getException();
-            if (result.equals(Status.OK_STATUS)|| result.equals(Status.WARNING)){
-                title = "Delete was successfull.";
+            if (result.equals(Status.OK_STATUS)|| result.equals(IStatus.WARNING)){
+                title = DELETE_WAS_SUCCESSFULL;
             } else {
-                title = "Delete was aborted.";
+                title = DELETE_WAS_ABORTED;
             }
         }
-        StringBuffer relatedObjectsString = new StringBuffer();
-        Object[] relatedObjects = new ArrayList<Object>().toArray(); 
-      
-       
-    
+        Object[] relatedObjects = new ArrayList<Object>().toArray();
+
         String stackTraceWithContext = getContextInfo(details);
         CdmDeleteErrorDialog ced = new CdmDeleteErrorDialog(AbstractUtility.getShell(), title, message,new Status(IStatus.INFO, pluginId, null, e), stackTraceWithContext, relatedObjects);
 
         ced.open();
-
-
-
     }
-    
+
 }