merge-update from trunk
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / name / operation / ChangeHomotypicalGroupBasionymOperation.java
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.editor.name.operation;
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 import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
22 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
23
24 /**
25 * <p>ChangeHomotypicalGroupBasionymOperation class.</p>
26 *
27 * @author p.ciardelli
28 * @created 15.01.2009
29 * @version 1.0
30 */
31 public class ChangeHomotypicalGroupBasionymOperation extends
32 AbstractPostTaxonOperation {
33 private TaxonBase taxonBase;
34
35 /**
36 * <p>Constructor for ChangeHomotypicalGroupBasionymOperation.</p>
37 *
38 * @param text a {@link java.lang.String} object.
39 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
40 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
41 * @param taxonBase a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
42 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
43 */
44 public ChangeHomotypicalGroupBasionymOperation(String text,
45 IUndoContext undoContext, Taxon taxon, TaxonBase taxonBase, IPostOperationEnabled postOperationEnabled) {
46 super(text, undoContext, taxon, postOperationEnabled);
47
48 this.taxonBase = taxonBase;
49 }
50
51 /* (non-Javadoc)
52 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
53 */
54 /** {@inheritDoc} */
55 @Override
56 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
57 throws ExecutionException {
58
59 TaxonNameBase<?, ?> name = taxonBase.getName();
60 monitor.worked(20);
61
62 name.setAsGroupsBasionym();
63 monitor.worked(40);
64
65 return postExecute(taxonBase);
66 }
67
68 /* (non-Javadoc)
69 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
70 */
71 /** {@inheritDoc} */
72 @Override
73 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
74 throws ExecutionException {
75 return execute(monitor, info);
76 }
77
78 /* (non-Javadoc)
79 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
80 */
81 /** {@inheritDoc} */
82 @Override
83 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
84 throws ExecutionException {
85 // TODO replace w method from cdmlib
86 // FIXME this is also old code: reimplement
87 // CdmUtil.setGroupBasionym(synonym.getName());
88
89 return postExecute(taxonBase);
90 }
91 }