2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.editor
.name
.operation
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
16 import org
.eclipse
.core
.runtime
.IAdaptable
;
17 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
18 import org
.eclipse
.core
.runtime
.IStatus
;
20 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
21 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
22 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
25 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
26 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
29 * <p>ChangeHomotypicalGroupBasionymOperation class.</p>
35 public class ChangeHomotypicalGroupBasionymOperation
extends
36 AbstractPostTaxonOperation
{
37 private final TaxonBase taxonBase
;
40 * <p>Constructor for ChangeHomotypicalGroupBasionymOperation.</p>
42 * @param text a {@link java.lang.String} object.
43 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
44 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
45 * @param taxonBase a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
46 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
48 public ChangeHomotypicalGroupBasionymOperation(String text
,
49 IUndoContext undoContext
, Taxon taxon
, TaxonBase taxonBase
, IPostOperationEnabled postOperationEnabled
) {
50 super(text
, undoContext
, taxon
, postOperationEnabled
);
52 this.taxonBase
= taxonBase
;
56 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
60 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
61 throws ExecutionException
{
63 TaxonNameBase
<?
, ?
> name
= taxonBase
.getName();
66 name
= HibernateProxyHelper
.deproxy(name
, TaxonNameBase
.class);
67 HomotypicalGroup group
= HibernateProxyHelper
.deproxy(name
.getHomotypicalGroup(), HomotypicalGroup
.class);
68 TaxonNameBase oldBasionym
= name
.getBasionym();
70 name
.setAsGroupsBasionym();
73 oldBasionym
= HibernateProxyHelper
.deproxy(oldBasionym
, TaxonNameBase
.class);
74 if (oldBasionym
!= null){
75 Set
<TaxonBase
> taxonBases
= oldBasionym
.getTaxonBases();
76 if (!taxonBases
.isEmpty()){
77 TaxonBase oldBasionymTaxonBase
= taxonBases
.iterator().next();
78 postExecute(oldBasionymTaxonBase
);
82 return postExecute(taxonBase
);
86 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
90 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
91 throws ExecutionException
{
92 return execute(monitor
, info
);
96 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
100 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
101 throws ExecutionException
{
102 // TODO replace w method from cdmlib
103 // FIXME this is also old code: reimplement
104 // CdmUtil.setGroupBasionym(synonym.getName());
106 return postExecute(taxonBase
);