From: n.hoffmann Date: Wed, 23 Sep 2009 11:01:58 +0000 (+0000) Subject: fixes #1089 X-Git-Tag: rcp.ss-first-working-version~579 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/b7c1585f158ce8705d7fe40c2c5800f1551df20b fixes #1089 --- diff --git a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonDropAdapterAssistant.java b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonDropAdapterAssistant.java index e12c1eab8..3fe7c615f 100644 --- a/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonDropAdapterAssistant.java +++ b/taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonDropAdapterAssistant.java @@ -26,9 +26,8 @@ import org.eclipse.ui.navigator.CommonDropAdapterAssistant; import eu.etaxonomy.cdm.model.common.CdmBase; import eu.etaxonomy.cdm.model.taxon.ITreeNode; +import eu.etaxonomy.cdm.model.taxon.IllegalAncestryException; import eu.etaxonomy.cdm.model.taxon.TaxonNode; -import eu.etaxonomy.cdm.model.taxon.TaxonomicTree; -import eu.etaxonomy.taxeditor.model.NameHelper; import eu.etaxonomy.taxeditor.navigation.NavigationUtil; import eu.etaxonomy.taxeditor.operations.IPostOperationEnabled; import eu.etaxonomy.taxeditor.operations.MoveTaxonOperation; @@ -95,15 +94,8 @@ public class TaxonDropAdapterAssistant extends CommonDropAdapterAssistant implem TaxonNode targetTaxonNode = (TaxonNode) targetTreeNode; - // TODO what should happen here? - // Make sure parentTaxon is not a child + // Make sure parentTaxon is not the drop target if (!childTaxonNode.isTopmostNode() && childTaxonNode.getParent().equals(targetTaxonNode)){ - - MessageDialog.openError(NavigationUtil.getShell(), "Can't move taxon.", - "'" + NameHelper.getDisplayName(childTaxonNode.getTaxon()) + "' sits above " + - "'" + NameHelper.getDisplayName(targetTaxonNode.getTaxon()) + "' " + - "in the taxonomic hierarchy."); - return Status.CANCEL_STATUS; } @@ -127,9 +119,11 @@ public class TaxonDropAdapterAssistant extends CommonDropAdapterAssistant implem } + IUndoableOperation operation = new MoveTaxonOperation ("Move Taxon", workspaceUndoContext, childTaxonNode, targetTreeNode, this); NavigationUtil.executeOperation(operation); + logger.info("Moved taxon " + childTaxonNode + " to new parent " + targetTreeNode); diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/MoveTaxonOperation.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/MoveTaxonOperation.java index 4fa470d40..9dbbfe2e6 100644 --- a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/MoveTaxonOperation.java +++ b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/MoveTaxonOperation.java @@ -21,8 +21,10 @@ import org.eclipse.core.runtime.Status; import eu.etaxonomy.cdm.api.conversation.ConversationHolder; import eu.etaxonomy.cdm.model.taxon.ITreeNode; +import eu.etaxonomy.cdm.model.taxon.IllegalAncestryException; import eu.etaxonomy.cdm.model.taxon.TaxonNode; import eu.etaxonomy.taxeditor.store.CdmStore; +import eu.etaxonomy.taxeditor.store.StoreUtil; /** * Change the taxonomic parent of a given taxon. @@ -103,10 +105,14 @@ public class MoveTaxonOperation extends AbstractPostOperation { // find the new parent node ITreeNode newParentTreeNode = CdmStore.getTaxonTreeService().getTreeNodeByUuid(newParentTreeNodeUuid); // add node to new parent - TaxonNode newChild = newParentTreeNode.addChildNode(taxonNode, newParentTreeNode.getReference(), newParentTreeNode.getMicroReference(), taxonNode.getSynonymToBeUsed()); - - // commit the conversation - conversation.commit(true); - return newChild; + try{ + TaxonNode newChild = newParentTreeNode.addChildNode(taxonNode, newParentTreeNode.getReference(), newParentTreeNode.getMicroReference(), taxonNode.getSynonymToBeUsed()); + // commit the conversation + conversation.commit(true); + return newChild; + }catch(IllegalAncestryException e){ + StoreUtil.warningDialog("Illegal ancestry", e.getMessage()); + } + return null; } }