Project

General

Profile

Download (3.27 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.editor.name.operation;
12

    
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.api.service.ITaxonService;
20
import eu.etaxonomy.cdm.model.taxon.Synonym;
21
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
22
import eu.etaxonomy.cdm.model.taxon.Taxon;
23
import eu.etaxonomy.taxeditor.model.MessagingUtils;
24
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
25
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
26
import eu.etaxonomy.taxeditor.store.CdmStore;
27

    
28
/**
29
 * <p>SwapSynonymAndAcceptedOperation class.</p>
30
 *
31
 * @author n.hoffmann
32
 * @created 23.04.2009
33
 * @version 1.0
34
 */
35
public class SwapSynonymAndAcceptedOperation extends AbstractPostTaxonOperation {
36

    
37
	private final Synonym synonym;
38
	// TODO store the old relationship for undo reasons
39
	private SynonymRelationshipType synonymRelationshipType;
40

    
41
	/**
42
	 * <p>Constructor for SwapSynonymAndAcceptedOperation.</p>
43
	 *
44
	 * @param label a {@link java.lang.String} object.
45
	 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
46
	 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
47
	 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
48
	 * @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
49
	 */
50
	public SwapSynonymAndAcceptedOperation(String label, IUndoContext undoContext,
51
			Taxon taxon, Synonym synonym, IPostOperationEnabled postOperationEnabled) {
52
		super("Swap Synonym And Accepted Taxon Operation", undoContext, taxon, postOperationEnabled);
53

    
54
		this.synonym = synonym;
55
	}
56

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

    
65
		monitor.worked(20);
66

    
67
		CdmStore.getService(ITaxonService.class).swapSynonymAndAcceptedTaxon(synonym, element);
68

    
69
		monitor.worked(40);
70

    
71
		return postExecute(element);
72
	}
73

    
74
	/* (non-Javadoc)
75
	 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
76
	 */
77
	/** {@inheritDoc} */
78
	@Override
79
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
80
			throws ExecutionException {
81
		// TODO Auto-generated method stub
82
		return execute(monitor, info);
83
	}
84

    
85
	/* (non-Javadoc)
86
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
87
	 */
88
	/** {@inheritDoc} */
89
	@Override
90
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
91
			throws ExecutionException {
92
		MessagingUtils.error(this.getClass(), "Not yet implemented", null);
93
		return null;
94
	}
95
}
(19-19/19)