Add referencing objects view functionality to derivative editor #5403
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 13 Jan 2016 06:26:59 +0000 (07:26 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 13 Jan 2016 06:26:59 +0000 (07:26 +0100)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java
eu.etaxonomy.taxeditor.editor/plugin.xml

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} */
index 8ead2c7be1b9f792fc6b4dfb4d4c7b6a1aded81e..18e6e63e8b266ad978fe28f534c8f4816ed79d4f 100644 (file)
       <menuContribution
             locationURI="popup:eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView">
          <command
-               commandId="eu.etaxonomy.taxeditor.editor.derivate.delete"
+               commandId="org.eclipse.ui.edit.delete"
                label="%command.label.52"
                style="push">
          </command>
                label="%command.label.54"
                style="push">
          </command>
+         <dynamic
+               class="eu.etaxonomy.taxeditor.view.CdmViewerContextMenu"
+               id="eu.etaxonomy.taxeditor.editor.derivativeEditor.CdmViewerContextMenu">
+         </dynamic>
          <dynamic
                class="eu.etaxonomy.taxeditor.editor.view.derivate.contextMenu.DerivateViewContextMenu"
                id="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateContextMenu">
       </handler>
       <handler
             class="eu.etaxonomy.taxeditor.editor.view.derivate.handler.DeleteDerivateHandler"
-            commandId="eu.etaxonomy.taxeditor.editor.view.derivate.command.delete">
+            commandId="org.eclipse.ui.edit.delete">
          <activeWhen>
             <with
                   variable="activePartId">
             </reference>
          </activeWhen>
       </handler>
+      <handler
+            class="eu.etaxonomy.taxeditor.handler.defaultHandler.OpenReferencingObjectsView"
+            commandId="eu.etaxonomy.taxeditor.openReferencingObjectsView">
+         <activeWhen>
+            <with
+                  variable="activePartId">
+               <equals
+                     value="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView">
+               </equals>
+            </with>
+         </activeWhen>
+      </handler>
    </extension>
    <extension
          name="%extension.name"