Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Cortell2009-07-13 18:53:22 +0000
committerJohn Cortell2009-07-13 18:53:22 +0000
commit02f13c474b40b0452a5c70fbb6b41b462b4004ed (patch)
treea3e3b0ae1111ff8d320c67080d349c20ec5bfd3d /dsf/org.eclipse.cdt.examples.dsf
parent7920146a21787f1d7caa97dd2c30b1a2e852f89d (diff)
downloadorg.eclipse.cdt-02f13c474b40b0452a5c70fbb6b41b462b4004ed.tar.gz
org.eclipse.cdt-02f13c474b40b0452a5c70fbb6b41b462b4004ed.tar.xz
org.eclipse.cdt-02f13c474b40b0452a5c70fbb6b41b462b4004ed.zip
Fixed 283333; View doesn't update when user makes model change
Diffstat (limited to 'dsf/org.eclipse.cdt.examples.dsf')
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/timers/TimersVMProvider.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/dsf/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/timers/TimersVMProvider.java b/dsf/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/timers/TimersVMProvider.java
index e44c122d7d..6a535983b7 100644
--- a/dsf/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/timers/TimersVMProvider.java
+++ b/dsf/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/timers/TimersVMProvider.java
@@ -42,12 +42,55 @@ public class TimersVMProvider extends AbstractDMVMProvider {
/** Enumeration of possible layouts for the timers view model */
public enum ViewLayout { TRIGGERS_AT_TOP, TIMERS_AT_TOP }
+ /** Have we registered ourselves as a listener for DM events? */
+ private boolean fRegisteredEventListener;
+
public TimersVMProvider(AbstractVMAdapter adapter, IPresentationContext presentationContext, DsfSession session) {
super(adapter, presentationContext, session);
+
+ // Add ourselves as listener for DM events events.
+ try {
+ session.getExecutor().execute(new Runnable() {
+ public void run() {
+ if (DsfSession.isSessionActive(getSession().getId())) {
+ getSession().addServiceEventListener(TimersVMProvider.this, null);
+ fRegisteredEventListener = true;
+ }
+ }
+ });
+ } catch (RejectedExecutionException e) {
+ // Session shut down, not much we can do but wait to be disposed.
+ }
+
// Set the initial view layout.
setViewLayout(ViewLayout.TIMERS_AT_TOP);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ // Remove ourselves as listener for DM events events. In practice, we
+ // get called after the session has shut down, so we'll end up with a
+ // RejectedExecutionException. We put this here all the same for
+ // completeness sake.
+ try {
+ getSession().getExecutor().execute(new Runnable() {
+ public void run() {
+ if (fRegisteredEventListener && DsfSession.isSessionActive(getSession().getId())) {
+ getSession().removeServiceEventListener(TimersVMProvider.this);
+ fRegisteredEventListener = false;
+ }
+ }
+ });
+ } catch (RejectedExecutionException e) {
+ // Session shut down, not much we can do but wait to be disposed.
+ }
+
+ super.dispose();
+ }
+
/**
* Configures a new layout for the timers view model.
* @param layout New layout to use.

Back to the top