performed javacscript:fix and worked on documentation
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / operations / SwapSynonymAndAcceptedOperation.java
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 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.SynonymRelationshipType;
21 import eu.etaxonomy.cdm.model.taxon.Taxon;
22 import eu.etaxonomy.taxeditor.store.CdmStore;
23 import eu.etaxonomy.taxeditor.store.StoreUtil;
24
25 /**
26 * <p>SwapSynonymAndAcceptedOperation class.</p>
27 *
28 * @author n.hoffmann
29 * @created 23.04.2009
30 * @version 1.0
31 */
32 public class SwapSynonymAndAcceptedOperation extends AbstractPostOperation {
33
34 private Synonym synonym;
35 // TODO store the old relationship for undo reasons
36 private SynonymRelationshipType synonymRelationshipType;
37
38 /**
39 * <p>Constructor for SwapSynonymAndAcceptedOperation.</p>
40 *
41 * @param label a {@link java.lang.String} object.
42 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
43 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
44 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operations.IPostOperationEnabled} object.
45 * @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
46 */
47 public SwapSynonymAndAcceptedOperation(String label, IUndoContext undoContext,
48 Taxon taxon, Synonym synonym, IPostOperationEnabled postOperationEnabled) {
49 super("Swap Synonym And Accepted Taxon Operation", undoContext, taxon, postOperationEnabled);
50
51 this.synonym = synonym;
52 }
53
54 /* (non-Javadoc)
55 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
56 */
57 /** {@inheritDoc} */
58 @Override
59 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
60 throws ExecutionException {
61
62 monitor.worked(20);
63
64 CdmStore.getTaxonService().swapSynonymAndAcceptedTaxon(synonym, taxon);
65
66 monitor.worked(40);
67
68 return postExecute(taxon);
69 }
70
71 /* (non-Javadoc)
72 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
73 */
74 /** {@inheritDoc} */
75 @Override
76 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
77 throws ExecutionException {
78 // TODO Auto-generated method stub
79 return execute(monitor, info);
80 }
81
82 /* (non-Javadoc)
83 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
84 */
85 /** {@inheritDoc} */
86 @Override
87 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
88 throws ExecutionException {
89 StoreUtil.error(this.getClass(), "Not yet implemented", null);
90 return null;
91 }
92 }