3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.model
;
12 import java
.util
.ArrayList
;
13 import java
.util
.Iterator
;
14 import java
.util
.List
;
16 import org
.eclipse
.core
.runtime
.IStatus
;
17 import org
.eclipse
.core
.runtime
.Status
;
19 import eu
.etaxonomy
.cdm
.api
.service
.DeleteResult
;
20 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
21 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
28 public class DeleteResultMessagingUtils
extends MessagingUtils
{
30 * Displays a message {@link org.eclipse.jface.dialogs.MessageDialog}.
36 public static void messageDialogWithDetails(DeleteResult result
, String message
, String pluginId
) {
37 if (result
.isOk() && result
.getExceptions().isEmpty()){
40 List
<String
> details
= new ArrayList
<String
>();
43 if (result
.getExceptions().size() > 0){
44 for (Exception e
:result
.getExceptions()){
45 details
.add(e
.getMessage());
48 title
= "Delete was successfull.";
50 title
= "Delete was aborted.";
53 StringBuffer relatedObjectsString
= new StringBuffer();
54 List
<String
> relatedObjects
= new ArrayList
<String
>();
55 if (result
.getUpdatedObjects().size() > 0){
56 Iterator
<CdmBase
> objects
= result
.getRelatedObjects().iterator();
57 while (objects
.hasNext()){
58 CdmBase object
= objects
.next();
59 if (object
instanceof IdentifiableEntity
){
61 relatedObjects
.add(((IdentifiableEntity
)object
).getTitleCache() );
63 relatedObjects
.add(object
.getUserFriendlyTypeName());
68 for (String relatedObject
: relatedObjects
){
70 relatedObjectsString
.append(relatedObject
);
71 relatedObjectsString
.append(System
.lineSeparator());
74 message
= message
+ "\n" ;
75 String stackTraceWithContext
= getContextInfo(details
);
76 CdmDeleteErrorDialog ced
= new CdmDeleteErrorDialog(AbstractUtility
.getShell(), title
, message
,new Status(IStatus
.INFO
, pluginId
, relatedObjectsString
.toString(), result
.getExceptions().iterator().next()), stackTraceWithContext
, result
.getUpdatedObjects().toArray());