Project

General

Profile

Download (1.7 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.navigation.navigator.handler;
2
// $Id$
3
/**
4
* Copyright (C) 2007 EDIT
5
* European Distributed Institute of Taxonomy
6
* http://www.e-taxonomy.eu
7
*
8
* The contents of this file are subject to the Mozilla Public License Version 1.1
9
* See LICENSE.TXT at the top of this package for the full license terms.
10
*/
11

    
12

    
13
import org.eclipse.core.commands.AbstractHandler;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.jface.wizard.WizardDialog;
18
import org.eclipse.ui.handlers.HandlerUtil;
19

    
20
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
21
import eu.etaxonomy.taxeditor.newWizard.IWizardPageListener;
22
import eu.etaxonomy.taxeditor.newWizard.NewTaxonNodeWizard;
23

    
24
/**
25
 * <p>NewTaxonNodeHandler class.</p>
26
 *
27
 * @author n.hoffmann
28
 * @created Sep 15, 2009
29
 * @version 1.0
30
 */
31
public class NewTaxonNodeHandler extends AbstractHandler {
32

    
33
	/** {@inheritDoc} */
34
	@Override
35
    public Object execute(ExecutionEvent event) throws ExecutionException {
36
		final NewTaxonNodeWizard wizard = new NewTaxonNodeWizard();
37
		wizard.init(null, null);
38
		final WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
39
		wizard.addWizardPageListener(new IWizardPageListener() {
40

    
41
		    @Override
42
		    public void close() {
43
		        wizard.performFinish();
44
		        dialog.close();
45
		    }
46
		});
47
		int status = dialog.open();
48

    
49
		if(status == IStatus.OK && wizard.openInEditor()){
50
			if(wizard.openEmpty()){
51
				NavigationUtil.openEmpty(wizard.getParentTreeNode().getUuid());
52
			}else if(wizard.getTaxonNode() != null){
53
				NavigationUtil.openEditor(wizard.getTaxonNode());
54
			}
55
		}
56
		return null;
57
	}
58
}
(10-10/16)