Merge branch 'develop' into nameEditorE4
authorPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 31 Aug 2017 11:45:41 +0000 (13:45 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 31 Aug 2017 11:45:41 +0000 (13:45 +0200)
1  2 
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/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

index fdbc8843a1e80afb26a710b0bc1908208f6eac50,efb73c2bef706e108c4e1196a2c4ce61dba2e629..a73085aef51af6099fcc7bef128e773f84e7c7a5
@@@ -42,10 -47,76 +47,78 @@@ import eu.etaxonomy.taxeditor.workbench
  public abstract class AbstractCdmEditorPartE4
          implements IConversationEnabled, IDirtyMarkable, ISelectionElementEditingPart, IPostOperationEnabled{
  
+     private DelaySelection delaySelection = null;
+     /**
+      * This is the monitor for the DelaySelection runnable.
+      * If it is <code>true</code> then it is currently delaying a selection.
+      */
+     private boolean isInDelay;
+     /**
+      * This class invokes internal_selectionChanged() in a separate thread.
+      * This allows an asynchronous and/or delayed handling of selection changes
+      */
+     private class DelaySelection implements Runnable{
+         private Object selection;
+         private MPart activePart;
+         private MPart thisPart;
+         public DelaySelection(Object selection, MPart activePart, MPart thisPart) {
+             super();
+             this.selection = selection;
+             this.activePart= activePart;
+             this.thisPart = thisPart;
+         }
+         @Override
+         public void run() {
+             try{
+                 selectionChanged_internal(selection, activePart, thisPart);
+             }
+             finally{
+                 isInDelay = false;
+             }
+         }
+         public synchronized void setSelection(Object selection) {
+             this.selection = selection;
+         }
+         public synchronized void setActivePart(MPart activePart) {
+             this.activePart = activePart;
+         }
+         public synchronized void setThisPart(MPart thisPart) {
+             this.thisPart = thisPart;
+         }
+     }
+     protected abstract void selectionChanged_internal(Object selection, MPart activePart, MPart thisPart);
+     @Inject
+     @Optional
+     public void selectionChanged(
+             @Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
+             @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+             MPart thisPart){
+         if(delaySelection==null){
+             delaySelection = new DelaySelection(selection, activePart, thisPart);
+         }
+         delaySelection.setSelection(selection);
+         delaySelection.setActivePart(activePart);
+         delaySelection.setThisPart(thisPart);
+         if(!isInDelay){
+             isInDelay = true;
+             Display.getCurrent().asyncExec(delaySelection);
+         }
+     }
      protected Viewer viewer;
  
 +    protected MPart thisPart;
 +
      protected MPart selectionProvidingPart;
  
      /** {@inheritDoc} */
index 82ee522255fce350989eb62ec330c659bd1a471e,b9f10b6fe5866493ff481cbb61eae6e28bec82e7..2ebe1c6e02cd3a62d4b8d4676b97033982e51894
@@@ -48,19 -45,12 +45,15 @@@ public class SupplementalDataPartE4 ext
      }
  
        @PostConstruct
 -      public void create(Composite parent) {
 -              viewer = new SupplementalDataViewerE4(parent, this);
 +      public void create(Composite parent, MPart thisPart) {
 +
 +          this.thisPart = thisPart;
 +
 +          viewer = new SupplementalDataViewerE4(parent, this);
        }
  
-       @Inject
-       @Optional
-       protected void selectionChanged_internal(
-               @Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
-               @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
-               MPart thisPart) {
+     @Override
+     public void selectionChanged_internal(Object selection, MPart activePart, MPart thisPart) {
            if(activePart==thisPart){
                return;
            }