// $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.
*/
package eu.etaxonomy.taxeditor.editor.name.handler;
import java.util.List;
+import java.util.Set;
import java.util.UUID;
import org.apache.log4j.Logger;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;
import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeSynonymToAcceptedTaxonOperation;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
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;
}
Synonym synonym = (Synonym) selection.getFirstElement();
-
+
// Force user to save taxon - not really necessary though, is it?
if (!EditorUtil.forceUserSave(editor, shell)) {
return null;
// 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);
-
+
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(),
- taxon, newParentNode, synonym, null, this, editor); //$NON-NLS-1$
+ AbstractPostOperation operation = new ChangeSynonymToAcceptedTaxonOperation("Change synonym to accepted taxon", EditorUtil.getUndoContext(),
+ taxon, newParentNode, synonym, namesInGroup, this, editor, editor); //$NON-NLS-1$
EditorUtil.executeOperation(operation);
}
-
+
return null;
}
* @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
/*
* doesn't work yet.
*/
EditorUtil.openTaxonNode(newNode.getUuid());
-
+
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
- EditorUtil.warningDialog("Could not create Taxon", this, e.getMessage());
+ MessagingUtils.warningDialog("Could not create Taxon", this, e.getMessage());
}
}
return true;
*
* @return a boolean.
*/
- public boolean onComplete() {
+ @Override
+ public boolean onComplete() {
// TODO Auto-generated method stub
return false;
}