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
.actions
.ui
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.core
.runtime
.IStatus
;
14 import org
.eclipse
.core
.runtime
.Status
;
15 import org
.eclipse
.jface
.action
.Action
;
16 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
17 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
18 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
22 import eu
.etaxonomy
.taxeditor
.ITaxEditorConstants
;
23 import eu
.etaxonomy
.taxeditor
.TaxEditorPlugin
;
24 import eu
.etaxonomy
.taxeditor
.actions
.UndoableAction
;
25 import eu
.etaxonomy
.taxeditor
.actions
.cdm
.ChangeSynonymToTaxonAction
;
26 import eu
.etaxonomy
.taxeditor
.actions
.cdm
.SaveTaxonAction
;
27 import eu
.etaxonomy
.taxeditor
.editor
.name
.NameComposite
;
35 * TODO seems like this is not beeing used at the moment
37 public class ChangeCompositeToNewTaxonAction
extends UndoableAction
{
38 private static final Logger logger
= Logger
39 .getLogger(ChangeCompositeToNewTaxonAction
.class);
41 private static String text
= "Use synonym name to make a new taxon";
42 private static ImageDescriptor image
= TaxEditorPlugin
.getDefault()
43 .getImageDescriptor(ITaxEditorConstants
.SYNONYM_TO_TAXON_ICON
);
45 private NameComposite composite
;
47 private Synonym synonym
;
49 public ChangeCompositeToNewTaxonAction(NameComposite composite
,
53 this.composite
= composite
;
56 if (composite
.getData() instanceof Synonym
) {
57 this.synonym
= (Synonym
) composite
.getData();
59 throw new IllegalArgumentException(
60 "This action requires a composite with a Synonym in its data field.");
66 * @see eu.etaxonomy.taxeditor.actions.UndoableAction#executeOperation()
69 protected IStatus
executeOperation() {
70 Action action
= new ChangeSynonymToTaxonAction(synonym
);
71 action
.addPropertyChangeListener(new IPropertyChangeListener() {
72 public void propertyChange(PropertyChangeEvent event
) {
73 if (event
.getProperty().equals(ITaxEditorConstants
.TAXON
)) {
74 if (event
.getNewValue() instanceof Taxon
) {
76 // Delete synonym composite in old taxon
79 Taxon newTaxon
= (Taxon
) event
.getNewValue();
80 // TaxEditorPlugin.getDefault().addSessionTaxon(newTaxon);
82 new OpenTaxonEditorAction(newTaxon
).run();
83 // new SaveTaxonAction(newTaxon).run();
89 return Status
.OK_STATUS
;
93 * @see eu.etaxonomy.taxeditor.actions.UndoableAction#redoOperation()
96 protected IStatus
redoOperation() {
97 // TODO Auto-generated method stub
102 * @see eu.etaxonomy.taxeditor.actions.UndoableAction#undoOperation()
105 protected IStatus
undoOperation() {
106 // TODO Auto-generated method stub