1 package eu
.etaxonomy
.taxeditor
.prototype2
.controller
;
3 import org
.eclipse
.jface
.action
.Action
;
4 import org
.eclipse
.ui
.PlatformUI
;
6 import eu
.etaxonomy
.cdm
.model
.name
.BotanicalName
;
7 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
8 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
9 import eu
.etaxonomy
.taxeditor
.prototype2
.Activator
;
10 import eu
.etaxonomy
.taxeditor
.prototype2
.view
.NameListView
;
11 import eu
.etaxonomy
.taxeditor
.prototype2
.view
.TaxonomicTreeViewer
;
14 * Open up a celleditor in the taxonomic tree
15 * to add a quickname to taxon
20 public class ActionAddQuickName
extends Action
{
23 public ActionAddQuickName(Taxon parentTaxon
) {
24 this.parentTaxon
= parentTaxon
;
29 // Create empty Taxon, add it to its parent
30 Taxon childTaxon
= new Taxon();
31 childTaxon
.setName(new BotanicalName(Rank
.GENUS()));
33 // TODO getTitleCache is currently returning "null", not null
34 // hence its being set here - change!
35 childTaxon
.getName().setTitleCache(null);
36 parentTaxon
.addTaxonomicChild(childTaxon
, null, null);
38 // Add childTaxon to observable tree list,
39 // causing it to appear in the tree
40 Activator
.getDefault().getObservableTaxonTreeList().add(childTaxon
);
43 TaxonomicTreeViewer treeViewer
= (TaxonomicTreeViewer
) ((NameListView
) PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage().
44 findView(NameListView
.ID
)).getTreeViewer();
45 treeViewer
.revealTaxon(childTaxon
);
47 // Put cursor in empty node
48 treeViewer
.editElement(childTaxon
, 0);