Issue #1298 Changes for WeatherPlogDialog found in testing of 1229 (part 2).

Change-Id: I86d06e37a791a8d73937d487a8f1c22cc23199b3

Former-commit-id: 520fa44d23 [formerly 1bc40b2daf [formerly 98d0d27124baa44bcbbdf6e9276aa1966e420207]]
Former-commit-id: 1bc40b2daf
Former-commit-id: 4b1c9a1d2c
This commit is contained in:
Roger Ferrel 2012-11-26 15:15:38 -06:00
parent bcaaf67e72
commit ffd2843b9f
2 changed files with 16 additions and 35 deletions

View file

@ -30,11 +30,6 @@ import jep.JepException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.PathManagerFactory;
@ -68,7 +63,7 @@ import com.raytheon.viz.aviation.monitor.AvnPyUtil;
*/
public class PythonCacheGuidanceJob extends
AbstractQueueJob<CacheGuidanceRequest> {
private static final transient IUFStatusHandler statusHandler = UFStatus
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(PythonCacheGuidanceJob.class);
/**
@ -116,14 +111,12 @@ public class PythonCacheGuidanceJob extends
*/
boolean suspendJob;
private boolean disposeSet;
/**
* Obtain the singleton instance of this class.
*
* @return pythonCacheJob
*/
public static PythonCacheGuidanceJob getInstance() {
public static synchronized PythonCacheGuidanceJob getInstance() {
if (instance == null) {
instance = new PythonCacheGuidanceJob(
"AvnFPS Cache Python Guidance");
@ -131,14 +124,19 @@ public class PythonCacheGuidanceJob extends
instance.schedule();
}
// Only setup dispose listener first time on the UI thread.
if (instance.disposeSet == false && Display.getCurrent() != null) {
instance.setupDispose();
instance.disposeSet = true;
}
return instance;
}
/**
* Shutdown and remove instance of this class.
*/
public static synchronized void dispose() {
if (instance != null) {
instance.shutdown();
instance = null;
}
}
/**
* A private constructor to force singleton.
*
@ -151,7 +149,6 @@ public class PythonCacheGuidanceJob extends
suspendMonitor = new Object();
suspendJob = false;
waitList = new ArrayList<CacheGuidanceRequest>();
disposeSet = false;
}
/**
@ -177,7 +174,6 @@ public class PythonCacheGuidanceJob extends
private void shutdown() {
shutdown = true;
restart();
instance = null;
}
/**
@ -199,22 +195,6 @@ public class PythonCacheGuidanceJob extends
}
}
/**
* Setup listener to clean up the instance of this class and any threads it
* is running.
*/
private void setupDispose() {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
shell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
shutdown();
}
});
}
/**
* A request some thread is waiting for the results to be cached.
*

View file

@ -53,6 +53,7 @@ import org.eclipse.ui.actions.ActionFactory;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.viz.alerts.observers.ProductAlertObserver;
import com.raytheon.viz.aviation.cachedata.PythonCacheGuidanceJob;
import com.raytheon.viz.aviation.climatology.ClimateMenuDlg;
import com.raytheon.viz.aviation.climatology.WeatherPlotDialog;
import com.raytheon.viz.aviation.editor.ITafSettable;
@ -139,6 +140,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* 10/11/2012 1229 jkorman Changes for BackupDialog to support non-blocking.
* 10/11/2012 1229 rferrel Changes for non-blocking TafViewerEditorDlg.
* 10/15/2012 1229 rferrel Changes for non-blocking HelpUsageDlg.
* 11/26/2012 1298 rferrel Non-blocking dialog cleanup.
* </pre>
*
* @author grichard
@ -892,9 +894,8 @@ public class TafMonitorDlg extends CaveSWTDialog {
}
tveDlg.disposeDialog();
// shell.dispose();
close();
return true;
PythonCacheGuidanceJob.dispose();
return close();
}
private void populateStationsOfInterest() {