// $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.
*/
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);
-
+
+ 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;
}
* @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();
*
* @return a boolean.
*/
- public boolean onComplete() {
+ @Override
+ public boolean onComplete() {
// TODO Auto-generated method stub
return false;
}