fix delete of classifications
authorKatja Luther <k.luther@bgbm.org>
Wed, 6 Nov 2013 09:25:30 +0000 (09:25 +0000)
committerKatja Luther <k.luther@bgbm.org>
Wed, 6 Nov 2013 09:25:30 +0000 (09:25 +0000)
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java

index 06daa8920e571cfb9d25aa21126c3101a93201dc..ef3965ce6c127625fd34f6839cd151e9d7192422 100644 (file)
@@ -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<ITreeNode> treeNodes = new HashSet<ITreeNode>();
+               Set<ITaxonTreeNode> treeNodes = new HashSet<ITaxonTreeNode>();
 
                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);
+                                               }
                                }
        
                
index 9968fa9cd6d7359e8314873dccc0e1f35f0068e9..5e57bd87396dcc7ed940113175f94aef355599e7 100644 (file)
@@ -44,7 +44,7 @@ import eu.etaxonomy.taxeditor.store.StoreUtil;
  */
 public class DeleteOperation extends AbstractPersistentPostOperation{
 
-       private Set<ITreeNode> treeNodes;
+       private Set<ITaxonTreeNode> 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<ITreeNode> treeNodes, TaxonDeletionConfigurator config,
+                       Set<ITaxonTreeNode> treeNodes, TaxonDeletionConfigurator config,
                        IPostOperationEnabled postOperationEnabled,
                        IConversationEnabled conversationEnabled) {
                super(label, undoContext, postOperationEnabled, conversationEnabled);
index 6d35611cf604060fcdf31d8cee38519404c5c4b7..eca9d8369f5d9301f3240f36af940436ec546a87 100644 (file)
@@ -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;