ref #6596 Implement framework for accessing the selection providing part
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 27 Jun 2017 16:25:11 +0000 (18:25 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 28 Jun 2017 08:28:59 +0000 (10:28 +0200)
 - All AbstractCdmViewparts now keep track of the part that has provided
the last selection. This is necessary during e4 migration to simulate
the e3 behavior having IViewParts that edit object of IEditorParts
 - this can be removed/refactored when fully migrated

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/AbstractCdmEditorViewPart.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewPart.java
eu.etaxonomy.taxeditor.workbench/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/part/ISelectionElementEditingPart.java [new file with mode: 0644]

index 94a1629fc8ce92e2a8bee1d9a273dc8328a8f2ed..40eedab684cb27e728a96f9d4f1b8a07d69255f4 100644 (file)
@@ -12,6 +12,7 @@ import org.eclipse.ui.IWorkbenchPart;
 import eu.etaxonomy.taxeditor.editor.ISecuredEditor;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
+import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart;
 
 /**
  * <p>
@@ -22,7 +23,7 @@ import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
  * @created Sep 21, 2010
  * @version 1.0
  */
-public abstract class AbstractCdmEditorViewPart extends AbstractCdmViewPart {
+public abstract class AbstractCdmEditorViewPart extends AbstractCdmViewPart implements ISelectionElementEditingPart {
 
     private DelaySelection delaySelection = null;
     /**
@@ -30,6 +31,8 @@ public abstract class AbstractCdmEditorViewPart extends AbstractCdmViewPart {
      * If it is <code>true</code> then it is currently delaying a selection.
      */
     private boolean isInDelay;
+    
+    protected Object selectionProvidingPart;
 
 
     /**
@@ -91,6 +94,12 @@ public abstract class AbstractCdmEditorViewPart extends AbstractCdmViewPart {
             isInDelay = true;
             Display.getCurrent().asyncExec(delaySelection);
         }
+        selectionProvidingPart = part;
+    }
+
+    @Override
+    public Object getSelectionProvidingPart() {
+        return selectionProvidingPart;
     }
 
 
@@ -113,6 +122,15 @@ public abstract class AbstractCdmEditorViewPart extends AbstractCdmViewPart {
         return AbstractUtility.getActiveEditor();
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void showEmptyPage() {
+        selectionProvidingPart = null;
+        super.showEmptyPage();
+    }
+
     /** {@inheritDoc} */
     @Override
     public void setFocus() {
@@ -124,6 +142,15 @@ public abstract class AbstractCdmEditorViewPart extends AbstractCdmViewPart {
         }
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void dispose() {
+        selectionProvidingPart = null;
+        super.dispose();
+    }
+
     /** {@inheritDoc} */
     @Override
     public void changed(Object object) {
index e2eb0ff0a5144ed37bd35b3017d51a92bff6fd6a..85596906c9da220902941bc3d82b0dd01595ca9e 100644 (file)
@@ -20,7 +20,6 @@ import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.TreeNode;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IMemento;
 import org.eclipse.ui.IWorkbenchPart;
@@ -58,9 +57,6 @@ public class DetailsViewPart extends AbstractCdmEditorViewPart implements IPartC
 
        private DetailsViewer viewer;
 
-       //FIXME E4: this can be removed when working with E4 event system
-       private Object selectionProvidingPart;
-
        /** {@inheritDoc} */
        @Override
        public void createViewer(Composite parent) {
@@ -132,7 +128,6 @@ public class DetailsViewPart extends AbstractCdmEditorViewPart implements IPartC
                     return;
                 }
             }
-            selectionProvidingPart = part;
             showViewer(part, structuredSelection);
         }else{
             showEmptyPage();
@@ -163,7 +158,6 @@ public class DetailsViewPart extends AbstractCdmEditorViewPart implements IPartC
 
        @Override
        public void showEmptyPage() {
-           selectionProvidingPart = null;
            viewer.setSelection(null);
            super.showEmptyPage();
        }
@@ -247,11 +241,11 @@ public class DetailsViewPart extends AbstractCdmEditorViewPart implements IPartC
         if (element instanceof Taxon){
                Taxon taxon = HibernateProxyHelper.deproxy(element, Taxon.class);
                if (taxon.isMisapplication()){
-                       
+
                        if (part instanceof ITaxonEditor){
                                Taxon accepted= ((ITaxonEditor)part).getTaxon();
-                               Set<TaxonRelationship> rels =  taxon.getTaxonRelations(accepted); 
-                               
+                               Set<TaxonRelationship> rels =  taxon.getTaxonRelations(accepted);
+
                                 if (rels.iterator().hasNext()){
                                         TaxonRelationship rel = rels.iterator().next();
                                         if (rel.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
@@ -261,8 +255,8 @@ public class DetailsViewPart extends AbstractCdmEditorViewPart implements IPartC
                                         }
                                 }
                        }
-                       
-                       
+
+
                }
         }
         getViewer().setInput(element);
index 41375d3e357914c308cf962a5bcd6f20d0be0c0a..21fc49687e14d5737b0420c67cffc04021510ef5 100644 (file)
@@ -20,3 +20,4 @@ Require-Bundle: org.eclipse.ui,
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Import-Package: javax.inject;version="1.0.0"
 Bundle-ActivationPolicy: lazy
+Export-Package: eu.etaxonomy.taxeditor.workbench.part
diff --git a/eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/part/ISelectionElementEditingPart.java b/eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/part/ISelectionElementEditingPart.java
new file mode 100644 (file)
index 0000000..65ed5e3
--- /dev/null
@@ -0,0 +1,32 @@
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.workbench.part;
+
+/**
+ * Classes implementing this interface should be parts that edit elements
+ * coming from other parts via a selection change
+ * <br>
+ * This interface is used as a temporary workaround during e4 migration
+ * for simulating the IEditorPart behavior of editors VS views
+ *
+ * @author pplitzner
+ * @since Jun 27, 2017
+ *
+ */
+@Deprecated
+//FIXME E4 migration
+public interface ISelectionElementEditingPart {
+
+    /**
+     * Returns the part that has provided the last selection
+     * @return the selection providing part
+     */
+    public Object getSelectionProvidingPart();
+
+}