Project

General

Profile

Download (1.79 KB) Statistics
| Branch: | Tag: | Revision:
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.navigation.navigator.e4.handler;
11

    
12
import javax.inject.Named;
13

    
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;
20

    
21
import eu.etaxonomy.taxeditor.editor.EditorUtil;
22
import eu.etaxonomy.taxeditor.newWizard.IWizardPageListener;
23
import eu.etaxonomy.taxeditor.newWizard.NewTaxonNodeWizard;
24

    
25
/**
26
 *
27
 * @author pplitzner
28
 * @date 05.09.2017
29
 *
30
 */
31
public class NewTaxonNodeHandlerE4 {
32

    
33
    public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell) throws Exception {
34

    
35
		final NewTaxonNodeWizard wizard = new NewTaxonNodeWizard();
36
		wizard.init(null, null);
37
		final WizardDialog dialog = new WizardDialog(shell, wizard);
38
		wizard.addWizardPageListener(new IWizardPageListener() {
39
		    @Override
40
		    public void close() {
41
		        wizard.performFinish();
42
		        dialog.close();
43
		    }
44
		});
45
		int status = dialog.open();
46

    
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());
52
			}
53
		}
54
	}
55

    
56
    @CanExecute
57
    private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection){
58
        return selection!=null && !selection.isEmpty();
59
    }
60
}
(9-9/11)