ref #7230: refresh of name editor and details view after changing taxon of misapplie...
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / e4 / details / DetailsPartE4.java
index f3230e6dec22bd34ff4b20d9919c0edbd4c12776..284496a5768f2821a9871d7b461d53bdbc5b7852 100644 (file)
@@ -14,8 +14,10 @@ import javax.inject.Inject;
 
 import org.eclipse.e4.core.contexts.ContextInjectionFactory;
 import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.services.log.Logger;
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWTException;
 import org.eclipse.swt.widgets.Composite;
 
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
@@ -25,7 +27,10 @@ import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
 import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPartE4;
+import eu.etaxonomy.taxeditor.view.e4.supplementaldata.SupplementalDataPartE4;
 import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart;
 
 /**
@@ -34,8 +39,10 @@ import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart;
  *
  */
 public class DetailsPartE4 extends AbstractCdmEditorPartE4 implements IPartContentHasSupplementalData {
-
-    @Inject
+       @Inject
+       private Logger logger;
+    
+       @Inject
     public DetailsPartE4() {
     }
 
@@ -59,6 +66,10 @@ public class DetailsPartE4 extends AbstractCdmEditorPartE4 implements IPartConte
         }
 
         Object partObject = createPartObject(activePart);
+        if (partObject instanceof SupplementalDataPartE4) {
+            // do not show empty page
+            return;
+        }
 
         if(partObject instanceof IPartContentHasDetails){
             IStructuredSelection structuredSelection = createSelection(selection);
@@ -87,6 +98,9 @@ public class DetailsPartE4 extends AbstractCdmEditorPartE4 implements IPartConte
 //                return;
 //
 //            }
+            //FIXME this is a temporary workaround to fix selection handling for supplemental data view
+            // Now the supp data view gets double selection from details view and name editor (see #7126)
+            viewer.setSelection(structuredSelection, false);
             showViewer(structuredSelection, activePart, viewer);
             return;
         }
@@ -99,8 +113,20 @@ public class DetailsPartE4 extends AbstractCdmEditorPartE4 implements IPartConte
     @Override
     protected void showEmptyPage() {
         super.showEmptyPage();
-        if(viewer!=null && viewer.getControl()!=null && !viewer.getControl().isDisposed()){
-            ((DetailsViewerE4)viewer).destroySections();
+        if(viewer!=null && viewer.getControl()!=null && !viewer.getControl().isDisposed() ){
+               try{
+                       ((DetailsViewerE4)viewer).destroySections();
+               }catch(SWTException e){
+                       if (PreferencesUtil.isShowUpWidgetIsDisposedMessages() && e.getMessage().equals("Widget is disposed")){
+                    MessagingUtils.errorDialog("Widget is disposed",
+                            null,
+                            MessagingUtils.WIDGET_IS_DISPOSED_MESSAGE,
+                            null,
+                            e,
+                            true);
+
+                }
+               }
         }
     }