ref #6596 Fix selection handling for descriptive view
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 28 Jun 2017 14:07:50 +0000 (16:07 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 28 Jun 2017 14:07:50 +0000 (16:07 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java

index bccefe8a773905bcdd3bc84056569e8b158af4cf..caece5acd0a5192b67ac020661137db8a8b0b45a 100644 (file)
@@ -176,31 +176,29 @@ public class DescriptiveViewPart extends AbstractCdmEditorViewPart implements IP
             // description selected in this view
             return;
         }
-               // unpackage TreeNode of DerivateView
-               else if(partObject instanceof E4PartWrapper && ((E4PartWrapper)partObject).getPartName().equals("%command.label.DERIVATIVE_EDITOR")){
-                   TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(selection);
-                   if(treeNodeOfSelection!=null){
-                       selection = new StructuredSelection(treeNodeOfSelection.getValue());
-                       showViewer(partObject, (IStructuredSelection) selection);
-                           return;
-                   }
-               }
         else if(partObject instanceof ChecklistEditor){
             if(selection instanceof StructuredSelection  && ((IStructuredSelection) selection).getFirstElement() instanceof Taxon){
                 Taxon taxon = (Taxon)((IStructuredSelection) selection).getFirstElement();
                 selection = new StructuredSelection(taxon);
             }
         }
-               if(selection instanceof IStructuredSelection
-                       && ((IStructuredSelection) selection).getFirstElement() instanceof IDescribable<?>
-                       && partObject instanceof IPartContentHasFactualData  && !(((IStructuredSelection) selection).getFirstElement() instanceof SpecimenOrObservationBase && partObject instanceof BulkEditor)){
-                   featureNodeContainerCache.clear();
-                   showViewer(partObject, (IStructuredSelection) selection);
-                   return;
-               }
-               else{
-                   showEmptyPage();
-               }
+        //check if it is a tree node selection
+        TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(selection);
+        if(treeNodeOfSelection!=null){
+            selection = new StructuredSelection(treeNodeOfSelection.getValue());
+        }
+        if(selection instanceof IStructuredSelection){
+            Object firstElement = ((IStructuredSelection) selection).getFirstElement();
+            if(firstElement instanceof IDescribable<?>
+            && partObject instanceof IPartContentHasFactualData  && !(firstElement instanceof SpecimenOrObservationBase && partObject instanceof BulkEditor)){
+                featureNodeContainerCache.clear();
+                showViewer(partObject, (IStructuredSelection) selection);
+                return;
+            }
+        }
+        else{
+            showEmptyPage();
+        }
        }
 
        @Override