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
.commands
.ExecutionException
;
14 import org
.eclipse
.core
.commands
.operations
.AbstractOperation
;
15 import org
.eclipse
.core
.commands
.operations
.IOperationHistory
;
16 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
17 import org
.eclipse
.core
.commands
.operations
.IUndoableOperation
;
18 import org
.eclipse
.core
.runtime
.IAdaptable
;
19 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
20 import org
.eclipse
.core
.runtime
.IStatus
;
21 import org
.eclipse
.core
.runtime
.Status
;
22 import org
.eclipse
.jface
.action
.Action
;
23 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
24 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
25 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
27 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
28 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
29 import eu
.etaxonomy
.taxeditor
.ITaxEditorConstants
;
30 import eu
.etaxonomy
.taxeditor
.TaxEditorPlugin
;
31 import eu
.etaxonomy
.taxeditor
.UiUtil
;
32 import eu
.etaxonomy
.taxeditor
.actions
.cdm
.DeleteSynonymFromTaxonAction
;
33 import eu
.etaxonomy
.taxeditor
.editor
.name
.NameComposite
;
40 public class DeleteSynonymCompositeAction
extends Action
{
41 private static final Logger logger
= Logger
42 .getLogger(DeleteSynonymCompositeAction
.class);
44 private static String text
= "Delete synonym from taxon";
45 private ImageDescriptor image
= TaxEditorPlugin
.getDefault()
46 .getImageDescriptor(ITaxEditorConstants
.ACTIVE_DELETE_ICON
);
48 private Synonym synonym
;
51 private NameComposite composite
;
52 private IUndoableOperation operation
;
54 private DeleteSynonymCompositeAction() {
56 setImageDescriptor(image
);
59 public DeleteSynonymCompositeAction(NameComposite composite
, Taxon taxon
) {
62 if (composite
.getData() instanceof Synonym
) {
63 this.synonym
= (Synonym
) composite
.getData();
65 throw new IllegalArgumentException(
66 "This action requires a composite with a Synonym in its data field.");
70 this.composite
= composite
;
72 operation
= new DeleteSynonymOperation();
76 IOperationHistory operationHistory
= UiUtil
.getOperationHistory();
77 IUndoContext undoContext
= UiUtil
.getWorkbenchUndoContext();
78 operation
.addContext(undoContext
);
80 operationHistory
.execute(operation
, null, null);
81 operationHistory
.add(operation
);
82 } catch (ExecutionException e
) {
87 class DeleteSynonymOperation
extends AbstractOperation
{
89 public DeleteSynonymOperation() {
90 super("'" + text
+ "'");
94 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
95 throws ExecutionException
{
96 // Delete synonym from taxon
97 Action action
= new DeleteSynonymFromTaxonAction(synonym
, taxon
);
98 action
.addPropertyChangeListener(new IPropertyChangeListener() {
99 public void propertyChange(PropertyChangeEvent event
) {
100 if (event
.getProperty().equals(
101 ITaxEditorConstants
.SYNONYM
)) {
102 // Delete namecomposite
109 return Status
.OK_STATUS
;
113 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
114 throws ExecutionException
{
115 // TODO Auto-generated method stub
116 return Status
.OK_STATUS
;
120 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
121 throws ExecutionException
{
122 // TODO Auto-generated method stub
123 return Status
.OK_STATUS
;