Project

General

Profile

Download (2.91 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.operations;
11

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

    
18
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
19
import eu.etaxonomy.cdm.model.taxon.Taxon;
20
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
21

    
22
/**
23
 * <p>ChangeHomotypicalGroupBasionymOperation class.</p>
24
 *
25
 * @author p.ciardelli
26
 * @created 15.01.2009
27
 * @version 1.0
28
 */
29
public class ChangeHomotypicalGroupBasionymOperation extends
30
		AbstractPostOperation {
31
	private TaxonBase taxonBase;
32

    
33
	/**
34
	 * <p>Constructor for ChangeHomotypicalGroupBasionymOperation.</p>
35
	 *
36
	 * @param text a {@link java.lang.String} object.
37
	 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
38
	 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
39
	 * @param taxonBase a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
40
	 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operations.IPostOperationEnabled} object.
41
	 */
42
	public ChangeHomotypicalGroupBasionymOperation(String text,
43
			IUndoContext undoContext, Taxon taxon, TaxonBase taxonBase, IPostOperationEnabled postOperationEnabled) {
44
		super(text, undoContext, taxon, postOperationEnabled);
45
		
46
		this.taxonBase = taxonBase;
47
	}
48

    
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
51
	 */
52
	/** {@inheritDoc} */
53
	@Override
54
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
55
			throws ExecutionException {
56
		
57
		TaxonNameBase<?, ?> name = taxonBase.getName();
58
		monitor.worked(20);
59
        
60
		name.setAsGroupsBasionym();
61
		monitor.worked(40);
62

    
63
		return postExecute(taxonBase);
64
	}
65

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

    
76
	/* (non-Javadoc)
77
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
78
	 */
79
	/** {@inheritDoc} */
80
	@Override
81
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
82
			throws ExecutionException {
83
		// TODO replace w method from cdmlib
84
		// FIXME this is also old code: reimplement
85
//		CdmUtil.setGroupBasionym(synonym.getName());
86
				
87
		return postExecute(taxonBase);
88
	}
89
}
(9-9/40)