Pre-select current classification for taxon node selection dialog
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / name / handler / ChangeSynonymToAcceptedTaxonHandler.java
index e76b8475e3a91bd43d8587fadb357dc6e94bd129..b25601b2140be37ca18662564753276f0c382d4e 100644 (file)
@@ -1,9 +1,9 @@
 // $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.
 */
@@ -51,16 +51,17 @@ public class ChangeSynonymToAcceptedTaxonHandler extends AbstractHandler impleme
        private static final Logger logger = Logger
                        .getLogger(ChangeSynonymToAcceptedTaxonHandler.class);
        private MultiPageTaxonEditor editor;
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
         */
        /** {@inheritDoc} */
-       public Object execute(ExecutionEvent event) throws ExecutionException {
+       @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
                editor =  (MultiPageTaxonEditor) HandlerUtil.getActiveEditor(event);
                Shell shell = HandlerUtil.getActiveShell(event);
                IEditorInput input = editor.getEditorInput();
-               
+
                if (!(input instanceof TaxonEditorInput)) {
                        logger.error("Editor input is not TaxonEditorInput");
                        return null;
@@ -74,7 +75,7 @@ public class ChangeSynonymToAcceptedTaxonHandler extends AbstractHandler impleme
                }
 
                Synonym synonym = (Synonym) selection.getFirstElement();
-               
+
                // Force user to save taxon - not really necessary though, is it?
                if (!EditorUtil.forceUserSave(editor, shell)) {
                        return null;
@@ -82,25 +83,25 @@ public class ChangeSynonymToAcceptedTaxonHandler extends AbstractHandler impleme
 
                // Get taxon
                Taxon taxon = ((TaxonEditorInput) input).getTaxon();
-               
+
                TaxonNode parentNode = (TaxonNode) HibernateProxyHelper.deproxy(((TaxonEditorInput) input).getTaxonNode().getParent());
-               
+
                List<UUID> excludeTaxa = null;
-               
-               TaxonNode newParentNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event), editor.getConversationHolder(), "Select parent", excludeTaxa, null, null);
-               
+
+               TaxonNode newParentNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event), editor.getConversationHolder(), "Select parent", excludeTaxa, null, ((TaxonEditorInput) input).getTaxonNode().getClassification());
+
                if(newParentNode != null){
-                       
+
                        // TODO get synonyms from homotypical group and add them as homotypic synonyms to new accepted taxon
                        // apply confirmation dialog
                        HomotypicalGroup group = synonym.getHomotypicGroup();
                        Set<TaxonNameBase> namesInGroup = group.getTypifiedNames();
                        // FIXME with this implementation we can not create a taxonNode that is a direct child of the classification node
-                       AbstractPostOperation operation = new ChangeSynonymToAcceptedTaxonOperation("Change synonym to accepted taxon", EditorUtil.getUndoContext(), 
+                       AbstractPostOperation operation = new ChangeSynonymToAcceptedTaxonOperation("Change synonym to accepted taxon", EditorUtil.getUndoContext(),
                                        taxon, newParentNode, synonym, namesInGroup, this, editor); //$NON-NLS-1$
                        EditorUtil.executeOperation(operation);
                }
-               
+
                return null;
        }
 
@@ -108,19 +109,20 @@ public class ChangeSynonymToAcceptedTaxonHandler extends AbstractHandler impleme
         * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
         */
        /** {@inheritDoc} */
-       public boolean postOperation(CdmBase objectAffectedByOperation) {
-               
+       @Override
+    public boolean postOperation(CdmBase objectAffectedByOperation) {
+
                // Redraw existing editor
                ((IPostOperationEnabled) editor).postOperation(null);
-               
+
                editor.doSave(EditorUtil.getMonitor());
-               
+
                if (objectAffectedByOperation instanceof TaxonNode) {
-               
+
                        // Open new unsaved editor with existing taxon's parent as temporary parent
                        TaxonNode newNode = (TaxonNode) objectAffectedByOperation;
 //                     TaxonNode newNode = parentNode.addChild(newTaxon);
-                                       
+
                        try {
                                // TODO
                                /*
@@ -129,7 +131,7 @@ public class ChangeSynonymToAcceptedTaxonHandler extends AbstractHandler impleme
                                 *  doesn't work yet.
                                 */
                                EditorUtil.openTaxonNode(newNode.getUuid());
-                               
+
                        } catch (PartInitException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
@@ -145,7 +147,8 @@ public class ChangeSynonymToAcceptedTaxonHandler extends AbstractHandler impleme
         *
         * @return a boolean.
         */
-       public boolean onComplete() {
+       @Override
+    public boolean onComplete() {
                // TODO Auto-generated method stub
                return false;
        }