}
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
- */
- /** {@inheritDoc} */
- @Override
- public IStatus execute(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
-
- bind();
- monitor.worked(20);
- ICdmApplicationConfiguration controller = CdmStore.getCurrentApplicationConfiguration();
- ITaxonNodeService service = controller.getTaxonNodeService();
- DeleteResult result;
-
- if(taxonNode != null && taxonNode instanceof TaxonNode) {
- element = ((TaxonNode)taxonNode).getTaxon();
-
- result = service.deleteTaxonNode(taxonNode.getUuid(), config);
- if (result.isError() || result.isAbort()){
- MessageDialog.openError(null, "Delete failed", result.getExceptions().get(0).getMessage());
- }
-
- } else if(taxonNode != null && taxonNode instanceof Classification) {
- Classification taxonomicTree = (Classification) taxonNode;
- /*if(taxonomicTree.hasChildNodes()){
- if(! MessageDialog.openConfirm(null, "Confirm Deletion", "The selected tree has children, do yu realy want to delete the whole tree with its children?")){
- return null;
- }
- }*/
-
- result = CdmStore.getService(IClassificationService.class).delete(taxonomicTree.getUuid());
- if (result.isError() || result.isAbort()){
- MessageDialog.openError(null, "Delete failed", result.getExceptions().get(0).getMessage());
- }
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+
+ bind();
+ monitor.worked(20);
+ ICdmApplicationConfiguration controller = CdmStore.getCurrentApplicationConfiguration();
+ ITaxonNodeService service = controller.getTaxonNodeService();
+ if(taxonNode != null && taxonNode instanceof TaxonNode){
+ //((TaxonNode) treeNode).delete();
+
+ element = ((TaxonNode)taxonNode).getTaxon();
+
+ DeleteResult result = service.deleteTaxonNode((TaxonNode)taxonNode, config);
+ if (result.isError() && !result.getExceptions().isEmpty()){
+ //TODO:Error message!
+ MessageDialog.openError(null, "Delete failed", result.getExceptions().iterator().next().getMessage());
+ } else if (!result.getExceptions().isEmpty()){
+ String separator = ", ";
+ String exceptionString = "";
+ for (Exception exception : result.getExceptions()) {
+ exceptionString += exception.getLocalizedMessage()+separator;
+ }
+ MessageDialog.openInformation(null, "Delete of the node was successful but the taxon could not be deleted.", exceptionString);
+ }
+
+
+ }else if(taxonNode != null && taxonNode instanceof Classification){
+ Classification taxonomicTree = (Classification) taxonNode;
+
+ DeleteResult result = CdmStore.getService(IClassificationService.class).delete(taxonomicTree.getUuid());
+ if (result.isError() && !result.getExceptions().isEmpty()){
+ //TODO:Error message!
+ MessageDialog.openError(null, "Delete failed", result.getExceptions().iterator().next().getMessage());
+ }
} else {
Set<UUID> treeNodeUuids = new HashSet<UUID>();
ITaxonTreeNode entity = null;
treeNodeUuids.add(treeNode.getUuid());
}
- result = service.deleteTaxonNodes(treeNodeUuids, config);
- if (result.isError() || result.isAbort()){
- MessageDialog.openError(null, "Delete failed", result.getExceptions().get(0).getMessage());
- }
+ DeleteResult result = service.deleteTaxonNodes(treeNodeUuids, config);
+ if (result.isError() && !result.getExceptions().isEmpty()){
+ //TODO:Error message!
+ MessageDialog.openError(null, "Delete failed", result.getExceptions().iterator().next().getMessage());
+ }
}