Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Besedin2012-01-31 14:49:32 +0000
committerOleg Besedin2012-01-31 14:49:32 +0000
commit06e81ee79961cf2de46c734ea4924bea432584ac (patch)
tree29cdc8c4778b7116448d8009db3bd654b8315cb6
parentc16b5b5c925ca5d739df3f29ec134e8eb8f3d0b0 (diff)
downloadeclipse.platform.runtime-06e81ee79961cf2de46c734ea4924bea432584ac.tar.gz
eclipse.platform.runtime-06e81ee79961cf2de46c734ea4924bea432584ac.tar.xz
eclipse.platform.runtime-06e81ee79961cf2de46c734ea4924bea432584ac.zip
Bug 370219 - Selection service could use an ability to pause dependencyv20120131-1449I20120202-0615I20120131-2200
recording
-rw-r--r--bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/RunAndTrack.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/RunAndTrack.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/RunAndTrack.java
index 791ae1e53..3022a34ec 100644
--- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/RunAndTrack.java
+++ b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/contexts/RunAndTrack.java
@@ -10,6 +10,10 @@
******************************************************************************/
package org.eclipse.e4.core.contexts;
+import java.util.Stack;
+import org.eclipse.e4.core.internal.contexts.Computation;
+import org.eclipse.e4.core.internal.contexts.EclipseContext;
+
/**
* Extended version of a runnable that can be used with the
* {@link IEclipseContext#runAndTrack(RunAndTrack)} version gets more detailed
@@ -17,6 +21,8 @@ package org.eclipse.e4.core.contexts;
*/
abstract public class RunAndTrack {
+ private boolean isRecordingPaused = false;
+
/**
* Creates a new instance of trackable computation
*/
@@ -35,4 +41,33 @@ abstract public class RunAndTrack {
* @return <code>true</code> to continue to be called on updates; <code>false</code> otherwise
*/
abstract public boolean changed(IEclipseContext context);
+
+ /**
+ * This method can be called to pause dependency recording while {@link #changed(IEclipseContext)}
+ * does its processing. This can be especially useful if external code
+ * has to be called. The method {@link #resumeRecoding()} must be called before RunAndTrack
+ * returns control to its caller.
+ */
+ synchronized protected void pauseRecording() {
+ if (isRecordingPaused)
+ return;
+ Stack<Computation> current = EclipseContext.getCalculatedComputations();
+ current.push(null);
+ isRecordingPaused = true;
+ }
+
+ /**
+ * Call this method to resume dependency recording previously paused by
+ * the {@link #pauseRecording()}.
+ */
+ synchronized protected void resumeRecoding() {
+ if (!isRecordingPaused)
+ return;
+ Stack<Computation> current = EclipseContext.getCalculatedComputations();
+ Computation plug = current.pop();
+ if (plug != null)
+ throw new IllegalArgumentException("Internal error in nested computation processing"); //$NON-NLS-1$
+ isRecordingPaused = false;
+ }
+
}

Back to the top