- only allow dragging in DerivateView when view is not dirty
authorPatric Plitzner <p.plitzner@bgbm.org>
Wed, 14 May 2014 07:18:25 +0000 (07:18 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Wed, 14 May 2014 07:18:25 +0000 (07:18 +0000)
 - added missing methods to transient services
 - exposed dto package in cdmlib project
 - some renaming

eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientOccurenceService.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateDragListener.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateDropListener.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java

index 86b13754f89f1878850993b6947c124fb023de7a..0959b7a46806502d2c42894aadfdfc51d9972491 100644 (file)
@@ -14,6 +14,7 @@ Export-Package: com.google.api,
  eu.etaxonomy.cdm.api.service,
  eu.etaxonomy.cdm.api.service.config,
  eu.etaxonomy.cdm.api.service.description,
+ eu.etaxonomy.cdm.api.service.dto,
  eu.etaxonomy.cdm.api.service.exception,
  eu.etaxonomy.cdm.api.service.lsid,
  eu.etaxonomy.cdm.api.service.lsid.impl,
index 5a226f607eadde05a2ac0e306ffad0d84627ee16..ab743b923719321b34ac1c5b74704c0019e0ea99 100644 (file)
@@ -30,7 +30,7 @@ import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
 import eu.etaxonomy.cdm.api.service.IOccurrenceService;
 import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
-import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
+import eu.etaxonomy.cdm.api.service.dto.DerivateHierarchyDTO;
 import eu.etaxonomy.cdm.api.service.pager.Pager;
 import eu.etaxonomy.cdm.api.service.search.SearchResult;
 import eu.etaxonomy.cdm.api.service.util.TaxonRelationshipEdge;
@@ -898,9 +898,28 @@ public class TransientOccurenceService implements IOccurrenceService {
        @Override
        public List<String> isDeletable(SpecimenOrObservationBase object,
                        DeleteConfiguratorBase config) {
-               // TODO Auto-generated method stub
-               return null;
+               return defaultService.isDeletable(object, config);
        }
 
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.cdm.api.service.IOccurrenceService#listFieldUnitsByAssociatedTaxon(java.util.Set, eu.etaxonomy.cdm.model.taxon.Taxon, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.util.List, java.util.List)
+     */
+    @Override
+    public Collection<FieldUnit> listFieldUnitsByAssociatedTaxon(Set<TaxonRelationshipEdge> includeRelationships,
+            Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
+            List<String> propertyPaths) {
+        return defaultService.listFieldUnitsByAssociatedTaxon(includeRelationships, associatedTaxon, maxDepth, pageSize, pageNumber, orderHints, propertyPaths);
+    }
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.cdm.api.service.IOccurrenceService#listDerivateHierarchyDTOsByAssociatedTaxon(java.util.Set, eu.etaxonomy.cdm.model.taxon.Taxon, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.util.List, java.util.List)
+     */
+    @Override
+    public Collection<DerivateHierarchyDTO> listDerivateHierarchyDTOsByAssociatedTaxon(
+            Set<TaxonRelationshipEdge> includeRelationships, Taxon associatedTaxon, Integer maxDepth, Integer pageSize,
+            Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {
+        return listDerivateHierarchyDTOsByAssociatedTaxon(includeRelationships, associatedTaxon, maxDepth, pageSize, pageNumber, orderHints, propertyPaths);
+    }
+
 
 }
index 381aa64a428daa25614dd146d720fe1c6f31a990..e4656ef53e55f4257291360d300e954020367a70 100644 (file)
@@ -11,11 +11,11 @@ package eu.etaxonomy.taxeditor.editor.view.derivate;
 
 import org.eclipse.jface.util.LocalSelectionTransfer;
 import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.dnd.DragSourceAdapter;
 import org.eclipse.swt.dnd.DragSourceEvent;
 
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
 
 /**
  * @author pplitzner
@@ -24,13 +24,13 @@ import eu.etaxonomy.taxeditor.editor.EditorUtil;
  */
 public class DerivateDragListener extends DragSourceAdapter{
 
-    private final Viewer viewer;
+    private final DerivateView derivateView;
 
     /**
-     * @param viewer
+     * @param derivateView
      */
-    public DerivateDragListener(Viewer viewer) {
-        this.viewer = viewer;
+    public DerivateDragListener(DerivateView derivateView) {
+        this.derivateView = derivateView;
     }
 
     /* (non-Javadoc)
@@ -39,7 +39,7 @@ public class DerivateDragListener extends DragSourceAdapter{
     @Override
     public void dragSetData(DragSourceEvent event) {
         if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
-            LocalSelectionTransfer.getTransfer().setSelection(viewer.getSelection());
+            LocalSelectionTransfer.getTransfer().setSelection(derivateView.getViewer().getSelection());
         }
     }
 
@@ -48,7 +48,12 @@ public class DerivateDragListener extends DragSourceAdapter{
      */
     @Override
     public void dragStart(DragSourceEvent event) {
-        ISelection selection = viewer.getSelection();
+        if(derivateView.isDirty()){
+            event.doit = false;
+            AbstractUtility.warningDialog("View has unsaved changes", this, "You need to save before performing this action");
+            return;
+        }
+        ISelection selection = derivateView.getViewer().getSelection();
         if(EditorUtil.getTreeNodeOfSelection(selection)!=null){
             event.doit = true;
         }
index 05a769171aa07cc180230a9a62bc264a00ce47d8..009c59fc032fc4c7c5eb3e0c82e1fe7c01ecfa3c 100644 (file)
@@ -79,18 +79,18 @@ public class DerivateDropListener extends ViewerDropAdapter {
      * @param value
      * @return
      */
-    private boolean moveTreeNode(TreeNode from, TreeNode to) {
-        Object fromValue = from.getValue();
-        Object toValue = to.getValue();
-        TreeNode fromParentNode = from.getParent();
+    private boolean moveTreeNode(TreeNode draggedNode, TreeNode targetNode) {
+        Object draggedNodeValue = draggedNode.getValue();
+        Object targetNodeValue = targetNode.getValue();
+        TreeNode fromParentNode = draggedNode.getParent();
         Object fromParentSpecimen = fromParentNode.getValue();
 
         // drag'n'drop for SpecimenOrObservationBase
-        if(fromValue instanceof DerivedUnit && toValue instanceof SpecimenOrObservationBase<?>){
-            DerivedUnit draggedSpecimen = (DerivedUnit) fromValue;
-            SpecimenOrObservationBase<?> targetSpecimen = (SpecimenOrObservationBase<?>) toValue;
+        if(draggedNodeValue instanceof DerivedUnit && targetNodeValue instanceof SpecimenOrObservationBase<?>){
+            DerivedUnit draggedSpecimen = (DerivedUnit) draggedNodeValue;
+            SpecimenOrObservationBase<?> targetSpecimen = (SpecimenOrObservationBase<?>) targetNodeValue;
             //check if type is a sub derivate type
-            if(!fromParentNode.equals(to)//don't drag on direct parent node
+            if(!fromParentNode.equals(targetNode)//don't drag on direct parent node
                     && fromParentSpecimen instanceof SpecimenOrObservationBase<?>){
                 CdmStore.getService(IOccurrenceService.class).moveDerivate((SpecimenOrObservationBase<?>)fromParentSpecimen, targetSpecimen, draggedSpecimen);
                 return true;
@@ -98,19 +98,19 @@ public class DerivateDropListener extends ViewerDropAdapter {
         }
 
         // drag'n'drop for SingleRead
-        else if(fromValue instanceof SingleRead && toValue instanceof Sequence){
-            SingleRead singleRead = (SingleRead) fromValue;
+        else if(draggedNodeValue instanceof SingleRead && targetNodeValue instanceof Sequence){
+            SingleRead singleRead = (SingleRead) draggedNodeValue;
             if(fromParentSpecimen instanceof Sequence){
-                CdmStore.getService(ISequenceService.class).moveSingleRead((Sequence)fromParentSpecimen, (Sequence)toValue, singleRead);
+                CdmStore.getService(ISequenceService.class).moveSingleRead((Sequence)fromParentSpecimen, (Sequence)targetNodeValue, singleRead);
             }
             return true;
         }
 
         // drag'n'drop for Sequence
-        else if(fromValue instanceof Sequence && toValue instanceof DnaSample ){
-            Sequence sequence = (Sequence)fromValue;
+        else if(draggedNodeValue instanceof Sequence && targetNodeValue instanceof DnaSample ){
+            Sequence sequence = (Sequence)draggedNodeValue;
             if(fromParentSpecimen instanceof DnaSample){
-                CdmStore.getService(IOccurrenceService.class).moveSequence((DnaSample)fromParentSpecimen, (DnaSample)toValue, sequence);
+                CdmStore.getService(IOccurrenceService.class).moveSequence((DnaSample)fromParentSpecimen, (DnaSample)targetNodeValue, sequence);
                 return true;
             }
         }
index 441685dc42af8b15a09b6186a098c76bd146b364..2745a94d1c7ecaf9341f9d36b456dc231a3248fe 100644 (file)
@@ -112,7 +112,7 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
 
         //add drag'n'drop support
         Transfer[] transfers = new Transfer[] {LocalSelectionTransfer.getTransfer(),};
-        viewer.addDragSupport(dndOperations, transfers, new DerivateDragListener(viewer));
+        viewer.addDragSupport(dndOperations, transfers, new DerivateDragListener(this));
         viewer.addDropSupport(dndOperations, transfers, new DerivateDropListener(this));
     }