Issue #1578 Code clean up for non-blocking dialogs.

Changes from code review.

Change-Id: I9f95dd07736f96af8cb1116030a9fb778fe4b047

Former-commit-id: e3c21436e1186e467daf071bb723a2c31d6d3579
This commit is contained in:
Roger Ferrel 2013-02-06 12:01:38 -06:00
parent cdafa71827
commit db818dfd35
4 changed files with 319 additions and 123 deletions

View file

@ -41,7 +41,7 @@ import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.viz.hydro.CaveHydroSWTDialog; import com.raytheon.viz.hydro.CaveHydroSWTDialog;
/** /**
* TODO Add Description * Dialog add remove distribution directories.
* *
* <pre> * <pre>
* *
@ -50,6 +50,7 @@ import com.raytheon.viz.hydro.CaveHydroSWTDialog;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Mar 28, 2011 mpduff Initial creation * Mar 28, 2011 mpduff Initial creation
* Feb 06, 2013 1578 rferrel Code cleanup for non-blocking dialog.
* *
* </pre> * </pre>
* *
@ -64,18 +65,25 @@ public class SendConfigDlg extends CaveHydroSWTDialog {
*/ */
private Font font; private Font font;
/** Manager for handling the shef xml data. */
private ShefIssueMgr shefIssueMgr; private ShefIssueMgr shefIssueMgr;
/** Distribute product check box. */
private Button distChk; private Button distChk;
/** Internal directory check box. */
private Button directoryChk; private Button directoryChk;
/** Button to bring up dialog to add a directory . */
private Button addBtn; private Button addBtn;
/** Button to remove selectted directory. */
private Button removeBtn; private Button removeBtn;
/** Button to remove all directories in the list. */
private Button removeAllBtn; private Button removeAllBtn;
/** List to display the directories. */
private List directoryList; private List directoryList;
/** /**
@ -105,12 +113,20 @@ public class SendConfigDlg extends CaveHydroSWTDialog {
initializeComponents(); initializeComponents();
} }
/**
* Setup layout of dialog.
*/
private void initializeComponents() { private void initializeComponents() {
createDistributionGroup(); createDistributionGroup();
createDirectoryGroup(); createDirectoryGroup();
createBottomButtons(); createBottomButtons();
} }
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
*/
@Override @Override
protected Layout constructShellLayout() { protected Layout constructShellLayout() {
// Create the main layout for the shell. // Create the main layout for the shell.
@ -122,7 +138,8 @@ public class SendConfigDlg extends CaveHydroSWTDialog {
} }
private void createDistributionGroup() { private void createDistributionGroup() {
String defSelection = AppsDefaults.getInstance().getToken("timeseries_dist_shef", "OFF"); String defSelection = AppsDefaults.getInstance().getToken(
"timeseries_dist_shef", "OFF");
boolean selected = true; boolean selected = true;
if (defSelection.equalsIgnoreCase("OFF")) { if (defSelection.equalsIgnoreCase("OFF")) {
selected = false; selected = false;
@ -193,10 +210,9 @@ public class SendConfigDlg extends CaveHydroSWTDialog {
addBtn.addSelectionListener(new SelectionAdapter() { addBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
System.out.println("Add Pressed");
DirectoryDialog fd = new DirectoryDialog(shell, SWT.OPEN); DirectoryDialog fd = new DirectoryDialog(shell, SWT.OPEN);
String dir = fd.open(); String dir = fd.open();
System.out.println("Selected " + dir); if (dir != null) {
directoryList.add(dir); directoryList.add(dir);
String[] items = directoryList.getItems(); String[] items = directoryList.getItems();
java.util.Arrays.sort(items); java.util.Arrays.sort(items);
@ -205,6 +221,7 @@ public class SendConfigDlg extends CaveHydroSWTDialog {
directoryList.add(s); directoryList.add(s);
} }
} }
}
}); });
gd = new GridData(buttonWidth, SWT.DEFAULT); gd = new GridData(buttonWidth, SWT.DEFAULT);
@ -236,6 +253,9 @@ public class SendConfigDlg extends CaveHydroSWTDialog {
}); });
} }
/**
* Layout the button at the bottom of the dialog.
*/
private void createBottomButtons() { private void createBottomButtons() {
Composite buttonComp = new Composite(shell, SWT.NONE); Composite buttonComp = new Composite(shell, SWT.NONE);
buttonComp.setLayout(new GridLayout(3, true)); buttonComp.setLayout(new GridLayout(3, true));
@ -275,7 +295,7 @@ public class SendConfigDlg extends CaveHydroSWTDialog {
cancelBtn.addSelectionListener(new SelectionAdapter() { cancelBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
shell.dispose(); close();
} }
}); });
} }
@ -309,6 +329,9 @@ public class SendConfigDlg extends CaveHydroSWTDialog {
activateDirectoryWidgets(); activateDirectoryWidgets();
} }
/**
* Save the changes based on dialog selections.
*/
private void applyChanges() { private void applyChanges() {
ShefIssueXML xml = this.shefIssueMgr.getShefIssueXml(); ShefIssueXML xml = this.shefIssueMgr.getShefIssueXml();
if (xml == null) { if (xml == null) {
@ -340,6 +363,9 @@ public class SendConfigDlg extends CaveHydroSWTDialog {
} }
} }
/**
* Set enable status of directory widgets.
*/
private void activateDirectoryWidgets() { private void activateDirectoryWidgets() {
boolean activate = directoryChk.getSelection(); boolean activate = directoryChk.getSelection();

View file

@ -40,6 +40,8 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.GC;
@ -122,6 +124,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Sep 09 2011 9962 lbousaidi reload time series when there is update/insert * Sep 09 2011 9962 lbousaidi reload time series when there is update/insert
* and highlight the row that was updated. * and highlight the row that was updated.
* Feb 05,2013 1578 rferrel Changes for non-blocking singleton TimeSeriesDlg. * Feb 05,2013 1578 rferrel Changes for non-blocking singleton TimeSeriesDlg.
* Code clean up for non-blocking dialog.
* *
* </pre> * </pre>
* *
@ -134,30 +137,46 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
private final IUFStatusHandler statusHandler = UFStatus private final IUFStatusHandler statusHandler = UFStatus
.getHandler(TabularTimeSeriesDlg.class); .getHandler(TabularTimeSeriesDlg.class);
/** Location and size to use when opening a new dialog. */
private static Rectangle bounds;
/** Line terminator to use when reading a line from a shef file. */
private final String CARRIAGECONTROL = "\r"; private final String CARRIAGECONTROL = "\r";
/** Maximum number time series to place in a list. */
private final int MAX_TS_ON_LIST = 120; private final int MAX_TS_ON_LIST = 120;
/** Default header label */
private final String HDRDEFAULT = " Value Time(Z) RV SQ QC Product Time Posted"; private final String HDRDEFAULT = " Value Time(Z) RV SQ QC Product Time Posted";
/** Stage header label.. */
private final String HDRSTAGE = " Value Flow Time(Z) RV SQ QC Product Time Posted"; private final String HDRSTAGE = " Value Flow Time(Z) RV SQ QC Product Time Posted";
/** Flow header label. */
private final String HDRFLOW = " Value Stage Time(Z) RV SQ QC Product Time Posted"; private final String HDRFLOW = " Value Stage Time(Z) RV SQ QC Product Time Posted";
/** Quality control value for manual "Good" */
private final int QC_MANUAL_PASSED = 121; private final int QC_MANUAL_PASSED = 121;
/** Quality control value for manual "Quest". */
private final int QC_MANUAL_QUEST = 122; private final int QC_MANUAL_QUEST = 122;
/** Quality control value for manue "Bad". */
private final int QC_MANUAL_FAILED = 123; private final int QC_MANUAL_FAILED = 123;
/** Value used for undefined type source. */
private final String UNDEFINED_TYPESOURCE = "??"; private final String UNDEFINED_TYPESOURCE = "??";
/** Default value or product ID. */
private final String INSERT_PROD_ID = "CCCCWRKXXX"; private final String INSERT_PROD_ID = "CCCCWRKXXX";
/** The base for all shel file names. */
private final String SHEF_FILE_NAME = "shef_product"; private final String SHEF_FILE_NAME = "shef_product";
/** Message title to use when invalid product ID error message. */
private final String INVALID_PRODUCT_ID = "Invalid Product ID"; private final String INVALID_PRODUCT_ID = "Invalid Product ID";
/** the Send configuration dialog. */
private SendConfigDlg sendConfigDlg; private SendConfigDlg sendConfigDlg;
/** /**
@ -176,8 +195,10 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
private SimpleDateFormat prodBasisFmt = new SimpleDateFormat( private SimpleDateFormat prodBasisFmt = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss"); "yyyy-MM-dd HH:mm:ss");
/** Date format for shef information. */
private SimpleDateFormat shefDateFormat = new SimpleDateFormat("yyyyMMdd"); private SimpleDateFormat shefDateFormat = new SimpleDateFormat("yyyyMMdd");
/** Time format for shef information. */
private SimpleDateFormat shefTimeFormat = new SimpleDateFormat("HHmm"); private SimpleDateFormat shefTimeFormat = new SimpleDateFormat("HHmm");
/** /**
@ -234,7 +255,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
private Label headerLbl; private Label headerLbl;
/** /**
* TODO: need to replace this with a real time object. * Dummy time to use; based on the simulated time.
*/ */
private Calendar dummyTime; private Calendar dummyTime;
@ -389,6 +410,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
/** Date format for the database */ /** Date format for the database */
private static SimpleDateFormat dbFormat; private static SimpleDateFormat dbFormat;
/* Setup the format static variables. */
static { static {
tabularFormat = new SimpleDateFormat("MM/dd HH:mm"); tabularFormat = new SimpleDateFormat("MM/dd HH:mm");
tabularFormat.setTimeZone(TimeZone.getTimeZone("GMT")); tabularFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
@ -412,24 +434,38 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
/** SHEF broadcast filename */ /** SHEF broadcast filename */
String attachedFilename = null; String attachedFilename = null;
/* Vars used in the printing methods */ /** Printer to use. */
private Printer printer; private Printer printer;
/** Printer's line height. */
private int lineHeight = 0; private int lineHeight = 0;
/** Printer's tab width. */
private int tabWidth = 0; private int tabWidth = 0;
/** Printer's left margin. */
private int leftMargin; private int leftMargin;
/** Printer's right margin. */
private int rightMargin; private int rightMargin;
/** Printer's top margin. */
private int topMargin; private int topMargin;
/** Printer's bottom margin. */
private int bottomMargin; private int bottomMargin;
private int x, y; /** Printer's horizontal location for printing. */
private int x;
private int index, end; /** Printer's vertical location for printing. */
private int y;
/** Location in the text that is being printed. */
private int index;
/** Number of characters in the text being printed. */
private int end;
private StringBuffer wordBuffer; private StringBuffer wordBuffer;
@ -475,6 +511,11 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
this.tsDataJobManager = new TimeSeriesDataJobManager(); this.tsDataJobManager = new TimeSeriesDataJobManager();
} }
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
*/
@Override @Override
protected Layout constructShellLayout() { protected Layout constructShellLayout() {
// Create the main layout for the shell. // Create the main layout for the shell.
@ -503,7 +544,31 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
} }
} }
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
*/
@Override
protected void preOpened() {
super.preOpened();
shell.addShellListener(new ShellAdapter() {
@Override
public void shellClosed(ShellEvent event) {
bounds = shell.getBounds();
}
});
if (bounds != null) {
shell.setBounds(bounds);
}
}
/**
* Set up to retrieve selection data.
*/
private void scheduleDataRetrieval() { private void scheduleDataRetrieval() {
shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
this.topDataList.setEnabled(false); this.topDataList.setEnabled(false);
String selection = this.extractFormInformation(); String selection = this.extractFormInformation();
tsDataJobManager.scheduleGetTableData(this, this, selection); tsDataJobManager.scheduleGetTableData(this, this, selection);
@ -1055,7 +1120,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
closeBtn.addSelectionListener(new SelectionAdapter() { closeBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
close(); disposeDialog();
} }
}); });
} }
@ -1203,12 +1268,17 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
scheduleDataRetrieval(); scheduleDataRetrieval();
} catch (VizException ve) { } catch (VizException ve) {
ve.printStackTrace(); statusHandler.handle(Priority.PROBLEM, "Time Series Load", ve);
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
ex.printStackTrace(); statusHandler.handle(Priority.PROBLEM, "Time Series Load", ex);
} }
} }
/**
* Get table data for the selection.
*
* @param selection
*/
public void getDataForTable(String selection) { public void getDataForTable(String selection) {
TimeSeriesDataManager dataManager = TimeSeriesDataManager.getInstance(); TimeSeriesDataManager dataManager = TimeSeriesDataManager.getInstance();
@ -1240,9 +1310,9 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
ts, dur, ext, beginningTime, endingTime, basisTime, ts, dur, ext, beginningTime, endingTime, basisTime,
forecast); forecast);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
e.printStackTrace(); statusHandler.handle(Priority.PROBLEM, "Getting Table Data: ", e);
} catch (VizException e) { } catch (VizException e) {
e.printStackTrace(); statusHandler.handle(Priority.PROBLEM, "Getting Table Data: ", e);
} }
} }
@ -1389,6 +1459,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
} }
} }
shell.setCursor(null);
this.topDataList.setEnabled(true); this.topDataList.setEnabled(true);
this.parentDialog.enableTableButton(); this.parentDialog.enableTableButton();
this.parentDialog.enableBothButton(); this.parentDialog.enableBothButton();
@ -1491,8 +1562,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
Date defaultDate = dbFormat.parse(productTimeLbl.getText()); Date defaultDate = dbFormat.parse(productTimeLbl.getText());
dr.setProductTime(defaultDate); dr.setProductTime(defaultDate);
} catch (ParseException e) { } catch (ParseException e) {
// TODO Auto-generated catch block statusHandler.error("Parse Error", e);
e.printStackTrace();
} }
} }
@ -1513,8 +1583,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
dr.setProductId(INSERT_PROD_ID); dr.setProductId(INSERT_PROD_ID);
} catch (ParseException e) { } catch (ParseException e) {
// TODO Auto-generated catch block statusHandler.handle(Priority.PROBLEM, "Parse Error: " + e);
e.printStackTrace();
} }
} }
@ -1561,8 +1630,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
scheduleDataRetrieval(); scheduleDataRetrieval();
} catch (VizException e) { } catch (VizException e) {
// TODO Auto-generated catch block statusHandler.handle(Priority.PROBLEM, "", e);
e.printStackTrace();
} }
} }
@ -1636,7 +1704,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
dr.setProductTime(newDateTime); dr.setProductTime(newDateTime);
dr.setBasisTime(newDefaultTime); dr.setBasisTime(newDefaultTime);
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); statusHandler.handle(Priority.PROBLEM, "Parse error: ", e);
} }
newDateTime = now; newDateTime = now;
@ -1660,8 +1728,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
dr.setProductId(INSERT_PROD_ID); dr.setProductId(INSERT_PROD_ID);
} catch (ParseException e) { } catch (ParseException e) {
// TODO Auto-generated catch block statusHandler.handle(Priority.PROBLEM, "Parse error: ", e);
e.printStackTrace();
} }
} }
@ -1749,8 +1816,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
} }
} catch (VizException e) { } catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, "Data Query:" statusHandler.handle(Priority.PROBLEM, "Data Query:"
+ " Error inserting forecast data."); + " Error inserting forecast data.", e);
e.printStackTrace();
} }
/* call Load Max Forecast if update or insert of H or Q PE's */ /* call Load Max Forecast if update or insert of H or Q PE's */
@ -1759,9 +1825,8 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
try { try {
LoadMaxFcst.loadMaxFcstItem(lid, pe, ts); LoadMaxFcst.loadMaxFcstItem(lid, pe, ts);
} catch (VizException e) { } catch (VizException e) {
e.printStackTrace();
statusHandler.handle(Priority.PROBLEM, "Data Query:" statusHandler.handle(Priority.PROBLEM, "Data Query:"
+ " Error inserting max forecast record."); + " Error inserting max forecast record.", e);
} }
} }
} // end if fcst } // end if fcst
@ -2116,7 +2181,8 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
throw new VizException("Error Updating QC value"); throw new VizException("Error Updating QC value");
} }
} catch (VizException e) { } catch (VizException e) {
e.printStackTrace(); statusHandler.handle(Priority.PROBLEM,
"Updating QC value: ", e);
} }
} }
@ -2150,8 +2216,8 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
status = dataManager.insertRejectedData(dr); status = dataManager.insertRejectedData(dr);
} }
} catch (VizException e) { } catch (VizException e) {
// TODO Auto-generated catch block statusHandler.handle(Priority.PROBLEM,
e.printStackTrace(); "Inserted Rejected Data: ", e);
} }
} }
@ -2202,8 +2268,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
out.write(text); out.write(text);
out.close(); out.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); statusHandler.handle(Priority.PROBLEM, "Saving Table: ", e);
// TODO Log error here
} }
} }
@ -2250,24 +2315,16 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
Rectangle clientArea = printer.getClientArea(); Rectangle clientArea = printer.getClientArea();
Rectangle trim = printer.computeTrim(0, 0, 0, 0); Rectangle trim = printer.computeTrim(0, 0, 0, 0);
Point dpi = printer.getDPI(); Point dpi = printer.getDPI();
leftMargin = dpi.x + trim.x; // one inch from left side of paper // one inch from left side of paper
rightMargin = clientArea.width - dpi.x + trim.x + trim.width; // one leftMargin = dpi.x + trim.x;
// inch // one inch from right side of paper
// from rightMargin = clientArea.width - dpi.x + trim.x + trim.width;
// right // one inch from top edge of paper
// side topMargin = dpi.y + trim.y;
// of // one inch from bottom edge of paper
// paper bottomMargin = clientArea.height - dpi.y + trim.y + trim.height;
topMargin = dpi.y + trim.y; // one inch from top edge of paper
bottomMargin = clientArea.height - dpi.y + trim.y + trim.height; // one
// inch
// from
// bottom
// edge
// of
// paper
/* Create a buffer for computing tab width. */ // Create a buffer for computing tab width.
int tabSize = 4; // is tab width a user setting in your UI? int tabSize = 4; // is tab width a user setting in your UI?
StringBuffer tabBuffer = new StringBuffer(tabSize); StringBuffer tabBuffer = new StringBuffer(tabSize);
for (int i = 0; i < tabSize; i++) { for (int i = 0; i < tabSize; i++) {
@ -2435,8 +2492,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
return sb.toString(); return sb.toString();
} catch (VizException e) { } catch (VizException e) {
e.printStackTrace(); statusHandler.handle(Priority.PROBLEM, "", e);
// TODO log error message
} }
return null; return null;
} }
@ -2481,6 +2537,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
if (y + lineHeight <= bottomMargin) { if (y + lineHeight <= bottomMargin) {
printer.endPage(); printer.endPage();
} }
wordBuffer = null;
} }
/** /**
@ -2491,12 +2548,12 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
String word = wordBuffer.toString(); String word = wordBuffer.toString();
int wordWidth = gc.stringExtent(word).x; int wordWidth = gc.stringExtent(word).x;
if (x + wordWidth > rightMargin) { if (x + wordWidth > rightMargin) {
/* word doesn't fit on current line, so wrap */ // word doesn't fit on current line, so wrap
newline(); newline();
} }
gc.drawString(word, x, y, false); gc.drawString(word, x, y, false);
x += wordWidth; x += wordWidth;
wordBuffer = new StringBuffer(); wordBuffer.setLength(0);
} }
} }
@ -2606,7 +2663,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
siteLabel = selectedLid; siteLabel = selectedLid;
} }
} catch (VizException e) { } catch (VizException e) {
e.printStackTrace(); statusHandler.handle(Priority.INFO, "Uable to get site: ", e);
siteLabel = selectedLid; siteLabel = selectedLid;
} }
@ -2631,6 +2688,9 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
} }
/**
* Update the flood stage label based on selection.
*/
private void updateFloodStageLabel() { private void updateFloodStageLabel() {
TimeSeriesDataManager dataManager = TimeSeriesDataManager.getInstance(); TimeSeriesDataManager dataManager = TimeSeriesDataManager.getInstance();
String selection = topDataList.getItem(topDataList.getSelectionIndex()); String selection = topDataList.getItem(topDataList.getSelectionIndex());
@ -2643,8 +2703,8 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
floodList = (ArrayList<Object[]>) dataManager floodList = (ArrayList<Object[]>) dataManager
.getFloodStage(selectedLid); .getFloodStage(selectedLid);
} catch (VizException e) { } catch (VizException e) {
// TODO Auto-generated catch block statusHandler.handle(Priority.PROBLEM,
e.printStackTrace(); "Unable to get Flood Stage List: ", e);
} }
/* Should only be one here, lid is primary key */ /* Should only be one here, lid is primary key */
@ -2793,24 +2853,23 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
} }
/* report on any duplicates which are ignored */ // report on any duplicates which are ignored
// TODO print this to log
if (duplicateCnt > 0) { if (duplicateCnt > 0) {
System.out.println(duplicateCnt statusHandler.handle(Priority.INFO, duplicateCnt
+ " records detected in copy operation."); + " records detected in copy operation.");
} }
int selection = topDataList.getSelectionIndex(); int selection = topDataList.getSelectionIndex();
/* reload list of timeseries */ // reload list of timeseries
tabularLoadTimeseries(); tabularLoadTimeseries();
topDataList.select(selection); topDataList.select(selection);
} }
} catch (ParseException pe) { } catch (ParseException pe) {
pe.printStackTrace(); statusHandler.handle(Priority.PROBLEM, "Parse eror: ", pe);
} catch (VizException ve) { } catch (VizException ve) {
ve.printStackTrace(); statusHandler.handle(Priority.PROBLEM, "", ve);
} }
} }
@ -2939,14 +2998,14 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
out.write(aRec + "\n"); out.write(aRec + "\n");
} catch (VizException e) { } catch (VizException e) {
e.printStackTrace(); statusHandler.handle(Priority.PROBLEM, "", e);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
e.printStackTrace(); statusHandler.handle(Priority.PROBLEM, "", e);
} }
} }
out.close(); out.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); statusHandler.handle(Priority.PROBLEM, "", e);
showMessage(shell, SWT.ERROR | SWT.OK, "Unable to Save File", showMessage(shell, SWT.ERROR | SWT.OK, "Unable to Save File",
"File: " + SHEF_FILE_NAME + "." + getPid() "File: " + SHEF_FILE_NAME + "." + getPid()
+ "\nUser does NOT have write permission."); + "\nUser does NOT have write permission.");
@ -3047,12 +3106,10 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
} }
} }
} catch (VizException e) { } catch (VizException e) {
e.printStackTrace();
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
"Error transmitting text product", e); "Error transmitting text product", e);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
"Error transmitting text product", e); "Error transmitting text product", e);
} }
@ -3094,6 +3151,11 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
return retVal; return retVal;
} }
/**
* Get the text from the shef file.
*
* @return text
*/
private String getFileText() { private String getFileText() {
if (shefFileName != null) { if (shefFileName != null) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -3135,6 +3197,16 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
} }
} }
/**
* Update bounds then close the dialog.
*/
public void disposeDialog() {
if (isOpen()) {
bounds = shell.getBounds();
}
close();
}
/** /**
* Show a dialog message. * Show a dialog message.
* *
@ -3256,6 +3328,13 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
this.currentTabInfo = currentTabInfo; this.currentTabInfo = currentTabInfo;
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.hydro.timeseries.ForecastDataAttributeListener#notifyUpdate
* (com.raytheon.viz.hydro.timeseries.FcstAttUpdateEvent)
*/
@Override @Override
public void notifyUpdate(FcstAttUpdateEvent faue) { public void notifyUpdate(FcstAttUpdateEvent faue) {
fcstAtt = faue.getFcstAttributes(); fcstAtt = faue.getFcstAttributes();

View file

@ -26,10 +26,10 @@ import java.util.List;
import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.ImageData;
@ -51,6 +51,9 @@ import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.ohd.AppsDefaults; import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.FileUtil; import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.hydro.timeseries.util.GraphData; import com.raytheon.viz.hydro.timeseries.util.GraphData;
@ -89,6 +92,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 23 Jul 2012 15195 mpduff Fix dates for displaying groups * 23 Jul 2012 15195 mpduff Fix dates for displaying groups
* 06 Dec 2012 15066 wkwock Fix "ctrl+r" not work in group mode * 06 Dec 2012 15066 wkwock Fix "ctrl+r" not work in group mode
* 30 Jan 2012 15459 mpduff Redmine 1560 - Make graph canvases redraw on page up/down. * 30 Jan 2012 15459 mpduff Redmine 1560 - Make graph canvases redraw on page up/down.
* 06 Feb 2013 1578 rferrel Code cleanup for non-blocking dialogs.
* *
* </pre> * </pre>
* *
@ -98,6 +102,12 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
*/ */
public class TimeSeriesDisplayDlg extends CaveSWTDialog { public class TimeSeriesDisplayDlg extends CaveSWTDialog {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(TimeSeriesDisplayDlg.class);
/** Location and size of dialog. */
private static Rectangle bounds = null;
/** /**
* Time Series Control menu item. * Time Series Control menu item.
*/ */
@ -365,12 +375,13 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
*/ */
private Composite mainComp = null; private Composite mainComp = null;
/** Canvas to display graph on. */
private Composite canvasComp = null; private Composite canvasComp = null;
private Rectangle bounds = null; /** parent dialog for this display */
private TimeSeriesDlg parentDialog = null; private TimeSeriesDlg parentDialog = null;
/** Application default value used to enable widgets in the dialog. */
private int showCatValue = 0; private int showCatValue = 0;
/** /**
@ -387,16 +398,19 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
* @param parent * @param parent
* Parent shell. * Parent shell.
*/ */
public TimeSeriesDisplayDlg(Shell parent, Rectangle bounds, public TimeSeriesDisplayDlg(Shell parent, TimeSeriesDlg parentDialog) {
TimeSeriesDlg parentDialog) {
super(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.RESIZE, CAVE.DO_NOT_BLOCK super(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.RESIZE, CAVE.DO_NOT_BLOCK
| CAVE.INDEPENDENT_SHELL); | CAVE.INDEPENDENT_SHELL);
setText("Time Series Display"); setText("Time Series Display");
this.bounds = bounds;
this.parentDialog = parentDialog; this.parentDialog = parentDialog;
} }
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
*/
@Override @Override
protected Layout constructShellLayout() { protected Layout constructShellLayout() {
// Create the main layout for the shell. // Create the main layout for the shell.
@ -407,16 +421,24 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
return mainLayout; return mainLayout;
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayoutData()
*/
@Override @Override
protected Object constructShellLayoutData() { protected Object constructShellLayoutData() {
return new GridData(SWT.FILL, SWT.FILL, true, true); return new GridData(SWT.FILL, SWT.FILL, true, true);
} }
@Override /*
protected void disposed() { * (non-Javadoc)
setReturnValue(bounds); *
} * @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
@Override @Override
protected void initializeComponents(final Shell shell) { protected void initializeComponents(final Shell shell) {
// Get default values from Apps Defaults // Get default values from Apps Defaults
@ -447,24 +469,33 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
shell.setMinimumSize(new Point(900, 900)); shell.setMinimumSize(new Point(900, 900));
} }
@Override /*
protected void opened() { * (non-Javadoc)
shell.addDisposeListener(new DisposeListener() { *
@Override * @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
public void widgetDisposed(DisposeEvent e) { */
bounds = shell.getBounds();
}
});
}
@Override @Override
protected void preOpened() { protected void preOpened() {
super.preOpened();
shell.addShellListener(new ShellAdapter() {
@Override
public void shellClosed(ShellEvent e) {
bounds = shell.getBounds();
}
});
if (bounds != null) { if (bounds != null) {
shell.setBounds(bounds); shell.setBounds(bounds);
} }
} }
/**
* This dialog's parent dialog.
*
* @return parentDialog
*/
public TimeSeriesDlg getParentDialog() { public TimeSeriesDlg getParentDialog() {
return this.parentDialog; return this.parentDialog;
} }
@ -825,9 +856,8 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
dataManager.delete(deleteList); dataManager.delete(deleteList);
updateMaxFcst(deleteList); updateMaxFcst(deleteList);
} catch (VizException e) { } catch (VizException e) {
// TODO Auto-generated catch block statusHandler.handle(Priority.PROBLEM,
e.printStackTrace(); "Error deleting points: ", e);
System.err.println("Error deleting points");
} }
} }
@ -836,8 +866,11 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
dataManager.insert(insertList); dataManager.insert(insertList);
updateMaxFcst(insertList); updateMaxFcst(insertList);
} catch (VizException e) { } catch (VizException e) {
// TODO Auto-generated catch block if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
e.printStackTrace(); statusHandler.handle(Priority.DEBUG,
"Insert Error: ", e);
}
MessageBox mb = new MessageBox(shell, MessageBox mb = new MessageBox(shell,
SWT.ICON_ERROR | SWT.OK); SWT.ICON_ERROR | SWT.OK);
mb.setText("Insert Error"); mb.setText("Insert Error");
@ -852,9 +885,8 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
dataManager.edit(editList); dataManager.edit(editList);
updateMaxFcst(editList); updateMaxFcst(editList);
} catch (VizException e) { } catch (VizException e) {
// TODO Auto-generated catch block statusHandler.handle(Priority.PROBLEM,
e.printStackTrace(); "Error editing points: ", e);
System.err.println("Error editing points");
} }
} }
@ -1199,29 +1231,38 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
} }
/**
* From Apps defaults get the showCatValue.
*/
private void loadAppsDefaults() { private void loadAppsDefaults() {
AppsDefaults appsDefaults = AppsDefaults.getInstance(); AppsDefaults appsDefaults = AppsDefaults.getInstance();
this.showCatValue = appsDefaults.getInt("timeseries_showcat", 0); this.showCatValue = appsDefaults.getInt("timeseries_showcat", 0);
} }
/**
* If pointList is for a Max Forecast perform an update.
*
* @param pointList
*/
private void updateMaxFcst(List<ForecastData> pointList) { private void updateMaxFcst(List<ForecastData> pointList) {
ForecastData point = pointList.get(0); ForecastData point = pointList.get(0);
String pe = point.getPe(); String pe = point.getPe();
String ts = point.getTs(); String ts = point.getTs();
if (ts.startsWith("F") || ts.startsWith("C")) { if (ts.startsWith("F") || ts.startsWith("C")) {
/* call Load Max Forecast if update or insert of H or Q PE's */ // call Load Max Forecast if update or insert of H or Q PE's
if (pe.toUpperCase().startsWith("H") if (pe.toUpperCase().startsWith("H")
|| pe.toUpperCase().startsWith("Q")) { || pe.toUpperCase().startsWith("Q")) {
String lid = point.getLid(); String lid = point.getLid();
/* call Load Max Forecast if update or insert of H or Q PE's */ // call Load Max Forecast if update or insert of H or Q PE's
if (pe.toUpperCase().startsWith("H") if (pe.toUpperCase().startsWith("H")
|| pe.toUpperCase().startsWith("Q")) { || pe.toUpperCase().startsWith("Q")) {
try { try {
LoadMaxFcst.loadMaxFcstItem(lid, pe, ts); LoadMaxFcst.loadMaxFcstItem(lid, pe, ts);
} catch (VizException e) { } catch (VizException e) {
e.printStackTrace(); statusHandler.handle(Priority.PROBLEM,
"Error updating MaxFcst: " + e);
} }
} }
} }
@ -1669,6 +1710,9 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
destBytesPerLine, destDataArray); destBytesPerLine, destDataArray);
} }
/**
* Clear and redraw the graph.
*/
public void createNewGraph() { public void createNewGraph() {
if (stackGridComp != null) { if (stackGridComp != null) {
stackGridComp.dispose(); stackGridComp.dispose();
@ -1686,6 +1730,9 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
shell.update(); shell.update();
} }
/**
* Adjust view up a page.
*/
protected void pageUpAction() { protected void pageUpAction() {
if (currentPage == 0) { if (currentPage == 0) {
currentPage = groupInfo.getPageInfoList().size() - 1; currentPage = groupInfo.getPageInfoList().size() - 1;
@ -1709,6 +1756,9 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
} }
/**
* Adjust view down a page.
*/
protected void pageDownAction() { protected void pageDownAction() {
if (currentPage == groupInfo.getPageInfoList().size() - 1) { if (currentPage == groupInfo.getPageInfoList().size() - 1) {
currentPage = 0; currentPage = 0;
@ -1730,6 +1780,9 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
/** /**
* Redraw each Canvas in the list. * Redraw each Canvas in the list.
*
* @param getData
* - when true fetch the data.
*/ */
private void redrawCanvases(boolean getData) { private void redrawCanvases(boolean getData) {
for (TimeSeriesDisplayCanvas c : canvasList) { for (TimeSeriesDisplayCanvas c : canvasList) {
@ -1738,6 +1791,9 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
} }
/**
* Redraw each Canvas without fetching the data.
*/
private void redrawCanvases() { private void redrawCanvases() {
redrawCanvases(false); redrawCanvases(false);
} }
@ -1753,6 +1809,8 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
/** /**
* Return the location ID.
*
* @return the lid * @return the lid
*/ */
public String getLid() { public String getLid() {
@ -1760,6 +1818,8 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
/** /**
* Set the Location ID.
*
* @param lid * @param lid
* the lid to set * the lid to set
*/ */
@ -1768,13 +1828,17 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
/** /**
* @return the beginDate * Get the being date.
*
* @return the begin date
*/ */
public Date getBeginDate() { public Date getBeginDate() {
return beginDate; return beginDate;
} }
/** /**
* Set the being date.
*
* @param beginDate * @param beginDate
* the beginDate to set * the beginDate to set
*/ */
@ -1783,6 +1847,8 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
/** /**
* Get the end date.
*
* @return the endDate * @return the endDate
*/ */
public Date getEndDate() { public Date getEndDate() {
@ -1790,6 +1856,8 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
/** /**
* Set the end date.
*
* @param endDate * @param endDate
* the endDate to set * the endDate to set
*/ */
@ -1798,6 +1866,8 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
/** /**
* Get the site name.
*
* @return the siteName * @return the siteName
*/ */
public String getSiteName() { public String getSiteName() {
@ -1805,6 +1875,8 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
/** /**
* Set the site name.
*
* @param siteName * @param siteName
* the siteName to set * the siteName to set
*/ */
@ -1813,6 +1885,8 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
/** /**
* Get the group information.
*
* @return the groupInfo * @return the groupInfo
*/ */
public GroupInfo getGroupInfo() { public GroupInfo getGroupInfo() {
@ -1820,6 +1894,8 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
/** /**
* Set the group information.
*
* @param groupInfo * @param groupInfo
* the groupInfo to set * the groupInfo to set
*/ */
@ -1828,6 +1904,8 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
/** /**
* Get the points' menu item.
*
* @return the pointsMI * @return the pointsMI
*/ */
public MenuItem getPointsMI() { public MenuItem getPointsMI() {
@ -1835,6 +1913,8 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
/** /**
* Get the lines menu item.
*
* @return the linesMI * @return the linesMI
*/ */
public MenuItem getLinesMI() { public MenuItem getLinesMI() {
@ -1842,6 +1922,8 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
/** /**
* Get the points and line menu item.
*
* @return the bothMI * @return the bothMI
*/ */
public MenuItem getBothMI() { public MenuItem getBothMI() {
@ -1856,6 +1938,8 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
} }
/** /**
* Get the Batch Data Only, Show Categories menu item.
*
* @return the batchDataOnlyShowCatMI * @return the batchDataOnlyShowCatMI
*/ */
public MenuItem getBatchDataOnlyShowCatMI() { public MenuItem getBatchDataOnlyShowCatMI() {
@ -1869,14 +1953,27 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
return batchDataAndCategoriesMI; return batchDataAndCategoriesMI;
} }
/**
* Get the data only menu item.
*
* @return dataOnlyMI
*/
public MenuItem getScaleStagesDataOnlyMI() { public MenuItem getScaleStagesDataOnlyMI() {
return dataOnlyMI; return dataOnlyMI;
} }
/**
* @return dataOnlyShowCatMI
*/
public MenuItem getScaleStagesDataOnlyShowCategoreMI() { public MenuItem getScaleStagesDataOnlyShowCategoreMI() {
return dataOnlyShowCatMI; return dataOnlyShowCatMI;
} }
/**
* Get the Data and Categories menu item.
*
* @return dataAndCategoriesMI
*/
public MenuItem getScaleStagesDataAndCategoriesMI() { public MenuItem getScaleStagesDataAndCategoriesMI() {
return dataAndCategoriesMI; return dataAndCategoriesMI;
} }
@ -2227,16 +2324,14 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
return showLatestFcstMI.getSelection(); return showLatestFcstMI.getSelection();
} }
/**
* Update bounds then close the dialog.
*/
public void disposeDialog() { public void disposeDialog() {
shell.dispose(); if (isOpen()) {
} bounds = shell.getBounds();
public Rectangle getDialogBounds() {
if (shell.isDisposed()) {
return bounds;
} else {
return shell.getBounds();
} }
close();
} }
/** /**

View file

@ -46,7 +46,6 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowData; import org.eclipse.swt.layout.RowData;
@ -473,8 +472,6 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
*/ */
private boolean displayGraph = false; private boolean displayGraph = false;
private Rectangle bounds = null;
private TabularTimeSeriesDlg tabularDlg; private TabularTimeSeriesDlg tabularDlg;
/** /**
@ -2045,7 +2042,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
tabInfoList.clear(); tabInfoList.clear();
if ((tabularDlg != null) && tabularDlg.isOpen()) { if ((tabularDlg != null) && tabularDlg.isOpen()) {
tabularDlg.close(); tabularDlg.disposeDialog();
} }
tabularDlg = new TabularTimeSeriesDlg(shell, beginCal.getTime(), tabularDlg = new TabularTimeSeriesDlg(shell, beginCal.getTime(),
@ -2133,11 +2130,10 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
} else { } else {
if (timeSeriesDisplayDlg != null) { if (timeSeriesDisplayDlg != null) {
bounds = timeSeriesDisplayDlg.getDialogBounds();
timeSeriesDisplayDlg.disposeDialog(); timeSeriesDisplayDlg.disposeDialog();
} }
timeSeriesDisplayDlg = new TimeSeriesDisplayDlg(shell, bounds, this); timeSeriesDisplayDlg = new TimeSeriesDisplayDlg(shell, this);
PageInfo pageInfo = new PageInfo(); PageInfo pageInfo = new PageInfo();
LIDData firstLidData = new LIDData(); LIDData firstLidData = new LIDData();