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
.navigation
.navigator
.e4
.handler
;
12 import javax
.inject
.Named
;
14 import org
.eclipse
.core
.runtime
.IStatus
;
15 import org
.eclipse
.e4
.core
.di
.annotations
.CanExecute
;
16 import org
.eclipse
.e4
.ui
.services
.IServiceConstants
;
17 import org
.eclipse
.jface
.viewers
.TreeSelection
;
18 import org
.eclipse
.jface
.wizard
.WizardDialog
;
19 import org
.eclipse
.swt
.widgets
.Shell
;
21 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
22 import eu
.etaxonomy
.taxeditor
.newWizard
.IWizardPageListener
;
23 import eu
.etaxonomy
.taxeditor
.newWizard
.NewTaxonNodeWizard
;
31 public class NewTaxonNodeHandlerE4
{
33 public void execute(@Named(IServiceConstants
.ACTIVE_SHELL
)Shell shell
) throws Exception
{
35 final NewTaxonNodeWizard wizard
= new NewTaxonNodeWizard();
36 wizard
.init(null, null);
37 final WizardDialog dialog
= new WizardDialog(shell
, wizard
);
38 wizard
.addWizardPageListener(new IWizardPageListener() {
41 wizard
.performFinish();
45 int status
= dialog
.open();
47 if(status
== IStatus
.OK
&& wizard
.openInEditor()){
48 if(wizard
.openEmpty()){
49 EditorUtil
.openEmptyE4(wizard
.getParentTreeNode().getUuid());
50 }else if(wizard
.getTaxonNode() != null){
51 EditorUtil
.openTaxonNodeE4(wizard
.getTaxonNode().getUuid());
57 private boolean canExecute(@Named(IServiceConstants
.ACTIVE_SELECTION
)TreeSelection selection
){
58 return selection
!=null && !selection
.isEmpty();