Project

General

Profile

Download (3.45 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
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.
9
*/
10

    
11
package eu.etaxonomy.taxeditor.operations;
12

    
13
import java.util.Set;
14

    
15
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.core.commands.operations.IUndoContext;
17
import org.eclipse.core.runtime.IAdaptable;
18
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.core.runtime.IStatus;
20

    
21
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
22
import eu.etaxonomy.cdm.model.taxon.Classification;
23
import eu.etaxonomy.cdm.model.taxon.ITreeNode;
24
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
25
import eu.etaxonomy.taxeditor.store.CdmStore;
26
import eu.etaxonomy.taxeditor.store.StoreUtil;
27

    
28
/**
29
 * <p>DeleteTreeNodeOperation class.</p>
30
 *
31
 * @author n.hoffmann
32
 * @created Jan 20, 2010
33
 * @version 1.0
34
 */
35
public class DeleteTreeNodeOperation extends AbstractPersistentPostOperation{
36
	
37
	private Set<ITreeNode> treeNodes;
38

    
39
	
40
	/**
41
	 * <p>Constructor for DeleteTreeNodeOperation.</p>
42
	 *
43
	 * @param label a {@link java.lang.String} object.
44
	 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
45
	 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operations.IPostOperationEnabled} object.
46
	 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
47
	 * @param treeNodes a {@link java.util.Set} object.
48
	 */
49
	public DeleteTreeNodeOperation(String label, IUndoContext undoContext,
50
			Set<ITreeNode> treeNodes,
51
			IPostOperationEnabled postOperationEnabled,
52
			IConversationEnabled conversationEnabled) {
53
		super(label, undoContext, postOperationEnabled, conversationEnabled);
54
		this.treeNodes = treeNodes;
55
	}
56

    
57
	
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
60
	 */
61
	/** {@inheritDoc} */
62
	@Override
63
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
64
			throws ExecutionException {
65

    
66
		bind();
67
		monitor.worked(20);
68
        for (ITreeNode treeNode : treeNodes){
69
			if(treeNode instanceof TaxonNode){
70
				((TaxonNode) treeNode).delete();
71
			}else if(treeNode instanceof Classification){
72
				Classification taxonomicTree = (Classification) treeNode;
73
				if(taxonomicTree.hasChildNodes()){
74
					StoreUtil.warningDialog("Tree is not empty", this, "It is not possible to delete a Taxonomic Tree that " +
75
							"is not empty. Please delete included taxa first");
76
				}else{
77
					CdmStore.getClassificationService().delete(taxonomicTree);
78
				}
79
			}
80
		}
81
		monitor.worked(40);
82
		return postExecute(null);
83
	}
84

    
85
	/* (non-Javadoc)
86
	 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
87
	 */
88
	/** {@inheritDoc} */
89
	@Override
90
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
91
			throws ExecutionException {
92
		// TODO Auto-generated method stub
93
		return null;
94
	}
95

    
96
	/* (non-Javadoc)
97
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
98
	 */
99
	/** {@inheritDoc} */
100
	@Override
101
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
102
			throws ExecutionException {
103
		// TODO Auto-generated method stub
104
		return null;
105
	}
106
}
(30-30/40)