a5be758f32d1b10535563aba6671a9e573a9f6d7
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / actions / ui / OpenTaxonEditorAction.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.ui;
11
12 import org.apache.log4j.Logger;
13 import org.eclipse.jface.action.Action;
14 import org.eclipse.jface.resource.ImageDescriptor;
15 import org.eclipse.ui.IWorkbenchWindow;
16 import org.eclipse.ui.actions.ActionFactory;
17
18 import eu.etaxonomy.cdm.model.taxon.Taxon;
19 import eu.etaxonomy.taxeditor.ITaxEditorConstants;
20 import eu.etaxonomy.taxeditor.TaxEditorPlugin;
21 import eu.etaxonomy.taxeditor.controller.EditorController;
22
23 /**
24 * Opens a taxon editor for an existing taxon.
25 *
26 * FIXME this action is broken and actually throws lots of hibernate exceptions
27 *
28 * @author p.ciardelli
29 * @created 02.06.2008
30 * @version 1.0
31 * @deprecated
32 */
33 public class OpenTaxonEditorAction extends Action implements ActionFactory.IWorkbenchAction {
34 private static final Logger logger = Logger
35 .getLogger(OpenTaxonEditorAction.class);
36
37 private static String editTaxonText = "Edit taxon";
38 private static String newTaxonText = "Add new taxon";
39 private ImageDescriptor image = TaxEditorPlugin.getDefault()
40 .getImageDescriptor(ITaxEditorConstants.OPEN_TAXON_ICON);
41
42 private IWorkbenchWindow window;
43
44 private Taxon taxon;
45 public static final String ID = "eu.etaxonomy.taxeditor.actions.opennameeditoraction"; //$NON-NLS-1$
46
47 @Deprecated
48 public OpenTaxonEditorAction(Taxon taxon) {
49 this();
50
51 this.taxon = taxon;
52 if (taxon != null) {
53 setText(editTaxonText);
54 }
55 }
56
57 @Deprecated
58 public OpenTaxonEditorAction() {
59 super(newTaxonText);
60 setImageDescriptor(image);
61 setId(ID);
62 }
63
64 @Override
65 public void run() {
66
67 EditorController.open(taxon);
68
69 // For clients who re-use the same instance of this class,
70 // taxon is re-initalized to ensure a new Taxon is opened every time
71 taxon = null;
72 }
73
74 public void dispose() {
75 }
76 }