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
.jface
.action
.Action
;
14 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
15 import org
.eclipse
.ui
.PartInitException
;
17 import eu
.etaxonomy
.cdm
.model
.name
.BotanicalName
;
18 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
19 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
20 import eu
.etaxonomy
.cdm
.model
.name
.ZoologicalName
;
21 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
23 import eu
.etaxonomy
.taxeditor
.ITaxEditorConstants
;
24 import eu
.etaxonomy
.taxeditor
.TaxEditorPlugin
;
25 import eu
.etaxonomy
.taxeditor
.UiUtil
;
26 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
29 * Opens a name editor for a new taxon with a parent taxon
35 public class OpenNewChildNameEditorAction
extends Action
{
36 private static final Logger logger
= Logger
37 .getLogger(OpenNewChildNameEditorAction
.class);
39 private static String text
= "Add child taxon";
40 private ImageDescriptor image
= TaxEditorPlugin
.getDefault()
41 .getImageDescriptor(ITaxEditorConstants
.ADD_CHILD_TAXON_ICON
);
44 private Taxon parentTaxon
;
45 public static final String ID
= "eu.etaxonomy.taxeditor.actions.opennameeditoraction"; //$NON-NLS-1$
47 private OpenNewChildNameEditorAction() {
49 setImageDescriptor(image
);
53 public OpenNewChildNameEditorAction(Taxon parentTaxon
) {
56 this.parentTaxon
= parentTaxon
;
61 NonViralName name
= PreferencesUtil
.getInstanceOfPreferredNameClass();
62 ReferenceBase sec
= parentTaxon
.getSec();
63 taxon
= Taxon
.NewInstance(name
, sec
);
65 parentTaxon
.addTaxonomicChild(taxon
, null, null);
67 // Open editor for new taxon
69 UiUtil
.openTaxonEditor(taxon
);
70 } catch (PartInitException e
) {
74 //new OpenTaxonEditorAction(taxon).run();