Add referencing objects view functionality to derivative editor #5403
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / referencingobjects / ReferencingObjectsView.java
index 8573b617bf11d22d6f23bb7a5941352d0ee4b892..6c76b43746d947e09e20801eb21872fd2feec12b 100644 (file)
@@ -31,6 +31,7 @@ import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.TableViewerColumn;
 import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.TreeNode;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
@@ -57,9 +58,7 @@ import eu.etaxonomy.cdm.model.name.NonViralName;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
-import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
 import eu.etaxonomy.taxeditor.model.DescriptionHelper;
-import eu.etaxonomy.taxeditor.model.LineSelection;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
@@ -283,26 +282,9 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
         if(part == this){
             return;
         }
-               if(! (part instanceof BulkEditor)){
-                       setContentDescription("");
-                       showEmptyPage();
-                       return;
-               }
-
-               if(! (selection instanceof LineSelection)){
-                       return;
-               }
-               LineSelection lineSelection = (LineSelection) selection;
-
-               if(lineSelection.size() != 1){
-                       return;
-               }
-
-               if(! (lineSelection.getFirstElement() instanceof IdentifiableEntity)){
-                       return;
-               }
-
-               showViewer(part, lineSelection);
+        if(selection instanceof IStructuredSelection){
+            showViewer(part, (IStructuredSelection) selection);
+        }
        }
 
        /** {@inheritDoc} */
@@ -310,7 +292,16 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
        public void showViewer(IWorkbenchPart part, IStructuredSelection selection) {
        //      this.part = part;
 
-               updateReferencingObjects(((IdentifiableEntity) selection.getFirstElement()).getUuid(),selection.getFirstElement().getClass() );
+               Object firstElement = selection.getFirstElement();
+               if(firstElement instanceof TreeNode){
+                   firstElement = ((TreeNode) firstElement).getValue();
+               }
+               if(firstElement instanceof IdentifiableEntity){
+                   updateReferencingObjects(((IdentifiableEntity) firstElement).getUuid(),firstElement.getClass() );
+               }
+               else{
+            setContentDescription("");
+               }
        }
 
        /** {@inheritDoc} */