Issue #1214 Made VizGlobalsManager check for null window before calling getPage() since getInstance() still returns succesfully when null window is passed in. Change TimeMatchingJob to be shutdown when core plugin stops and cancels existing jobs.

Amend: Removed println

Change-Id: I3559b13074eb025e9bf931685cda3e804037baff

Former-commit-id: 8a9ba0178b [formerly 51e565c6ff] [formerly 4b2467e639] [formerly edfd7fd22f [formerly 4b2467e639 [formerly fc617c1392d9585d2e91e371af74aad4b24acfbb]]]
Former-commit-id: edfd7fd22f
Former-commit-id: 6c26ac1dfaab3d2a090ad759e28fbd78f175087c [formerly 63c30eafc2]
Former-commit-id: f0376e0240
This commit is contained in:
Max Schenkelberg 2012-09-24 14:42:32 -05:00
parent f9bdb1a3fa
commit 2eaaa36856
2 changed files with 44 additions and 13 deletions

View file

@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
@ -163,9 +164,13 @@ public class VizGlobalsManager {
*/ */
public void updateUI(IDisplayPaneContainer editor, public void updateUI(IDisplayPaneContainer editor,
IRenderableDisplay display) { IRenderableDisplay display) {
if (window.getActivePage().getActiveEditor() != editor) { if (window != null) {
// Check the active editor on the window
IWorkbenchPage page = window.getActivePage();
if (page != null && page.getActiveEditor() != editor) {
return; return;
} }
}
if (editor != null && display != null) { if (editor != null && display != null) {
Map<String, Object> globals = display.getGlobalsMap(); Map<String, Object> globals = display.getGlobalsMap();
LoopProperties props = editor.getLoopProperties(); LoopProperties props = editor.getLoopProperties();

View file

@ -27,6 +27,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.services.IDisposable;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
@ -57,6 +58,17 @@ public class TimeMatchingJob extends Job {
private static final transient IUFStatusHandler statusHandler = UFStatus private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(TimeMatchingJob.class); .getHandler(TimeMatchingJob.class);
static {
Activator.getDefault().registerDisposable(new IDisposable() {
@Override
public void dispose() {
shutdown();
}
});
}
private static boolean running = true;
private static Map<IDescriptor, TimeMatchingJob> map = new ConcurrentHashMap<IDescriptor, TimeMatchingJob>(); private static Map<IDescriptor, TimeMatchingJob> map = new ConcurrentHashMap<IDescriptor, TimeMatchingJob>();
private IDescriptor request; private IDescriptor request;
@ -68,7 +80,11 @@ public class TimeMatchingJob extends Job {
this.request = desc; this.request = desc;
} }
public static synchronized void scheduleTimeMatch(IDescriptor desc) { public static void scheduleTimeMatch(IDescriptor desc) {
synchronized (TimeMatchingJob.class) {
if (running == false) {
return;
}
if (desc != null && desc.getTimeMatcher() != null) { if (desc != null && desc.getTimeMatcher() != null) {
TimeMatchingJob job = map.get(desc); TimeMatchingJob job = map.get(desc);
if (job == null) { if (job == null) {
@ -81,6 +97,17 @@ public class TimeMatchingJob extends Job {
job.schedule(); job.schedule();
} }
} }
}
private static void shutdown() {
synchronized (TimeMatchingJob.class) {
running = false;
}
for (TimeMatchingJob job : map.values()) {
job.cancel();
}
map.clear();
}
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -111,7 +138,6 @@ public class TimeMatchingJob extends Job {
} }
}); });
} }
} catch (Throwable e) { } catch (Throwable e) {
statusHandler.handle(Priority.CRITICAL, statusHandler.handle(Priority.CRITICAL,
"Error redoing time matching", e); "Error redoing time matching", e);