ref #10138: handle selection of empty media or factual data view
authorKatja Luther <k.luther@bgbm.org>
Wed, 21 Dec 2022 13:26:45 +0000 (14:26 +0100)
committerKatja Luther <k.luther@bgbm.org>
Wed, 21 Dec 2022 13:27:14 +0000 (14:27 +0100)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/container/AbstractGroupedContainer.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java

index c539be75353db83c7b486625f8de43bf20dee676..be46f8757a12d1ec0294542cc7c3bef7b69aa784 100755 (executable)
@@ -61,6 +61,8 @@ import eu.etaxonomy.taxeditor.editor.name.e4.TaxonEditor;
 import eu.etaxonomy.taxeditor.editor.name.e4.dnd.NameEditorDragListenerE4;
 import eu.etaxonomy.taxeditor.editor.name.e4.dnd.NameEditorDragSourceEffect;
 import eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInNewGroupOperation;
+import eu.etaxonomy.taxeditor.event.EventUtility;
+import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.IElementHasDetails;
 import eu.etaxonomy.taxeditor.model.NameHelper;
@@ -176,7 +178,7 @@ abstract public class AbstractGroupedContainer<T extends TaxonBase> implements
                        public void focusLost(FocusEvent e) {
                                super.focusLost(e);
                                persistName();
-//                             EventUtility.postAsyncEvent(WorkbenchEventConstants.REFRESH_DETAILS, true);
+                               EventUtility.postAsyncEvent(WorkbenchEventConstants.REFRESH_DETAILS, true);
                        }
                };
 
index 4197b213b035ba9e4a21ad6268bd369a0fea09a6..524b88d41b1d3ce8b216f421a819b9d1ecd36893 100644 (file)
@@ -14,8 +14,11 @@ import javax.inject.Inject;
 import org.eclipse.e4.core.contexts.ContextInjectionFactory;
 import org.eclipse.e4.core.contexts.IEclipseContext;
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.SWTException;
 import org.eclipse.swt.widgets.Composite;
 
@@ -59,12 +62,26 @@ public class DetailsPartE4 extends AbstractCdmEditorPart<DetailsViewerE4> implem
         if (activePart == thisPart){
             return;
         }
+        
+       
 
         Object partObject = getPartObject(activePart);
         if (partObject instanceof SupplementalDataPartE4 ) {
             // do not show empty page
             return;
         }
+        
+        if (partObject instanceof AbstractCdmEditorPart && ((AbstractCdmEditorPart)partObject).getViewer() instanceof TreeViewer ) {
+               //active part is factual data view or media view
+               IStructuredSelection structuredSelection = createSelection(selection);
+               if (structuredSelection != null && !structuredSelection.isEmpty()) {
+                       //if the active part is empty the selection is still the previous selection
+                       if (!(structuredSelection instanceof TreeSelection)) {
+                               return;
+                       }
+               }
+               
+           }
 
         if(partObject instanceof IPartContentHasDetails){
             IStructuredSelection structuredSelection = createSelection(selection);