for drag & drop it is now possible to move a taxonnode as a child node of the classif...
authorKatja Luther <k.luther@bgbm.org>
Mon, 16 Mar 2015 12:51:06 +0000 (12:51 +0000)
committerKatja Luther <k.luther@bgbm.org>
Mon, 16 Mar 2015 12:51:06 +0000 (12:51 +0000)
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TreeNodeDropAdapterAssistant.java

index a8828cbc7d8a167f6e4cab1a6c89e7debf29c6c9..fbf20ea45cfa2e92d287b62520ef53496af2493f 100644 (file)
@@ -29,7 +29,9 @@ import org.eclipse.ui.handlers.HandlerUtil;
 import org.eclipse.ui.navigator.CommonDropAdapter;
 import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
 
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
@@ -66,6 +68,10 @@ public class TreeNodeDropAdapterAssistant extends CommonDropAdapterAssistant imp
                if (target instanceof ITaxonTreeNode) {
                        Set<TaxonNode> taxonNodes = getSelectedTaxa();
                        ITaxonTreeNode targetTreeNode = (ITaxonTreeNode) target;
+                       if (targetTreeNode instanceof Classification){
+                               targetTreeNode = ((Classification)targetTreeNode).getRootNode();
+                               targetTreeNode = HibernateProxyHelper.deproxy(targetTreeNode, TaxonNode.class);
+                       }
                        if(taxonNodes != null) {
                                if (taxonNodes.size() == 1){
                                        return moveTaxon(taxonNodes.iterator().next(), targetTreeNode);
@@ -179,6 +185,10 @@ public class TreeNodeDropAdapterAssistant extends CommonDropAdapterAssistant imp
                                return Status.CANCEL_STATUS;
                        }
 
+                       
+                       /*if (((TaxonNode) targetITaxonTreeNode).isTopmostNode()) {
+                               MessageDialog.openConfirm(null, "Taxonnode can not be moved", "A taxonnode can not be moved to the classification");
+                       }*/
 
                        // Make sure parentTaxon is not the drop target
 //                     if (!childTaxonNode.isTopmostNode() && childTaxonNode.getParent().equals(targetTaxonNode)){