Issue #1353 Changes for non-blocking FFMPSplash and LoadSaveConfigDlg dialogs.

Change-Id: Ie8589daa43e45a83835d119bdecc1674c7104ed0

Former-commit-id: 0c83b2a277 [formerly 0c83b2a277 [formerly c243a7bdb065db53dee2a01b251e5fbc5f1ec23e]]
Former-commit-id: 3cb0385a93
Former-commit-id: b6ae15b04e
This commit is contained in:
Roger Ferrel 2012-12-07 10:46:14 -06:00
parent d455c023a6
commit b4d43d2d1e
5 changed files with 185 additions and 135 deletions

View file

@ -87,6 +87,7 @@ import com.raytheon.uf.viz.monitor.listeners.IMonitorListener;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 04/03/10 4494 D. Hladky Initial release
* 12/07/12 1353 rferrel Changes for non-blocking FFMPSplash.
*
* </pre>
*
@ -150,6 +151,11 @@ public class FFMPMonitor extends ResourceMonitor {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(FFMPMonitor.class);
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.monitor.ResourceMonitor#nullifyMonitor()
*/
@Override
public void nullifyMonitor() {
@ -193,11 +199,25 @@ public class FFMPMonitor extends ResourceMonitor {
System.gc();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.monitor.ResourceMonitor#thresholdUpdate(com.raytheon
* .uf.viz.monitor.events.IMonitorThresholdEvent)
*/
@Override
public void thresholdUpdate(IMonitorThresholdEvent me) {
// TODO Auto-generated method stub
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.monitor.ResourceMonitor#configUpdate(com.raytheon
* .uf.viz.monitor.events.IMonitorConfigurationEvent)
*/
@Override
public void configUpdate(IMonitorConfigurationEvent me) {
// updates the config
@ -390,7 +410,8 @@ public class FFMPMonitor extends ResourceMonitor {
if (source != null) {
boolean dupOverride = false;
if (getSourceConfig().getSource(source).getSourceType().equals(SOURCE_TYPE.GUIDANCE.getSourceType())) {
if (getSourceConfig().getSource(source).getSourceType()
.equals(SOURCE_TYPE.GUIDANCE.getSourceType())) {
dupOverride = true;
}
@ -525,7 +546,8 @@ public class FFMPMonitor extends ResourceMonitor {
SourceXML sourceXML = fscm.getSource(fsource);
FFMPCacheRecord ffmpRec = populateFFMPRecord(true,
fdataUri, fsiteKey, fsource, fhuc);
//FFMPRecord ffmpRec = loadRecordFromDatabase(fdataUri);
// FFMPRecord ffmpRec =
// loadRecordFromDatabase(fdataUri);
File loc = HDF5Util.findHDF5Location(ffmpRec);
IDataStore dataStore = DataStoreFactory
.getDataStore(loc);
@ -545,7 +567,8 @@ public class FFMPMonitor extends ResourceMonitor {
ffmpRec.getSourceName(), fbasin);
}
} catch (Throwable e) {
statusHandler.handle(Priority.PROBLEM,
statusHandler
.handle(Priority.PROBLEM,
"FFMP Can't retrieve FFMP URI, "
+ fdataUri, e);
}
@ -648,9 +671,9 @@ public class FFMPMonitor extends ResourceMonitor {
sourceName);
SourceXML source = getSourceConfig().getSource(sourceName);
if (source.getSourceType().equals(
SOURCE_TYPE.GUIDANCE.getSourceType())) {
// Always look back for guidance types because of long expiration times,
if (source.getSourceType().equals(SOURCE_TYPE.GUIDANCE.getSourceType())) {
// Always look back for guidance types because of long expiration
// times,
// prevents mosaic brittleness from occurring.
retrieveNew = true;
}
@ -945,14 +968,16 @@ public class FFMPMonitor extends ResourceMonitor {
FFMPResourceData frd = resource.getResourceData();
if (loadType == LOADER_TYPE.SECONDARY) {
//hucsToLoad.remove("ALL");
//hucsToLoad.remove(getConfig().getFFMPConfigData().getLayer());
timeBack = new Date(resource.getMostRecentTime().getTime() - (6 * 1000 * 24));
// hucsToLoad.remove("ALL");
// hucsToLoad.remove(getConfig().getFFMPConfigData().getLayer());
timeBack = new Date(resource.getMostRecentTime().getTime()
- (6 * 1000 * 24));
frd.timeBack = timeBack;
} else if (loadType == LOADER_TYPE.TERTIARY) {
hucsToLoad.clear();
hucsToLoad.add("ALL");
timeBack = new Date(resource.getMostRecentTime().getTime() - (3600 * 1000 * 24));
timeBack = new Date(resource.getMostRecentTime().getTime()
- (3600 * 1000 * 24));
}
frd.floader = new FFMPDataLoader(frd, timeBack, startTime, loadType,
@ -974,6 +999,7 @@ public class FFMPMonitor extends ResourceMonitor {
if (ffmpSplash == null) {
ffmpSplash = new FFMPSplash(fshell);
ffmpSplash.open();
// latch
int count = 0;
while (!getTemplates(fsiteKey).done) {
@ -981,14 +1007,14 @@ public class FFMPMonitor extends ResourceMonitor {
try {
count++;
if (count == 50) {
ffmpSplash.disposeDialog();
ffmpSplash.close();
break;
}
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
if (ffmpSplash != null) {
ffmpSplash.disposeDialog();
ffmpSplash.close();
}
}
}
@ -1042,7 +1068,7 @@ public class FFMPMonitor extends ResourceMonitor {
}
});
} else {
resource.basinTableDlg.getShell().setActive();
resource.basinTableDlg.open();
}
}
@ -1060,7 +1086,7 @@ public class FFMPMonitor extends ResourceMonitor {
public synchronized void splashDisposeAndDataLoad(FFMPResource resource) {
if (ffmpSplash != null) {
ffmpSplash.disposeDialog();
ffmpSplash.close();
ffmpSplash = null;
if (resource.isFirst) {
@ -1080,7 +1106,7 @@ public class FFMPMonitor extends ResourceMonitor {
public void forceKillFFMPSplash() {
if (ffmpSplash != null) {
ffmpSplash.disposeDialog();
ffmpSplash.close();
ffmpSplash = null;
}
}
@ -1124,7 +1150,8 @@ public class FFMPMonitor extends ResourceMonitor {
int val = siteCount.get(res.getSiteKey());
// clear out the cache
for (Entry<String, FFMPCacheRecord> entry: ffmpData.get(res.getSiteKey()).entrySet()){
for (Entry<String, FFMPCacheRecord> entry : ffmpData.get(
res.getSiteKey()).entrySet()) {
entry.getValue().closeCache();
}
@ -2121,15 +2148,8 @@ public class FFMPMonitor extends ResourceMonitor {
// based on "duration". A horizontal line (composed of two
// points) will be drawn to represent the precip during
// each "duration" period.
if ((secondsL < 0) || (secondsR > t1.getTime() / 1000)) { // gage
// data
// ahead
// of
// or
// beyond
// radar
// time
// range
if ((secondsL < 0) || (secondsR > t1.getTime() / 1000)) {
// gage data ahead of or beyond radar time range
continue;
} else {
gageAccu += (Float) data1Dur.get(i)[5];
@ -2378,7 +2398,8 @@ public class FFMPMonitor extends ResourceMonitor {
curRecord = ffmpData.get(fsiteKey).get(mySource);
if (curRecord == null) {
curRecord = new FFMPCacheRecord(fffmpRec,
mySource, getRunConfig().getRunner(wfo).getCacheDir());
mySource, getRunConfig().getRunner(wfo)
.getCacheDir());
ffmpData.get(fsiteKey).put(mySource, curRecord);
}
}
@ -2409,7 +2430,8 @@ public class FFMPMonitor extends ResourceMonitor {
"Retrieving and Populating URI: , "
+ dataUri);
curRecord.retrieveMapFromDataStore(dataStore,
dataUri, getTemplates(fffmpRec.getSiteKey()), fhuc,
dataUri,
getTemplates(fffmpRec.getSiteKey()), fhuc,
fffmpRec.getDataTime().getRefTime(),
fffmpRec.getSourceName());
} catch (Exception e) {

View file

@ -31,20 +31,32 @@ import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
public class FFMPSplash extends Dialog {
/**
* Dialog shell.
/**
* Display FFMP Basin Table's splash page dialog.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Initial creation
* Dec 7, 2012 1353 rferrel Covert to CaveSWTDialog and make non-blocking.
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
private Shell shell;
public class FFMPSplash extends CaveSWTDialog {
/**
* The display control.
*/
@ -70,20 +82,19 @@ public class FFMPSplash extends Dialog {
private Image loadImage = null;
public FFMPSplash(Shell parent) {
super(parent, 0);
open();
super(parent, SWT.NO_TRIM | SWT.ON_TOP, CAVE.DO_NOT_BLOCK);
}
/**
* Open method to show the dialog.
/*
* (non-Javadoc)
*
* @return Null.
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
public Object open() {
Shell parent = getParent();
display = parent.getDisplay();
shell = new Shell(parent, SWT.NO_TRIM | SWT.ON_TOP);
@Override
protected void initializeComponents(Shell shell) {
display = shell.getDisplay();
// Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, false);
@ -93,14 +104,17 @@ public class FFMPSplash extends Dialog {
// Initialize all of the controls and layouts
initializeComponents();
}
shell.pack();
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
*/
@Override
protected void preOpened() {
super.preOpened();
centerOnScreen();
shell.setVisible(true);
return null;
}
private void initializeComponents() {
@ -185,11 +199,15 @@ public class FFMPSplash extends Dialog {
return path;
}
public void disposeDialog() {
if (shell != null) {
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
*/
@Override
protected void disposed() {
textFont.dispose();
loadImage.dispose();
shell.dispose();
}
}
}

View file

@ -86,6 +86,7 @@ import com.raytheon.uf.viz.monitor.ffmp.ui.rsc.FFMPTableDataLoader;
import com.raytheon.uf.viz.monitor.ffmp.ui.rsc.FFMPTableDataUpdate;
import com.raytheon.uf.viz.monitor.listeners.IMonitorListener;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
import com.raytheon.viz.ui.dialogs.ICloseCallback;
/**
* Main FFMP dialog.
@ -102,6 +103,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* ColorCell is true.
* Dec 06, 2012 1353 rferrel Code clean up.
* Changes for non-blocking AttributesDlg.
* Changes for non-blocking AttributeThresholdDlg.
* Changes for non-blocking LoadSaveConfigDlg.
*
* </pre>
*
@ -115,6 +118,10 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(FfmpBasinTableDlg.class);
private LoadSaveConfigDlg loadDlg;
private LoadSaveConfigDlg saveDlg;
private List<FFMPTableDataLoader> retrievalQueue = new ArrayList<FFMPTableDataLoader>();
private MenuItem linkToFrameMI;
@ -1714,37 +1721,48 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
}
private void retrieveConfiguration() {
if (loadDlg == null) {
LoadSaveConfigDlg loadDlg = new LoadSaveConfigDlg(shell,
DialogType.OPEN);
LocalizationFile fileName = (LocalizationFile) loadDlg.open();
if (fileName == null) {
return;
}
loadDlg = new LoadSaveConfigDlg(shell, DialogType.OPEN);
loadDlg.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
if (returnValue instanceof LocalizationFile) {
LocalizationFile fileName = (LocalizationFile) returnValue;
ffmpConfig.loadNewConfig(fileName);
refreshDisplay(false);
} else {
shell.setCursor(null);
}
loadDlg = null;
}
});
}
loadDlg.open();
}
private void saveConfiguration() {
LoadSaveConfigDlg saveDlg = new LoadSaveConfigDlg(shell,
DialogType.SAVE_AS);
LocalizationFile fileName = (LocalizationFile) saveDlg.open();
if (saveDlg == null) {
if (fileName == null) {
return;
}
if (fileName.getFile().getParentFile().mkdirs() == false) {
System.out.println("Did not not create directory(ies): "
+ fileName.toString());
}
saveDlg = new LoadSaveConfigDlg(shell, DialogType.SAVE_AS);
saveDlg.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
if (returnValue instanceof LocalizationFile) {
LocalizationFile fileName = (LocalizationFile) returnValue;
fileName.getFile().getParentFile().mkdirs();
ffmpConfig.saveFFMPBasinConfig(fileName);
}
saveDlg = null;
}
});
}
saveDlg.open();
}
/**
* Refresh the display with the new configuration changes.

View file

@ -47,10 +47,37 @@ import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
* Display FFMP Basin Table's Load/Save dialog.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Initial creation
* Dec 6, 2012 1353 rferrel Make dialog non-blocking.
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class LoadSaveConfigDlg extends CaveSWTDialog {
public static enum DialogType {
OPEN, SAVE_AS
OPEN("Load Configuration"), SAVE_AS("Save Configuration");
private final String title;
public String getTitle() {
return title;
}
DialogType(String title) {
this.title = title;
}
};
private final DialogType dialogType;
@ -59,8 +86,6 @@ public class LoadSaveConfigDlg extends CaveSWTDialog {
private List cfgFileList;
private LocalizationFile selectedFile;
private LocalizationFile[] locFiles;
private TreeMap<String, LocalizationFile> locFileMap;
@ -73,16 +98,9 @@ public class LoadSaveConfigDlg extends CaveSWTDialog {
private Button userBtn;
// private String selectedFileName = null;
public LoadSaveConfigDlg(Shell parent, DialogType type) {
super(parent, SWT.TITLE);
if (type == DialogType.OPEN) {
setText("Load Configuration");
} else {
setText("Save Configuration");
}
super(parent, SWT.TITLE, CAVE.DO_NOT_BLOCK);
setText(type.getTitle());
dialogType = type;
}
@ -99,7 +117,6 @@ public class LoadSaveConfigDlg extends CaveSWTDialog {
@Override
protected void disposed() {
controlFont.dispose();
setReturnValue(selectedFile);
}
@Override
@ -237,8 +254,7 @@ public class LoadSaveConfigDlg extends CaveSWTDialog {
cancelBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
selectedFile = null;
shell.dispose();
close();
}
});
}
@ -246,8 +262,8 @@ public class LoadSaveConfigDlg extends CaveSWTDialog {
private void openAction() {
int selectedIndex = cfgFileList.getSelectionIndex();
String str = cfgFileList.getItem(selectedIndex);
selectedFile = locFileMap.get(str);
shell.dispose();
setReturnValue(locFileMap.get(str));
close();
}
private void saveAction() {
@ -261,10 +277,12 @@ public class LoadSaveConfigDlg extends CaveSWTDialog {
LocalizationContext context = pm.getContext(
LocalizationType.CAVE_STATIC, level);
String newFileName = "ffmp/guiConfig/" + fileName;
selectedFile = pm.getLocalizationFile(context, newFileName);
LocalizationFile selectedFile = pm.getLocalizationFile(context,
newFileName);
FFMPConfig.getInstance().saveFFMPBasinConfig(selectedFile);
shell.dispose();
setReturnValue(selectedFile);
close();
}
private boolean validateFileName() {
@ -287,27 +305,6 @@ public class LoadSaveConfigDlg extends CaveSWTDialog {
return false;
}
// String[] listItems = cfgFileList.getItems();
//
// for (String listItem : listItems) {
// int idx = listItem.lastIndexOf("/");
// String fn = listItem.substring(idx + 1);
//
// if (fn.compareTo(strBuf.toString()) == 0) {
// if (listItem.compareTo(strBuf.toString()) == 0) {
// MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.YES
// | SWT.NO);
// mb.setText("Warning");
// mb.setMessage("File name already exists. Do you wish to overwrite\n"
// + "the existing file?.");
// int result = mb.open();
//
// if (result == SWT.NO) {
// return false;
// }
// }
// }
if (strBuf.toString().endsWith(".xml") == false) {
strBuf.append(".xml");
newFileNameTF.setText(strBuf.toString().trim());
@ -330,8 +327,6 @@ public class LoadSaveConfigDlg extends CaveSWTDialog {
locFiles = pm.listFiles(contextList
.toArray(new LocalizationContext[contextList.size()]),
"ffmp/guiConfig", extensions, false, true);
// locFiles = PathManagerFactory.getPathManager().listStaticFiles(
// "ffmp/guiConfig", extensions, true, true);
if (locFiles == null) {
return;
@ -350,8 +345,4 @@ public class LoadSaveConfigDlg extends CaveSWTDialog {
cfgFileList.setSelection(0);
}
}
public LocalizationFile getSelectedFile() {
return selectedFile;
}
}

View file

@ -151,6 +151,7 @@ import com.vividsolutions.jts.geom.Point;
* 11 Apr. 2012 DR 14522 gzhang Fixing invalid thread error.
* 31 July 2012 14517 mpduff Fix for blanking map on update.
* 14 Sep 2012 1048 njensen Code cleanup
* 07 Dec 2012 1353 rferrel Changes for non-blocking FFMPSplash dialog.
*
* </pre>
*
@ -1225,7 +1226,7 @@ public class FFMPResource extends
}
} else {
if (getResourceData().getMonitor().ffmpSplash != null) {
getResourceData().getMonitor().ffmpSplash.disposeDialog();
getResourceData().getMonitor().ffmpSplash.close();
getResourceData().getMonitor().ffmpSplash = null;
}
}