package eu.etaxonomy.taxeditor.model;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IStatus;
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;
/**
* @author k.luther
List<String> details = new ArrayList<String>();
String title= "";
- if (result.isOk() && result.getExceptions().size() > 0){
+ if (result.getExceptions().size() > 0){
for (Exception e:result.getExceptions()){
details.add(e.getMessage());
}
- title = "The delete was successfull.";
+ if (result.isOk()){
+ title = "Delete was successfull.";
+ } else {
+ title = "Delete was aborted.";
+ }
+ }
+ StringBuffer relatedObjectsString = new StringBuffer();
+ List<String> relatedObjects = new ArrayList<String>();
+ if (result.getUpdatedObjects().size() > 0){
+ Iterator<CdmBase> objects = result.getRelatedObjects().iterator();
+ while (objects.hasNext()){
+ CdmBase object = objects.next();
+ if (object instanceof IdentifiableEntity){
+ relatedObjects.add("[" + object.getClass().getSimpleName() + "] " +((IdentifiableEntity)object).getTitleCache() );
+ } else{
+ relatedObjects.add(object.getUserFriendlyTypeName());
+ }
+
+ }
+
+ for (String relatedObject: relatedObjects){
+
+ relatedObjectsString.append(relatedObject);
+ relatedObjectsString.append(System.lineSeparator());
+ }
}
+ message = message + "\n" ;
String stackTraceWithContext = getContextInfo(details);
- CdmErrorDialog ced = new CdmErrorDialog(AbstractUtility.getShell(), title, message, new Status(IStatus.ERROR, pluginId, null), stackTraceWithContext);
+ CdmDeleteErrorDialog ced = new CdmDeleteErrorDialog(AbstractUtility.getShell(), title, message,new Status(IStatus.INFO, pluginId, relatedObjectsString.toString(), result.getExceptions().iterator().next()), stackTraceWithContext, result.getUpdatedObjects().toArray());
+
ced.open();