- added wizard page listener to react on ENTER key #4853
[taxeditor.git] / eu.etaxonomy.taxeditor.navigation / src / main / java / eu / etaxonomy / taxeditor / navigation / navigator / handler / NewTaxonNodeHandler.java
index dc5f39a1b923bcdbfc9aac28e3ff1acf70282a6d..4e928a0cec32e45ad20f2d44f52245b86e732d31 100644 (file)
@@ -2,9 +2,9 @@ package eu.etaxonomy.taxeditor.navigation.navigator.handler;
 // $Id$
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
@@ -13,12 +13,12 @@ package eu.etaxonomy.taxeditor.navigation.navigator.handler;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
+import eu.etaxonomy.taxeditor.newWizard.IWizardPageListener;
 import eu.etaxonomy.taxeditor.newWizard.NewTaxonNodeWizard;
 
 /**
@@ -28,25 +28,31 @@ import eu.etaxonomy.taxeditor.newWizard.NewTaxonNodeWizard;
  * @created Sep 15, 2009
  * @version 1.0
  */
-public class NewTaxonNodeHandler extends AbstractHandler implements IHandler {
+public class NewTaxonNodeHandler extends AbstractHandler {
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
-        */
        /** {@inheritDoc} */
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               NewTaxonNodeWizard wizard = new NewTaxonNodeWizard();
+       @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+               final NewTaxonNodeWizard wizard = new NewTaxonNodeWizard();
                wizard.init(null, null);
-               WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
+               final WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
+               wizard.addWizardPageListener(new IWizardPageListener() {
+
+                   @Override
+                   public void close() {
+                       wizard.performFinish();
+                       dialog.close();
+                   }
+               });
                int status = dialog.open();
-               
+
                if(status == IStatus.OK && wizard.openInEditor()){
                        if(wizard.openEmpty()){
                                NavigationUtil.openEmpty(wizard.getParentTreeNode().getUuid());
                        }else if(wizard.getTaxonNode() != null){
                                NavigationUtil.openEditor(wizard.getTaxonNode());
                        }
-               }       
+               }
                return null;
        }
 }