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
;
16 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
17 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
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 import eu
.etaxonomy
.taxeditor
.datasource
.CdmDataSourceRepository
;
23 import eu
.etaxonomy
.taxeditor
.model
.CdmSessionDataRepository
;
24 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
27 * Opens a name editor for a new, uninitialized taxon.
34 public class OpenNewTaxonEditorAction
extends Action
{
35 private static final Logger logger
= Logger
36 .getLogger(OpenNewTaxonEditorAction
.class);
38 private static String textRootTaxon
= "Add root taxon";
39 private static String textChildTaxon
= "Add child taxon";
40 private ImageDescriptor imageChildTaxon
= TaxEditorPlugin
.getDefault()
41 .getImageDescriptor(ITaxEditorConstants
.ADD_CHILD_TAXON_ICON
);
44 private Taxon parentTaxon
= null;
45 public static final String ID
= "eu.etaxonomy.taxeditor.actions.opennameeditoraction"; //$NON-NLS-1$
47 public OpenNewTaxonEditorAction() {
53 public OpenNewTaxonEditorAction(Taxon parentTaxon
) {
56 setText(textChildTaxon
);
57 setImageDescriptor(imageChildTaxon
);
59 this.parentTaxon
= parentTaxon
;
65 NonViralName name
= PreferencesUtil
.getInstanceOfPreferredNameClass();
66 taxon
= Taxon
.NewInstance(name
, null);
68 if (parentTaxon
== null) {
69 taxon
= Taxon
.NewInstance(name
,
70 CdmSessionDataRepository
.getDefault().getDefaultSec());
72 taxon
= Taxon
.NewInstance(name
,
73 parentTaxon
.getSec());
74 parentTaxon
.addTaxonomicChild(taxon
, null, null);
77 // Open editor for new taxon
78 EditorController
.openUnitializedChildTaxon(taxon
);
80 //new OpenTaxonEditorAction(taxon).run();