ref #10182: update details view when it gets the focus and there are changes
authorKatja Luther <k.luther@bgbm.org>
Thu, 5 Jan 2023 09:51:48 +0000 (10:51 +0100)
committerKatja Luther <k.luther@bgbm.org>
Thu, 5 Jan 2023 09:51:48 +0000 (10:51 +0100)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/TaxonEditor.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/event/WorkbenchEventConstants.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/details/DetailsViewerE4.java

index 2aea0cb08f6ab5e33245419a719f929467304909..0602aedade28f879e3d01f7e1d596b3fab7a9968 100644 (file)
@@ -396,6 +396,7 @@ public class TaxonEditor
         EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, new TaxonNodeDto(input.getTaxonNode().getParent()));
         EventUtility.postEvent(WorkbenchEventConstants.SAVE_TAXON, true);
         EventUtility.postAsyncEvent(WorkbenchEventConstants.REFRESH_DETAILS, true);
+//        EventUtility.postAsyncEvent(WorkbenchEventConstants.NEED_REFRESH_DETAILS, false);
         // Stop the progress monitor.
         monitor.done();
     }
index ca639868b7fccc81f21df210868d0c651dde1a77..f383bca889c629441f523c8203f98ef1e79a87cb 100644 (file)
@@ -58,6 +58,6 @@ public interface WorkbenchEventConstants {
     
     public static final String REFRESH_MATRIX = "REFRESH/MATRIX";
     
-    public static final String ENABLE_TAXON_DETAILS = "BLOCK/DETAILS/TAXON";
+    public static final String NEED_REFRESH_DETAILS = "BLOCK/DETAILS/TAXON";
 
 }
index 524b88d41b1d3ce8b216f421a819b9d1ecd36893..39f99dc8354ebdcabc37987158d89b70cd23e0b7 100644 (file)
@@ -31,6 +31,7 @@ import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
 import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.view.detail.CdmSectionPart;
 import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPart;
 import eu.etaxonomy.taxeditor.view.e4.supplementaldata.SupplementalDataPartE4;
 
@@ -59,8 +60,18 @@ public class DetailsPartE4 extends AbstractCdmEditorPart<DetailsViewerE4> implem
 
     @Override
     public void selectionChanged_internal(Object selection, MPart activePart, MPart thisPart) {
-        if (activePart == thisPart){
-            return;
+       if (activePart == null) {
+               return;
+       }
+       
+        if (activePart == thisPart ){
+               if (this.getViewer().isNeedsRefresh()) {
+                       viewer.refresh();
+                       viewer.setNeedsRefresh(false);
+                       return;
+               }else {
+                       return;
+               }
         }
         
        
@@ -106,7 +117,7 @@ public class DetailsPartE4 extends AbstractCdmEditorPart<DetailsViewerE4> implem
             viewer.setSelection(structuredSelection, false);
 
             showViewer(structuredSelection, activePart, viewer);
-
+            viewer.setNeedsRefresh(false);
             return;
         }
         else{
index a7c2ead25a9ecd6219a9c8067667a5dd78d4e8ad..f377bb3d149e4aecb8f78f11a3888caa87cf42c9 100755 (executable)
@@ -162,6 +162,8 @@ public class DetailsViewerE4 extends AbstractCdmDataViewer {
     private ISelection selection;
     private boolean detailsEnabled = true;
     private Object activePart;
+    
+    private boolean needsRefresh = false;
 
     public boolean isDetailsEnabled() {
                return detailsEnabled;
@@ -176,6 +178,14 @@ public class DetailsViewerE4 extends AbstractCdmDataViewer {
         setInput(input);
 
     }
+       
+       public boolean isNeedsRefresh() {
+               return needsRefresh;
+       }
+
+       public void setNeedsRefresh(boolean needsRefresh) {
+               this.needsRefresh = needsRefresh;
+       }
     // START HACK TO MAKE THE DERIVED UNIT FACADE WORK
     // since we are getting implementations of DerivedUnitBase from the bulk
     // editor and not derived unit facade objects,
@@ -987,16 +997,21 @@ public class DetailsViewerE4 extends AbstractCdmDataViewer {
     private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_DETAILS)boolean refresh){
         if(refresh){
                //refresh_withoutnew_build(); this would use the update without creation of all fields
-               refresh();
+               if (needsRefresh) {
+                       refresh();
+               }
+               this.needsRefresh = false;
         }
     }
     
     @Inject
     @Optional
-    private void blockView(@UIEventTopic(WorkbenchEventConstants.ENABLE_TAXON_DETAILS)boolean enable){
+    private void needsRefresh(@UIEventTopic(WorkbenchEventConstants.NEED_REFRESH_DETAILS)boolean enable){
        for (IFormPart part :this.managedForm.getParts()) {
           if (part instanceof CdmSectionPart) {
-                  ((CdmSectionPart)part).getSection().setEnabled(enable);
+                  //((CdmSectionPart)part).getSection().setEnabled(enable);
+                  this.setNeedsRefresh(!enable);
+                  
           }
        }
        
@@ -1020,4 +1035,6 @@ public class DetailsViewerE4 extends AbstractCdmDataViewer {
            }
         }
     }
+
+       
 }
\ No newline at end of file