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
;
19 import org
.eclipse
.core
.runtime
.Status
;
21 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
22 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
23 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
24 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
26 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
27 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
28 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
31 * <p>ChangeHomotypicalGroupBasionymOperation class.</p>
37 public class ChangeHomotypicalGroupBasionymOperation
extends
38 AbstractPostTaxonOperation
{
39 private TaxonBase taxonBase
;
42 * <p>Constructor for ChangeHomotypicalGroupBasionymOperation.</p>
44 * @param text 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 taxonBase a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
48 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
50 public ChangeHomotypicalGroupBasionymOperation(String text
,
51 IUndoContext undoContext
, Taxon taxon
, TaxonBase taxonBase
, IPostOperationEnabled postOperationEnabled
) {
52 super(text
, undoContext
, taxon
, postOperationEnabled
);
54 this.taxonBase
= taxonBase
;
58 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
62 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
63 throws ExecutionException
{
65 TaxonNameBase
<?
, ?
> name
= taxonBase
.getName();
68 name
= HibernateProxyHelper
.deproxy(name
, TaxonNameBase
.class);
69 HomotypicalGroup group
= HibernateProxyHelper
.deproxy(name
.getHomotypicalGroup(), HomotypicalGroup
.class);
70 TaxonNameBase oldBasionym
= name
.getBasionym();
72 name
.setAsGroupsBasionym();
75 oldBasionym
= HibernateProxyHelper
.deproxy(oldBasionym
, TaxonNameBase
.class);
76 if (oldBasionym
!= null){
77 Set
<TaxonBase
> taxonBases
= oldBasionym
.getTaxonBases();
78 if (!taxonBases
.isEmpty()){
79 TaxonBase oldBasionymTaxonBase
= taxonBases
.iterator().next();
80 postExecute(oldBasionymTaxonBase
);
83 return postExecute(taxonBase
);
87 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
91 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
92 throws ExecutionException
{
93 return execute(monitor
, info
);
97 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
101 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
102 throws ExecutionException
{
103 // TODO replace w method from cdmlib
104 // FIXME this is also old code: reimplement
105 // CdmUtil.setGroupBasionym(synonym.getName());
107 return postExecute(taxonBase
);