ref #6911, #6925 Clear views when selection providing editor is closed
authorPatrick Plitzner <p.plitzner@bgbm.org>
Fri, 22 Sep 2017 08:02:18 +0000 (10:02 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Fri, 22 Sep 2017 08:53:19 +0000 (10:53 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/e4/ConceptViewPartE4.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/e4/MediaViewPartE4.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmDataViewerE4.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/supplementaldata/SupplementalDataPartE4.java
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/SaveHandler.java
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/WorkbenchUtility.java

index 18639870d7134d5f69f684714c4fb06e6635ffc6..8f9acc976f2b3e85843929590b9cc63fafb66533 100644 (file)
@@ -35,6 +35,8 @@ import eu.etaxonomy.taxeditor.editor.key.AbstractGraphKeyEditor;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.editor.view.concept.ConceptContentProvider;
 import eu.etaxonomy.taxeditor.editor.view.concept.ConceptLabelProvider;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
+import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
@@ -65,7 +67,8 @@ implements IPartContentHasDetails, IPartContentHasSupplementalData{
 
         Object partObject = createPartObject(activePart);
 
-        if (partObject instanceof DetailsPartE4 || partObject instanceof SupplementalDataPartE4) {
+        if (partObject instanceof DetailsPartE4 || partObject instanceof SupplementalDataPartE4
+                || partObject instanceof FactualDataPartE4|| partObject instanceof MediaViewPartE4) {
             // do not show empty page as these views are also used to edit the
             // description selected in this view
             return;
index 73ead02524d871fb2e4d2b83ac386f6233a06b76..62fe4ede1976c0949bd5dd5ad8ec8380802284d2 100644 (file)
@@ -47,6 +47,7 @@ import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
 import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor;
+import eu.etaxonomy.taxeditor.editor.view.concept.e4.ConceptViewPartE4;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDragListener;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDropAdapter;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementTransfer;
@@ -142,7 +143,7 @@ public class FactualDataPartE4 extends AbstractCdmEditorPartE4
         Object partObject = createPartObject(activePart);
 
         if (partObject instanceof DetailsPartE4 || partObject instanceof SupplementalDataPartE4
-                || partObject instanceof MediaViewPartE4) {
+                || partObject instanceof MediaViewPartE4 || partObject instanceof ConceptViewPartE4) {
             // do not show empty page as these views are also used to edit the
             // description selected in this view
             return;
index 2c5ada6c4caea7c8c6c75d9cbb00204f918dec52..690f998e574b31a5824758f7644241ab37327e59 100644 (file)
@@ -28,6 +28,7 @@ import org.eclipse.swt.widgets.Tree;
 import eu.etaxonomy.cdm.model.description.IDescribable;
 import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
+import eu.etaxonomy.taxeditor.editor.view.concept.e4.ConceptViewPartE4;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
 import eu.etaxonomy.taxeditor.editor.view.media.MediaContentProvider;
 import eu.etaxonomy.taxeditor.editor.view.media.MediaLabelProvider;
@@ -82,7 +83,7 @@ public class MediaViewPartE4 extends AbstractCdmEditorPartE4
            Object partObject = createPartObject(activePart);
 
            if (partObject instanceof DetailsPartE4 || partObject instanceof SupplementalDataPartE4
-                   || partObject instanceof FactualDataPartE4) {
+                   || partObject instanceof FactualDataPartE4 || partObject instanceof ConceptViewPartE4) {
                // do not show empty page as these views are also used to edit the
                // description selected in this view
                return;
index 31055fdd7c4c1037eeffe4529e237cb1497c781d..87414b3ec3bc3cfa0dbaac58b41fba98f3c92a94 100644 (file)
@@ -149,7 +149,7 @@ public abstract class AbstractCdmDataViewerE4 extends Viewer implements IConvers
 
        protected abstract void showParts();
 
-       protected void destroySections() {
+       public void destroySections() {
                for (IFormPart formPart : managedForm.getParts()){
                        removePart((CdmSectionPart<?>) formPart);
                }
index 7ffb4a699203146a778a47b6fb385874ca65ccd6..f86f4612c4cfa4ac4406e8e326105ac2f7651d9f 100644 (file)
@@ -103,6 +103,10 @@ public abstract class AbstractCdmEditorPartE4
             @Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
             @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
             MPart thisPart){
+        Object savablePart = WorkbenchUtility.findSavablePart(this);
+        if(savablePart==null){
+            showEmptyPage();
+        }
         if(delaySelection==null){
             delaySelection = new DelaySelection(selection, activePart, thisPart);
         }
index ddb03224210006c34b872da708653dc52d7ffb38..36724567123f17d409cece0846511c62a0ae2809 100644 (file)
@@ -85,22 +85,19 @@ public class DetailsPartE4 extends AbstractCdmEditorPartE4 implements IPartConte
             showViewer(structuredSelection, activePart, viewer);
             return;
         }
-        else if(selectionProvidingPart!=null && selectionProvidingPart.isVisible()){
-            return;
-        }
         else{
             showEmptyPage();
             return;
         }
     }
 
-//    protected void showEmptyPage() {
-//        super.showEmptyPage();
-//        if(viewer!=null){
-//            viewer.showEmptyPage();
-//        }
-//        selectionProvidingPart = null;
-//    }
+    @Override
+    protected void showEmptyPage() {
+        super.showEmptyPage();
+        if(viewer!=null && !viewer.getControl().isDisposed()){
+            ((DetailsViewerE4)viewer).destroySections();
+        }
+    }
 
     @Override
     protected String getViewName(){
index 40dbc6d0461eb0642c14ef75226d844793eb8474..dfe918bf97a4ee04be6dd92f2b13de82ec1d34f1 100644 (file)
@@ -106,15 +106,23 @@ public class SupplementalDataPartE4 extends AbstractCdmEditorPartE4 {
                showViewer(structuredSelection, activePart, viewer);
                return;
            }
-        else if(selectionProvidingPart!=null && selectionProvidingPart.isVisible()){
-            return;
-        }
         else{
                showEmptyPage();
                return;
            }
        }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void showEmptyPage() {
+        super.showEmptyPage();
+        if(viewer!=null && !viewer.getControl().isDisposed()){
+            ((SupplementalDataViewerE4)viewer).destroySections();
+        }
+    }
+
        @Override
     protected String getViewName() {
                return Messages.SupplementalDataViewPart_VIEWER_NAME;
index aa593403bb7385a79829b72a278cc92f75205abf..ae6a18e1255012f588f83b3942099590a88b5c52 100644 (file)
@@ -32,7 +32,7 @@ public class SaveHandler {
             Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(activePart.getObject());
             if(e4WrappedPart instanceof ISelectionElementEditingPart){
                 ISelectionElementEditingPart editingPart = (ISelectionElementEditingPart)e4WrappedPart;
-                Object savablePart = findSavablePart(editingPart);
+                Object savablePart = WorkbenchUtility.findSavablePart(editingPart);
                 if(savablePart instanceof ISaveablePart){
                     ((ISaveablePart) savablePart).doSave(new NullProgressMonitor());
                 }
@@ -46,19 +46,7 @@ public class SaveHandler {
         }
        }
 
-       private Object findSavablePart(ISelectionElementEditingPart part){
-           Object selectionProvidingPart = WorkbenchUtility.getE4WrappedPart(part.getSelectionProvidingPart());
-           if(selectionProvidingPart instanceof ISelectionElementEditingPart){
-               return findSavablePart((ISelectionElementEditingPart) selectionProvidingPart);
-           }
-           else if(selectionProvidingPart instanceof ISaveablePart || selectionProvidingPart instanceof IE4SavablePart || selectionProvidingPart instanceof MPart){
-               return selectionProvidingPart;
-           }
-           return null;
-       }
-
-
-    private void savePart(EPartService partService, ECommandService commandService, EHandlerService handlerService,
+       private void savePart(EPartService partService, ECommandService commandService, EHandlerService handlerService,
             MPart mPart) {
         if(mPart.getObject() instanceof CompatibilityPart){
             //FIXME E4 remove when fully migrated
index 635fe7ff331eeb10f4cef90a96cfb6a3baa016f0..b1d6a754d5c9ab3038cbda2754051adc6f906e7a 100644 (file)
@@ -11,10 +11,14 @@ package eu.etaxonomy.taxeditor.workbench;
 import java.lang.reflect.Field;
 
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.ui.ISaveablePart;
 import org.eclipse.ui.internal.E4PartWrapper;
 import org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor;
 import org.eclipse.ui.internal.e4.compatibility.CompatibilityView;
 
+import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
+import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart;
+
 /**
  * Utility class for e4 workbench related operations
  * @author pplitzner
@@ -57,4 +61,15 @@ public class WorkbenchUtility {
         }
         return object;
     }
+
+    public static Object findSavablePart(ISelectionElementEditingPart part){
+        Object selectionProvidingPart = getE4WrappedPart(part.getSelectionProvidingPart());
+        if(selectionProvidingPart instanceof ISelectionElementEditingPart){
+            return findSavablePart((ISelectionElementEditingPart) selectionProvidingPart);
+        }
+        else if(selectionProvidingPart instanceof ISaveablePart || selectionProvidingPart instanceof IE4SavablePart || selectionProvidingPart instanceof MPart){
+            return selectionProvidingPart;
+        }
+        return null;
+    }
 }