From: Katja Luther Date: Wed, 6 Nov 2013 09:25:30 +0000 (+0000) Subject: fix delete of classifications X-Git-Tag: 3.6.0~887 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/531fbc7c55d6459eca9906d9bca751fb10cd0ee2 fix delete of classifications --- diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java index 06daa8920..ef3965ce6 100644 --- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java +++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java @@ -29,6 +29,7 @@ import org.eclipse.ui.handlers.HandlerUtil; import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator; import eu.etaxonomy.cdm.model.common.ITreeNode; +import eu.etaxonomy.cdm.model.taxon.Classification; import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; import eu.etaxonomy.cdm.model.taxon.TaxonNode; import eu.etaxonomy.taxeditor.editor.TaxonEditorInput; @@ -66,16 +67,16 @@ public class DeleteHandler extends AbstractHandler implements IHandler{ } Iterator selectionIterator = selection.iterator(); - Set treeNodes = new HashSet(); + Set treeNodes = new HashSet(); while (selectionIterator.hasNext()){ Object object = selectionIterator.next(); - if(object instanceof ITreeNode) { - treeNodes.add((ITreeNode) object); + if(object instanceof ITaxonTreeNode) { + treeNodes.add((ITaxonTreeNode) object); } } boolean allEditorsClosed = true; - for (ITreeNode treeNode : treeNodes){ + for (ITaxonTreeNode treeNode : treeNodes){ if(treeNode instanceof TaxonNode) { allEditorsClosed &= closeObsoleteEditor((TaxonNode) treeNode); } @@ -86,12 +87,21 @@ public class DeleteHandler extends AbstractHandler implements IHandler{ if (allEditorsClosed){ - TaxonNode taxonNode = (TaxonNode)treeNodes.iterator().next(); - operation = new DeleteOperation( - event.getCommand().getName(), NavigationUtil.getUndoContext(), - taxonNode, new TaxonDeletionConfigurator(), taxonNavigator, taxonNavigator); - - NavigationUtil.executeOperation(operation); + ITaxonTreeNode treeNode = treeNodes.iterator().next(); + if (treeNode instanceof Classification){ + operation = new DeleteOperation( + event.getCommand().getName(), NavigationUtil.getUndoContext(), + treeNodes, new TaxonDeletionConfigurator(), taxonNavigator, taxonNavigator); + + NavigationUtil.executeOperation(operation); + }else { + TaxonNode taxonNode = (TaxonNode)treeNode; + operation = new DeleteOperation( + event.getCommand().getName(), NavigationUtil.getUndoContext(), + taxonNode, new TaxonDeletionConfigurator(), taxonNavigator, taxonNavigator); + + NavigationUtil.executeOperation(operation); + } } diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java index 9968fa9cd..5e57bd873 100644 --- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java +++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java @@ -44,7 +44,7 @@ import eu.etaxonomy.taxeditor.store.StoreUtil; */ public class DeleteOperation extends AbstractPersistentPostOperation{ - private Set treeNodes; + private Set treeNodes; private TaxonDeletionConfigurator config; @@ -58,7 +58,7 @@ public class DeleteOperation extends AbstractPersistentPostOperation{ * @param treeNodes a {@link java.util.Set} object. */ public DeleteOperation(String label, IUndoContext undoContext, - ITreeNode taxonNode, TaxonDeletionConfigurator config, + ITaxonTreeNode taxonNode, TaxonDeletionConfigurator config, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) { super(label, undoContext, postOperationEnabled, conversationEnabled); @@ -76,7 +76,7 @@ public class DeleteOperation extends AbstractPersistentPostOperation{ * @param treeNodes a {@link java.util.Set} object. */ public DeleteOperation(String label, IUndoContext undoContext, - Set treeNodes, TaxonDeletionConfigurator config, + Set treeNodes, TaxonDeletionConfigurator config, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) { super(label, undoContext, postOperationEnabled, conversationEnabled); diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java index 6d35611cf..eca9d8369 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java @@ -18,6 +18,7 @@ import org.eclipse.core.runtime.Status; import eu.etaxonomy.cdm.model.common.CdmBase; import eu.etaxonomy.cdm.model.common.ITreeNode; +import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.cdm.model.taxon.TaxonNode; @@ -44,7 +45,7 @@ public abstract class AbstractPostOperation extends AbstractOperation { /** * A reference to the taxons TaxonNode */ - protected ITreeNode taxonNode; + protected ITaxonTreeNode taxonNode; protected UUID parentNodeUuid;