Project

General

Profile

Download (2.54 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.store.operations;
11

    
12
import org.apache.log4j.Logger;
13
import org.eclipse.core.commands.ExecutionException;
14
import org.eclipse.core.commands.operations.IUndoContext;
15
import org.eclipse.core.runtime.IAdaptable;
16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.IStatus;
18

    
19
import eu.etaxonomy.cdm.model.taxon.Synonym;
20
import eu.etaxonomy.cdm.model.taxon.Taxon;
21

    
22
/**
23
 * @author p.ciardelli
24
 * @created 15.01.2009
25
 * @version 1.0
26
 * @author n.hoffmann
27
 */
28
public class ChangeSynonymToTaxonOperation extends AbstractPostOperation {
29
	private static final Logger logger = Logger
30
			.getLogger(ChangeSynonymToTaxonOperation.class);
31
	private Synonym synonym;
32

    
33
	public ChangeSynonymToTaxonOperation(String text, IUndoContext undoContext,
34
			Taxon taxon, Synonym synonym) {
35
		super(text, undoContext, taxon);
36
		
37
		this.synonym = synonym;
38
	}
39

    
40
	/* (non-Javadoc)
41
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
42
	 */
43
	@Override
44
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
45
			throws ExecutionException {
46

    
47
		// Remove synonym from taxon
48
		taxon.removeSynonym(synonym);
49
		
50
		// Create new taxon with synonym name
51
		Taxon newTaxon = Taxon.NewInstance(synonym.getName(), synonym.getSec());
52
				
53
		// Add new taxon to session data repository
54
		taxon.setTaxonomicParent(null, null, null);
55
		
56
		// Open editor for new taxon
57
		// TODO this will not work. maybe we have to extend the postExecute to allow a parameter (Object?)
58
		//EditorController.open(newTaxon);
59
		
60
		
61
		return postExecute(null);
62
	}
63

    
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
66
	 */
67
	@Override
68
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
69
			throws ExecutionException {
70
		return null;
71
	}
72

    
73
	/* (non-Javadoc)
74
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
75
	 */
76
	@Override
77
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
78
			throws ExecutionException {
79
		return null;
80
	}
81
}
(10-10/28)