Massive refactoring of the methodology in former class UiUtils
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / actions / cdm / DeleteTaxonAction.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.actions.cdm;
11
12 /**
13 * @author p.ciardelli
14 * @created 14.05.2008
15 * @version 1.0
16 */
17 import org.apache.log4j.Logger;
18 import org.eclipse.core.commands.ExecutionException;
19 import org.eclipse.core.commands.operations.IOperationHistory;
20 import org.eclipse.core.commands.operations.IUndoContext;
21 import org.eclipse.core.commands.operations.IUndoableOperation;
22 import org.eclipse.core.runtime.IProgressMonitor;
23 import org.eclipse.core.runtime.IStatus;
24 import org.eclipse.jface.action.Action;
25 import org.eclipse.jface.resource.ImageDescriptor;
26
27 import eu.etaxonomy.cdm.model.taxon.Taxon;
28 import eu.etaxonomy.taxeditor.ITaxEditorConstants;
29 import eu.etaxonomy.taxeditor.TaxEditorPlugin;
30 import eu.etaxonomy.taxeditor.controller.GlobalController;
31 import eu.etaxonomy.taxeditor.operations.DeleteTaxonOperation;
32
33 /**
34 * Delete this taxon from the CDM
35 *
36 * @author p.ciardelli
37 *
38 */
39 public class DeleteTaxonAction extends Action {
40 private static final Logger logger = Logger
41 .getLogger(DeleteTaxonAction.class);
42
43 private static String text = "Delete taxon from tree";
44 private ImageDescriptor image = TaxEditorPlugin.getDefault()
45 .getImageDescriptor(ITaxEditorConstants.ACTIVE_DELETE_ICON);
46
47 private IUndoContext undoContext;
48
49 Taxon taxon;
50
51 public DeleteTaxonAction() {
52 super(text);
53 setImageDescriptor(image);
54
55 undoContext = GlobalController.getWorkbenchUndoContext();
56 }
57
58 public DeleteTaxonAction(Taxon taxon) {
59 this();
60
61 this.taxon = taxon;
62 }
63
64 public void run() {
65 IUndoableOperation operation = new DeleteTaxonOperation
66 (this.getText(), undoContext, taxon);
67
68 GlobalController.executeOperation(operation);
69 }
70 }