49550275694f01797b92bca0b490a2c23236abb9
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / operations / 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.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.Synonym;
20 import eu.etaxonomy.cdm.model.taxon.Taxon;
21 import eu.etaxonomy.taxeditor.model.SynonymUtil;
22
23 /**
24 * @author p.ciardelli
25 * @created 15.01.2009
26 * @version 1.0
27 */
28 public class ChangeHomotypicalGroupBasionymOperation extends
29 AbstractPostOperation {
30 private Synonym synonym;
31
32 public ChangeHomotypicalGroupBasionymOperation(String text,
33 IUndoContext undoContext, Taxon taxon, Synonym synonym, IPostOperationEnabled postOperationEnabled) {
34 super(text, undoContext, taxon, postOperationEnabled);
35
36 this.synonym = synonym;
37 }
38
39 /* (non-Javadoc)
40 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
41 */
42 @Override
43 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
44 throws ExecutionException {
45
46 TaxonNameBase<?, ?> oldSynonymName = synonym.getName();
47 // TODO replace w method from cdmlib
48 SynonymUtil.setGroupBasionym(oldSynonymName);
49
50 return postExecute(synonym);
51 }
52
53 /* (non-Javadoc)
54 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
55 */
56 @Override
57 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
58 throws ExecutionException {
59 return execute(monitor, info);
60 }
61
62 /* (non-Javadoc)
63 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
64 */
65 @Override
66 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
67 throws ExecutionException {
68 // TODO replace w method from cdmlib
69 // FIXME this is also old code: reimplement
70 // CdmUtil.setGroupBasionym(synonym.getName());
71
72 return postExecute(synonym);
73 }
74 }