Project

General

Profile

« Previous | Next » 

Revision f6a8dc56

Added by Patrick Plitzner over 10 years ago

merged model adaptions to cdmlib 3.2.4 from campanula branch

View differences:

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/MoveTaxonOperation.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
21 21
import org.eclipse.core.runtime.Status;
22 22

  
23 23
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
24
import eu.etaxonomy.cdm.model.taxon.ITreeNode;
24
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
25 25
import eu.etaxonomy.cdm.model.taxon.IllegalAncestryException;
26 26
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
27 27
import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
......
36 36
 * @version 1.0
37 37
 */
38 38
public class MoveTaxonOperation extends AbstractPersistentPostOperation {
39
	
39

  
40 40
	/**
41 41
	 * A reference to the new taxonomical parent.
42 42
	 */
43
	private ITreeNode newParentTreeNode;
43
	private ITaxonTreeNode newParentTreeNode;
44 44
	/**
45 45
	 * A reference to the former taxonomical parents
46 46
	 */
47
	private Map<TaxonNode, ITreeNode> oldParentTreeNodes;
48
	
47
	private Map<TaxonNode, ITaxonTreeNode> oldParentTreeNodes;
48

  
49 49
	private Set<TaxonNode> taxonNodes;
50 50

  
51 51
	/**
......
54 54
	 * @param label a {@link java.lang.String} object.
55 55
	 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
56 56
	 * @param taxonNodes a {@link java.util.Set} object.
57
	 * @param newParentTreeNode a {@link eu.etaxonomy.cdm.model.taxon.ITreeNode} object.
57
	 * @param newParentTreeNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
58 58
	 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
59 59
	 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
60 60
	 */
61 61
	public MoveTaxonOperation(String label, IUndoContext undoContext,
62
			Set<TaxonNode> taxonNodes, ITreeNode newParentTreeNode, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
62
			Set<TaxonNode> taxonNodes, ITaxonTreeNode newParentTreeNode, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
63 63
		super(label, undoContext, postOperationEnabled, conversationEnabled);
64 64

  
65 65
		this.taxonNodes = taxonNodes;
66
		
66

  
67 67
		this.newParentTreeNode = newParentTreeNode;
68
		
69
		// Save old parent ITreeNodes for undo
70
		oldParentTreeNodes = new HashMap<TaxonNode, ITreeNode>();
68

  
69
		// Save old parent ITaxonTreeNodes for undo
70
		oldParentTreeNodes = new HashMap<TaxonNode, ITaxonTreeNode>();
71 71
		for(TaxonNode taxonNode : taxonNodes){
72 72
			this.oldParentTreeNodes.put(taxonNode, taxonNode.getParent());
73 73
		}
74 74
	}
75
	
75

  
76 76
	/* (non-Javadoc)
77 77
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
78 78
	 */
......
82 82
			throws ExecutionException {
83 83
		bind();
84 84
		monitor.worked(20);
85
		
85

  
86 86
		try {
87 87
			for (TaxonNode taxonNode : taxonNodes){
88
				TaxonNode newTaxonNode = newParentTreeNode.addChildNode(taxonNode, 
88
				TaxonNode newTaxonNode = newParentTreeNode.addChildNode(taxonNode,
89 89
						newParentTreeNode.getReference(), newParentTreeNode.getMicroReference());
90 90
				taxonNodes.add(newTaxonNode);
91 91
				monitor.worked(2);
......
94 94
			StoreUtil.warningDialog("Illegal ancestry", this, e.getMessage());
95 95
		}
96 96
		monitor.worked(40);
97
		
97

  
98 98
		return postExecute(null);
99 99
	}
100 100

  
......
116 116
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
117 117
			throws ExecutionException {
118 118
		StoreUtil.warn(this.getClass(), "Not implemented yet.");
119
		
120
		// iterate over oldParentTreeNodes, delete each TaxonNode from its actual parent and add to its former parent		
121
		
119

  
120
		// iterate over oldParentTreeNodes, delete each TaxonNode from its actual parent and add to its former parent
121

  
122 122
		return Status.OK_STATUS;
123 123
	}
124 124
}

Also available in: Unified diff