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.commands.IHandler;
|
17
|
import org.eclipse.core.runtime.IStatus;
|
18
|
import org.eclipse.jface.wizard.WizardDialog;
|
19
|
import org.eclipse.ui.handlers.HandlerUtil;
|
20
|
|
21
|
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
|
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 implements IHandler {
|
32
|
|
33
|
/* (non-Javadoc)
|
34
|
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
|
35
|
*/
|
36
|
/** {@inheritDoc} */
|
37
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
38
|
NewTaxonNodeWizard wizard = new NewTaxonNodeWizard();
|
39
|
wizard.init(null, null);
|
40
|
WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
|
41
|
int status = dialog.open();
|
42
|
|
43
|
if(status == IStatus.OK && wizard.openInEditor()){
|
44
|
if(wizard.openEmpty()){
|
45
|
NavigationUtil.openEmpty(wizard.getParentTreeNode().getUuid());
|
46
|
}else if(wizard.getTaxonNode() != null){
|
47
|
NavigationUtil.openEditor(wizard.getTaxonNode());
|
48
|
}
|
49
|
}
|
50
|
return null;
|
51
|
}
|
52
|
}
|