From 00f7c65d9fa10c845b5ca8a48e734f04514191e4 Mon Sep 17 00:00:00 2001 From: Uwe Stieber Date: Thu, 17 Oct 2013 15:58:35 +0200 Subject: Target Explorer: Fix auto-refresh in system monitor has no effect --- .../processes/core/model/runtime/RuntimeModel.java | 48 ++++++++++++++-------- 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core') diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/RuntimeModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/RuntimeModel.java index c8bc0c169..07c161af6 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/RuntimeModel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.core/src/org/eclipse/tcf/te/tcf/processes/core/model/runtime/RuntimeModel.java @@ -196,22 +196,13 @@ public final class RuntimeModel extends ContainerModelNode implements IRuntimeMo // Get the auto-refresh started if not yet scheduled if (interval != 0 && timer == null) { // Create the timer task to schedule - final TimerTask task = new TimerTask() { + TimerTask task = new TimerTask() { @Override public void run() { // Drop out of the interval has been set to 0 in the meanwhile if (RuntimeModel.this.interval == 0) return; - final TimerTask task = this; - // Refresh the model - RuntimeModel.this.getService(IModelRefreshService.class).refresh(new Callback() { - @Override - protected void internalDone(Object caller, IStatus status) { - // Re-schedule ourself if the interval is still > 0 - if (RuntimeModel.this.interval > 0 && timer != null) { - timer.schedule(task, RuntimeModel.this.interval); - } - } - }); + // Do the auto refresh + doAutoRefresh(); } }; @@ -236,14 +227,35 @@ public final class RuntimeModel extends ContainerModelNode implements IRuntimeMo return interval; } - protected void startAutoRefresh() { - - } - /** - * Stops the auto-refresh if scheduled. + * Execute the auto refresh of the model and reschedule until stopped. */ - protected void stopAutoRefresh() { + /* default */ void doAutoRefresh() { + Protocol.invokeLater(new Runnable() { + @Override + public void run() { + // Refresh the model + RuntimeModel.this.getService(IModelRefreshService.class).refresh(new Callback() { + @Override + protected void internalDone(Object caller, IStatus status) { + // Re-schedule ourself if the interval is still > 0 + if (RuntimeModel.this.interval > 0 && timer != null) { + // Create the timer task to schedule + TimerTask task = new TimerTask() { + @Override + public void run() { + // Drop out of the interval has been set to 0 in the meanwhile + if (RuntimeModel.this.interval == 0) return; + // Do the auto refresh + doAutoRefresh(); + } + }; + timer.schedule(task, RuntimeModel.this.interval); + } + } + }); + } + }); } } -- cgit v1.2.3