From 4575dce48eb8f168a8b8e0b68cf62b8925c3ac42 Mon Sep 17 00:00:00 2001 From: Lee Venable Date: Mon, 29 Apr 2013 14:35:32 -0500 Subject: [PATCH] Issue #1945 - SCAN performance improvements and code cleanup. Former-commit-id: b47c88a8586bca789367406f3fb2962a529e5605 [formerly 41e2d9ee306e0b9ea11d62cf163666e28a73b8e4 [formerly 834da4689a93e07fb668fc6b64a435722986d745]] Former-commit-id: 41e2d9ee306e0b9ea11d62cf163666e28a73b8e4 Former-commit-id: a9dec96a856df8d6afbc3dee491fc7b3151bf06e --- .../monitor/scan/tables/AbstractTableDlg.java | 62 ++-- .../scan/tables/SCANCellTableComp.java | 75 +++-- .../monitor/scan/tables/SCANCellTableDlg.java | 303 ++++-------------- .../monitor/scan/tables/SCANDmdTableComp.java | 39 +-- .../monitor/scan/tables/SCANDmdTableDlg.java | 129 +++----- .../scan/tables/SCANMesoTableComp.java | 59 +--- .../monitor/scan/tables/SCANMesoTableDlg.java | 153 ++++----- .../uf/viz/monitor/scan/tables/SCANTable.java | 173 +++++----- .../monitor/scan/tables/SCANTvsTableComp.java | 67 +--- .../monitor/scan/tables/SCANTvsTableDlg.java | 163 +++++----- 10 files changed, 467 insertions(+), 756 deletions(-) diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/AbstractTableDlg.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/AbstractTableDlg.java index 2e0e577380..fb8761ba29 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/AbstractTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/AbstractTableDlg.java @@ -50,6 +50,7 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.monitor.scan.config.SCANConfig; import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables; +import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.viz.core.alerts.AlertMessage; import com.raytheon.uf.viz.monitor.IMonitor; import com.raytheon.uf.viz.monitor.Monitor; @@ -74,6 +75,7 @@ import com.raytheon.uf.viz.monitor.scan.commondialogs.LoadSaveConfigDlg.DialogTy * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Nov 21, 2009 #3039 lvenable Initial creation + * Apr 26, 2013 #1945 lvenable Some code cleanup. * * * @@ -179,14 +181,10 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, initData(); - // fileButtonTipText = "Current Config:\n" + - // scanCfg.getCurrentConfigFileName(scanTable); - setShellText(); setTableType(); initComponents(); - shellCloseAction(); shellDisposeAction(); shell.pack(); @@ -260,7 +258,6 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, } // Loop and close all of the open dialogs; - Set keys = dialogsMap.keySet(); for (ICommonDialogAction icda : keys) { @@ -476,6 +473,29 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, fileBtn.setToolTipText(fileButtonTipText); } + /** + * Get the scan time. If link to frame is turned on then get that time with + * the displayed frame otherwise get the latest time. + * + * @param scanMonitor + * The scan monitor. + * @return The scan time. + */ + protected Date getScanTime(ScanMonitor scanMonitor) { + Date time = null; + if (getLinkToFrame(scanTable.name())) { + time = scanMonitor.getScanTime(scanTable, site); + } else { + DataTime dt = scanMonitor.getMostRecent(scanMonitor, + scanTable.name(), site); + + if (dt != null) { + time = dt.getRefTime(); + } + } + return time; + } + @Override public void addMonitorControlListener(IMonitor monitor) { getMonitorControlListeners().add(monitor); @@ -491,6 +511,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, public void fireConfigUpdate(IMonitorConfigurationEvent imce) { final IMonitorConfigurationEvent fimce = imce; Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { Iterator iter = getMonitorControlListeners() .iterator(); @@ -504,6 +525,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, @Override public void fireKillMonitor() { Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { Iterator iter = getMonitorControlListeners() .iterator(); @@ -518,6 +540,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, public void fireThresholdUpdate(IMonitorThresholdEvent imte) { final IMonitorThresholdEvent fimte = imte; Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { Iterator iter = getMonitorControlListeners() .iterator(); @@ -534,8 +557,8 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, * @param ident * @param type */ - public TrendGraphData getTrendGraphData(ScanTables type, - String field, String ident) { + public TrendGraphData getTrendGraphData(ScanTables type, String field, + String ident) { TrendGraphData tgd = null; Iterator iter = getMonitorControlListeners().iterator(); while (iter.hasNext()) { @@ -572,6 +595,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, final ScanTables ftype = type; final String ficao = icao; Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { Iterator iter = getMonitorControlListeners() .iterator(); @@ -590,6 +614,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, */ public void fireScanPaint() { Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { Iterator iter = getMonitorControlListeners() .iterator(); @@ -612,10 +637,8 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, } // TODO: What needs to be done here is to grab the current selected - // trend set - // and fire a trend set for the passed in ID and table + // trend set and fire a trend set for the passed in ID and table // this will mean firing a get graphData Event back to the monitor - System.out.println("Trend Set requested: " + type + " : " + ident); } @Override @@ -635,6 +658,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, @Override public void fireDialogShutdown(IMonitorListener iml) { Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { Iterator iter = getMonitorControlListeners() .iterator(); @@ -646,8 +670,8 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, } @Override - public TrendGraphData requestTrendGraphData(ScanTables type, - String field, String ident) { + public TrendGraphData requestTrendGraphData(ScanTables type, String field, + String ident) { return getTrendGraphData(type, field, ident); } @@ -683,6 +707,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, * used to notify updates of data to display elements from classes that * implement the IMonitor interface. */ + @Override public void fireMonitorEvent() { return; } @@ -694,6 +719,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, * listener class as an argument that can be used for targeted * notifications. */ + @Override public void fireMonitorEvent(String type) { return; } @@ -703,6 +729,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, * used to notify updates of data to display elements from classes that * implement the IMonitor interface. */ + @Override public void fireMonitorEvent(Monitor monitor) { return; } @@ -712,6 +739,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, * * @param pluginName */ + @Override public void initObserver(String pluginName, Monitor monitor) { return; } @@ -722,6 +750,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, * @param type * @return */ + @Override public ArrayList getTimeOrderedKeys(IMonitor monitor, String type) { return monitor.getTimeOrderedKeys(monitor, type); } @@ -742,6 +771,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, /* * Abstract methods to be implemented by classes extending this class. */ + @Override public abstract void notify(IMonitorEvent me); public abstract void displayTrendSetGraphs(String ident); @@ -750,12 +780,8 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, protected abstract void initComponents(); - // protected abstract void update(); - protected abstract void setShellText(); - protected abstract void shellCloseAction(); - protected abstract void shellDisposeAction(); protected abstract void updateAfterConfigLoad(); @@ -766,7 +792,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor, public abstract void updateThresh(String attr); - public abstract void turnOffAlarm(); + public abstract void turnOffAlarm(); - public abstract void turnOnAlarm(); + public abstract void turnOnAlarm(); } diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANCellTableComp.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANCellTableComp.java index d0456a67a9..4f8443d2b1 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANCellTableComp.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANCellTableComp.java @@ -44,6 +44,7 @@ import com.raytheon.uf.viz.monitor.scan.commondialogs.IRequestTrendGraphData; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 3, 2009 #3039 lvenable Initial creation + * Apr 29, 2013 #1945 lvenable Code cleanup for SCAN performance. * * * @@ -59,13 +60,28 @@ public class SCANCellTableComp extends SCANTableTrendGraphLayer { private static final String UNWARNED_SVR_TOOLTIP = "\nA storm meeting Severe " + "Weather warning\ncriteria is outside any SVR warning polygon."; - // private Point mouseMovePt = new Point(0, 0); - // - // private Point mouseDownPt = new Point(0, 0); - // - // private Point prevMousePt = new Point(-9999, -9999); + /** Radius interpolation column name. */ + private String radVarColName = ""; - public SCANCellTableComp(Composite parent, SCANTableData tableData, ITableAction tableActionCB, + /** Clutter control column name. */ + private String clutterCoName = ""; + + /** + * Constructor. + * + * @param parent + * Parent composite. + * @param tableData + * Table data. + * @param tableActionCB + * Table action callback + * @param requestDataCallback + * Request data callback + * @param site + * The site. + */ + public SCANCellTableComp(Composite parent, SCANTableData tableData, + ITableAction tableActionCB, IRequestTrendGraphData requestDataCallback, String site) { super(parent, tableData, tableActionCB, requestDataCallback, site); @@ -105,22 +121,24 @@ public class SCANCellTableComp extends SCANTableTrendGraphLayer { if (colIndex == 0) { tableIndex = rowIndex; if ((tableIndex >= 0) || (tableIndex > table.getItemCount())) { - tableActionCB.centerByStormId(table.getItem(tableIndex).getText()); + tableActionCB.centerByStormId(table.getItem(tableIndex) + .getText()); redrawTable(); } } else { String name = (String) table.getColumn(colIndex).getData(); if (scanCfg.canViewTrend(scanTable, name) == true) { - String ident = tableData.getTableRows().get(rowIndex).getTableCellData(0).getCellText(); + String ident = tableData.getTableRows().get(rowIndex) + .getTableCellData(0).getCellText(); - System.out.println("Display trend graph dialog for " + ident); displayTrendGraphDialog(ident, name); } } } else if (event.button == 3) { if (colIndex == 0) { - String ident = tableData.getTableRows().get(rowIndex).getTableCellData(0).getCellText(); + String ident = tableData.getTableRows().get(rowIndex) + .getTableCellData(0).getCellText(); displayTrendSetsGraphDialog(ident); } } @@ -141,10 +159,10 @@ public class SCANCellTableComp extends SCANTableTrendGraphLayer { } Rectangle rect; - // rect = item.getBounds(table.getColumnCount() - 1); rect = item.getBounds(scanCfg.getCountyColumnIndex(scanTable)); - if (scanCfg.showTips(scanTable) == false && rect.contains(mouseMovePt) == false) { + if (scanCfg.showTips(scanTable) == false + && rect.contains(mouseMovePt) == false) { prevMousePt.x = -9999; prevMousePt.y = -9999; table.setToolTipText(null); @@ -162,17 +180,22 @@ public class SCANCellTableComp extends SCANTableTrendGraphLayer { prevMousePt.x = mouseMovePt.x; prevMousePt.y = mouseMovePt.y; - String toolTip = toolTipMgr.getTableCellTip(scanTable, (String) table.getColumn(i).getData()); + String toolTip = toolTipMgr.getTableCellTip(scanTable, + (String) table.getColumn(i).getData()); if (i == 0) { - WARN_TYPE wt = tableData.getTableRows().get(table.indexOf(item)).getTableCellData(0).getWarnType(); + WARN_TYPE wt = tableData.getTableRows() + .get(table.indexOf(item)).getTableCellData(0) + .getWarnType(); if (wt == WARN_TYPE.SEVERE) { toolTip = toolTip.concat(UNWARNED_SVR_TOOLTIP); } else if (wt == WARN_TYPE.TVS) { toolTip = toolTip.concat(UNWARNED_TOR_TOOLTIP); } - } else if (((String) table.getColumn(i).getData()).equals(CELLTable.COUNTY.getColName())) { - toolTip = tableData.getTableRows().get(table.indexOf(item)).getTableCellData(i).getCellText(); + } else if (((String) table.getColumn(i).getData()) + .equals(CELLTable.COUNTY.getColName())) { + toolTip = tableData.getTableRows().get(table.indexOf(item)) + .getTableCellData(i).getCellText(); } table.setToolTipText(toolTip); @@ -191,6 +214,17 @@ public class SCANCellTableComp extends SCANTableTrendGraphLayer { */ @Override protected void setColumnImages() { + + /* + * If the Radius Interpolation, Clutter Control, or sort column hasn't + * changed then return because the images will not change. + */ + if (scanCfg.isRadVar(scanTable, radVarColName) + && scanCfg.isClutterControl(scanTable, clutterCoName) + && lastSortColIndex == sortedColumnIndex) { + return; + } + TableColumn[] tCols = table.getColumns(); for (int i = 0; i < tCols.length; i++) { @@ -215,13 +249,16 @@ public class SCANCellTableComp extends SCANTableTrendGraphLayer { */ if (scanCfg.isRadVar(scanTable, colName) == true) { + radVarColName = colName; gc.setBackground(scanCfg.getScanColor(ScanColors.RadVar)); } // Set the foreground color to the clutter control color if the // column is a clutter control. if (scanCfg.isClutterControl(scanTable, colName) == true) { - gc.setForeground(scanCfg.getScanColor(ScanColors.ClutterControl)); + clutterCoName = colName; + gc.setForeground(scanCfg + .getScanColor(ScanColors.ClutterControl)); } // Set the background color to the sort color if that column is @@ -237,12 +274,12 @@ public class SCANCellTableComp extends SCANTableTrendGraphLayer { gc.setBackground(scanCfg.getScanColor(ScanColors.Sort)); } + lastSortColIndex = sortedColumnIndex; + gc.fillRectangle(0, 0, imageWidth, imageHeight); int colNameExt = gc.stringExtent(colName).x; - // int xCoord = (imageWidth / 2) - (colName.length() * textWidth / - // 2); int xCoord = (imageWidth / 2) - (colNameExt / 2); gc.drawText(colName, xCoord, 3, true); diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANCellTableDlg.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANCellTableDlg.java index 3f3a10758d..2701c085a2 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANCellTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANCellTableDlg.java @@ -54,6 +54,7 @@ import com.raytheon.uf.common.monitor.scan.config.SCANConfig; import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.MESOTable; import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanColors; import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables; +import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.viz.monitor.IMonitor; import com.raytheon.uf.viz.monitor.events.IMonitorConfigurationEvent; import com.raytheon.uf.viz.monitor.events.IMonitorEvent; @@ -87,6 +88,8 @@ import com.raytheon.viz.ui.EditorUtil; * Nov 21, 2009 #3039 lvenable Initial creation * * 03/15/2012 13939 Mike Duff For a SCAN Alarms issue + * Apr 26, 2013 #1945 lvenable Improved SCAN performance, reworked + * some bad code, and some code cleanup. * * * @@ -99,7 +102,7 @@ public class SCANCellTableDlg extends AbstractTableDlg implements private boolean killDialog = false; /* - * Action button at the top of the dialog. + * Action buttons at the top of the dialog. */ private Button configBtn; @@ -180,6 +183,10 @@ public class SCANCellTableDlg extends AbstractTableDlg implements private SCANAlarmsDlg alarmDlg = null; + /** Date format for the time label. */ + private SimpleDateFormat dateFmt = new SimpleDateFormat( + "E MMM dd HH:mm yyyy"); + /** * Constructor. * @@ -209,6 +216,7 @@ public class SCANCellTableDlg extends AbstractTableDlg implements */ @Override protected void initComponents() { + dateFmt.setTimeZone(TimeZone.getTimeZone("GMT")); createTopControls(); createCellTable(); createFilePopupMenu(); @@ -231,7 +239,7 @@ public class SCANCellTableDlg extends AbstractTableDlg implements } /** - * + * Add an alarm timer. */ private void addAlarmTimer() { if (scanTableComp.timer != null) { @@ -239,6 +247,7 @@ public class SCANCellTableDlg extends AbstractTableDlg implements @Override public void run() { Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { if (shell.isDisposed()) { scanTableComp.timer.cancel(); @@ -437,11 +446,16 @@ public class SCANCellTableDlg extends AbstractTableDlg implements vertChk.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); vertChk.setSelection(cellCfgMgr.getScanCellCfgXML().getFilterOption()); vertChk.setLayoutData(gd); - vertChk.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - } - }); + + /* + * The vertical table is a techblocked DR. This selection listener will + * be commented out until it is needed. + */ + // vertChk.addSelectionListener(new SelectionAdapter() { + // @Override + // public void widgetSelected(SelectionEvent e) { + // } + // }); setupButtonMouseListeners(vertChk); gd = new GridData(); @@ -475,7 +489,7 @@ public class SCANCellTableDlg extends AbstractTableDlg implements alarmDlg.open(); if (!alarmBtn.isDisposed() && (mgr.getAlertedAlarmCount(site, scanTable) == 0)) { - turnOffAlarm(); + turnOffAlarm(); } } }); @@ -489,52 +503,19 @@ public class SCANCellTableDlg extends AbstractTableDlg implements @Override public void turnOffAlarm() { - if (alarmBtn != null && !alarmBtn.isDisposed()) { - alarmBtn.setVisible(false); - } + if (alarmBtn != null && !alarmBtn.isDisposed()) { + alarmBtn.setVisible(false); + } mgr.setRing(false); - } + } @Override public void turnOnAlarm() { - if (alarmBtn != null && !alarmBtn.isDisposed()) { - alarmBtn.setVisible(true); - } + if (alarmBtn != null && !alarmBtn.isDisposed()) { + alarmBtn.setVisible(true); + } mgr.setRing(true); - } - - // private void resetButtonForegroundColor(Button btn) - // { - // btn.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); - // } - - // private void setupButtonMouseListeners(final Button btn) - // { - // btn.addMouseMoveListener(new MouseMoveListener() - // { - // @Override - // public void mouseMove(MouseEvent e) - // { - // btn.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); - // } - // - // }); - // - // btn.addMouseTrackListener(new MouseTrackAdapter() - // { - // @Override - // public void mouseExit(MouseEvent e) - // { - // btn.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); - // } - // - // @Override - // public void mouseEnter(MouseEvent e) - // { - // btn.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); - // } - // }); - // } + } /** * Create the CELL table. @@ -605,19 +586,6 @@ public class SCANCellTableDlg extends AbstractTableDlg implements } }); - // new MenuItem(filePopupMenu, SWT.SEPARATOR); - // - // MenuItem exitMI = new MenuItem(filePopupMenu, SWT.NONE); - // exitMI.setText("Exit"); - // exitMI.addSelectionListener(new SelectionAdapter() - // { - // @Override - // public void widgetSelected(SelectionEvent e) - // { - // shellDisposeDialog(); - // } - // }); - fileBtn.setMenu(filePopupMenu); } @@ -903,6 +871,7 @@ public class SCANCellTableDlg extends AbstractTableDlg implements */ private void displayMesoTableDialog() { Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { Iterator iter = getMonitorControlListeners() .iterator(); @@ -921,6 +890,7 @@ public class SCANCellTableDlg extends AbstractTableDlg implements */ private void displayTvsTableDialog() { Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { Iterator iter = getMonitorControlListeners() .iterator(); @@ -943,8 +913,6 @@ public class SCANCellTableDlg extends AbstractTableDlg implements return; } - SimpleDateFormat dateFmt = new SimpleDateFormat("E MMM dd HH:mm yyyy"); - dateFmt.setTimeZone(TimeZone.getTimeZone("GMT")); timeLbl.setText(dateFmt.format(currentTime)); } @@ -1012,144 +980,6 @@ public class SCANCellTableDlg extends AbstractTableDlg implements mb.open(); } - // /** - // * Retrieve the default configuration. - // */ - // private void retrieveDefaultConfig() - // { - // /* - // * TODO : when loading the default config, the controls on the dialog - // * needs to be updated and a new table data should be loaded - // */ - // scanCfg.loadDefaultConfigFileName(scanTable); - // - // updateAfterConfigLoad(); - // } - // - // /** - // * Retrieve an existing configuration. - // */ - // private void retrieveExistingConfig() - // { - // /* - // * TODO : when loading an existing config, the controls on the dialog - // * needs to be updated and a new table data should be loaded - // */ - // - // if (closedOpenDialogs() == false) - // { - // return; - // } - // - // LoadSaveConfigDlg loadDlg = new LoadSaveConfigDlg(shell, DialogType.OPEN, - // scanTable); - // LocalizationFile fileName = loadDlg.open(); - // - // if (fileName == null) - // { - // System.out.println("FileName is null..."); - // return; - // } - // - // scanCfg.loadNewConfigFileName(scanTable, fileName.getFile().getName()); - // - // System.out.println(fileName.getFile().getAbsolutePath()); - // - // updateAfterConfigLoad(); - // - // } - // - // /** - // * Save the current configuration. - // */ - // private void saveCurrentConfiguration() - // { - // /* - // * TODO : save the current configuration... - // * - // * do not need to update the display... - // * - // * call to configuration manager to save the config... - // */ - // - // /* - // * check if the user is trying to save the default config - // */ - // - // if (scanCfg.currentConfigIsDefault(scanTable) == true) - // { - // MessageBox mb = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK | - // SWT.CANCEL); - // mb.setText("Overwrite"); - // mb.setMessage("Saving will overwrite the default configuration.\n" + - // "Do you wish to continue?"); - // int result = mb.open(); - // - // // If the user selected Cancel then return. - // if (result == SWT.CANCEL) - // { - // return; - // } - // } - // - // scanCfg.saveCurrentConfigurationFile(scanTable); - // } - // - // /** - // * Save the current configuration as a different name. - // */ - // private void saveConfigurationAs() - // { - // /* - // * TODO : launch the save dialog and then get a name to save the - // configuration. - // * - // * do not need to update the display... - // */ - // String defCfgName = scanCfg.getDefaultConfigName(scanTable); - // - // - // - // LoadSaveConfigDlg loadDlg = new LoadSaveConfigDlg(shell, - // DialogType.SAVE_AS, scanTable); - // LocalizationFile fileName = loadDlg.open(); - // - // if (fileName == null) - // { - // System.out.println("FileName is null..."); - // return; - // } - // - // if (defCfgName.compareTo(fileName.getFile().getName()) == 0) - // { - // MessageBox mb = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK | - // SWT.CANCEL); - // mb.setText("Overwrite"); - // mb.setMessage("The Save As name is the same as the default configuration name. Saving " - // + - // "will overwrite the default configuration.\n" + - // "Do you wish to continue?"); - // int result = mb.open(); - // - // // If the user selected Cancel then return. - // if (result == SWT.CANCEL) - // { - // return; - // } - // } - // - // scanCfg.saveConfigurationFileAs(scanTable, fileName.getFile().getName()); - // } - - /** - * Shell closed action. - */ - @Override - protected void shellCloseAction() { - // TODO : this method may be deleted from the abstract - // class if it is not needed - } - /** * Shell dispose action. */ @@ -1164,7 +994,6 @@ public class SCANCellTableDlg extends AbstractTableDlg implements @Override public void shellClosed(ShellEvent e) { e.doit = killDialog; - // unregisterDialog(); } }); } @@ -1186,6 +1015,22 @@ public class SCANCellTableDlg extends AbstractTableDlg implements shell.setText(this.site + " CELL Table"); } + /** + * Update the table with new data. + * + * @param scan + * Scan Monitor. + * @param time + * The new time. + * @param sdg + * Scan Data Generator. + */ + private void updateTable(ScanMonitor scan, Date time, ScanDataGenerator sdg) { + tableData = sdg.generateCellData(scan.getTableData(scanTable, site, + time)); + scanTableComp.setTableData(tableData); + } + /** * Notify when the table data needs to be updated. */ @@ -1193,18 +1038,15 @@ public class SCANCellTableDlg extends AbstractTableDlg implements public void notify(IMonitorEvent me) { if (me.getSource() instanceof IMonitor) { ScanMonitor scan = (ScanMonitor) me.getSource(); - Date time = null; - try { - if (getLinkToFrame(scanTable.name())) { - time = scan.getScanTime(scanTable, site); - } else { - time = scan.getMostRecent(scan, scanTable.name(), site) - .getRefTime(); - } - } catch (Exception e) { + + // If scan is null return since nothing will be done. + if (scan == null) { + return; } - if ((time != null) && (scan != null)) { + Date time = getScanTime(scan); + + if ((time != null)) { ScanDataGenerator sdg = new ScanDataGenerator(site); @@ -1218,21 +1060,18 @@ public class SCANCellTableDlg extends AbstractTableDlg implements sdg.setUnwarnedCells(warnings); } - tableData = sdg.generateCellData((scan).getTableData(scanTable, - site, time)); - - scanTableComp.setTableData(tableData); - - setShellText(); - if (getLinkToFrame(scanTable.name())) { - - currentTime = (scan).getDialogTime(scanTable, site); - + currentTime = scan.getDialogTime(scanTable, site); + updateTimeLabel(); + updateTable(scan, time, sdg); } else { - currentTime = time; + if (currentTime == null || !currentTime.equals(time)) { + currentTime = time; + updateTimeLabel(); + updateTable(scan, time, sdg); + } } - updateTimeLabel(); + scan.fireMonitorEvent(SCANMesoTableDlg.class.getName()); scan.fireMonitorEvent(SCANTvsTableDlg.class.getName()); @@ -1242,11 +1081,10 @@ public class SCANCellTableDlg extends AbstractTableDlg implements // closes the alarm dialog if new data comes in or user switches // frame Date scanMostRecentTime = null; - try { - scanMostRecentTime = scan.getMostRecent(scan, - scanTable.name(), site).getRefTime(); - } catch (NullPointerException npe) { - // scan has been turned off + DataTime dataTime = scan.getMostRecent(scan, scanTable.name(), + site); + if (dataTime != null) { + scanMostRecentTime = dataTime.getRefTime(); } if (scanMostRecentTime != null) { @@ -1265,13 +1103,14 @@ public class SCANCellTableDlg extends AbstractTableDlg implements scanTableComp.checkBlink(sdg, scanMostRecentTime); if (mgr.getAlertedAlarms(site, scanTable).size() > 0) { boolean displayAlarmBtn = false; - for (AlertedAlarms alarm: mgr.getAlertedAlarms(site, scanTable)) { + for (AlertedAlarms alarm : mgr.getAlertedAlarms( + site, scanTable)) { if (!alarm.cleared) { displayAlarmBtn = true; break; } } - + alarmBtn.setVisible(displayAlarmBtn); addAlarmTimer(); } else { diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANDmdTableComp.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANDmdTableComp.java index 8f3ab0f83f..1afdb641e1 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANDmdTableComp.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANDmdTableComp.java @@ -27,7 +27,6 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.TableColumn; @@ -55,6 +54,8 @@ import com.raytheon.uf.viz.monitor.scan.commondialogs.TimeHeightDlg; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 3, 2009 #3039 lvenable Initial creation + * Apr 26, 2013 #1945 lvenable Improved SCAN performance, reworked + * some bad code, and some code cleanup. * * * @@ -63,16 +64,14 @@ import com.raytheon.uf.viz.monitor.scan.commondialogs.TimeHeightDlg; */ public class SCANDmdTableComp extends SCANTableTrendGraphLayer implements IRequestTimeHeightData { - private Point mouseMovePt = new Point(0, 0); - - private Point mouseDownPt = new Point(0, 0); - - private Point prevMousePt = new Point(-9999, -9999); private TimeHeightDlg timeHeightDlg = null; private IRequestTimeHeightData timeHeightCB; + /** Clutter control column name. */ + private String clutterColName = ""; + public SCANDmdTableComp(Composite parent, SCANTableData tableData, ITableAction tableActionCB, IRequestTrendGraphData requestDataCallback, @@ -85,6 +84,15 @@ public class SCANDmdTableComp extends SCANTableTrendGraphLayer implements @Override protected void setColumnImages() { + /* + * If the clutter control & sort column hasn't changed then return + * because the images will not change. + */ + if (scanCfg.isClutterControl(scanTable, clutterColName) + && lastSortColIndex == sortedColumnIndex) { + return; + } + TableColumn[] tCols = table.getColumns(); for (int i = 0; i < tCols.length; i++) { @@ -100,9 +108,9 @@ public class SCANDmdTableComp extends SCANTableTrendGraphLayer implements gc.setBackground(this.getDisplay().getSystemColor(SWT.COLOR_BLACK)); // Set the foreground color to the clutter control color if the - // column - // is a clutter control. + // column is a clutter control. if (scanCfg.isClutterControl(scanTable, colName) == true) { + clutterColName = colName; gc.setForeground(scanCfg .getScanColor(ScanColors.ClutterControl)); } @@ -120,12 +128,12 @@ public class SCANDmdTableComp extends SCANTableTrendGraphLayer implements gc.setBackground(scanCfg.getScanColor(ScanColors.Sort)); } + lastSortColIndex = sortedColumnIndex; + gc.fillRectangle(0, 0, imageWidth, imageHeight); int colNameExt = gc.stringExtent(colName).x; - // int xCoord = (imageWidth / 2) - (colName.length() * textWidth / - // 2); int xCoord = (imageWidth / 2) - (colNameExt / 2); gc.drawText(colName, xCoord, 3, true); @@ -201,12 +209,6 @@ public class SCANDmdTableComp extends SCANTableTrendGraphLayer implements @Override protected void tableMouseMoveAction(MouseEvent event) { - // if (scanCfg.showTips(scanTable) == false) { - // prevMousePt.x = -9999; - // prevMousePt.y = -9999; - // table.setToolTipText(null); - // return; - // } mouseMovePt.x = event.x; mouseMovePt.y = event.y; @@ -219,7 +221,6 @@ public class SCANDmdTableComp extends SCANTableTrendGraphLayer implements } Rectangle rect; - // rect = item.getBounds(table.getColumnCount() - 2); rect = item.getBounds(scanCfg.getCountyColumnIndex(scanTable)); if ((scanCfg.showTips(scanTable) == false) @@ -282,9 +283,9 @@ public class SCANDmdTableComp extends SCANTableTrendGraphLayer implements public void redrawTimeHeightGraph() { if ((timeHeightDlg == null) || timeHeightDlg.isDisposed()) { return; - } else { - timeHeightDlg.redrawGraph(); } + + timeHeightDlg.redrawGraph(); } public boolean timeHeightDisplayed() { diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANDmdTableDlg.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANDmdTableDlg.java index 64f217a003..4f1867796b 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANDmdTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANDmdTableDlg.java @@ -57,7 +57,6 @@ import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanColors; import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables; 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.viz.monitor.IMonitor; import com.raytheon.uf.viz.monitor.events.IMonitorConfigurationEvent; import com.raytheon.uf.viz.monitor.events.IMonitorEvent; @@ -90,6 +89,8 @@ import com.raytheon.viz.ui.EditorUtil; * Apr 29, 2010 lvenable Initial creation * * 03/15/2012 13939 Mike Duff For a SCAN Alarms issue + * Apr 29, 2013 #1945 lvenable Improved SCAN performance, reworked + * some bad code, and some code cleanup. * * * @@ -315,6 +316,7 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements @Override public void run() { Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { if (shell.isDisposed()) { dmdTableComp.timer.cancel(); @@ -473,11 +475,16 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements vertChk.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); vertChk.setSelection(dmdConfigMgr.getScanDmdCfgXML().getFilterOption()); vertChk.setLayoutData(gd); - vertChk.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - } - }); + + /* + * The vertical table is a techblocked DR. This will be commented out + * until that is addressed. + */ + // vertChk.addSelectionListener(new SelectionAdapter() { + // @Override + // public void widgetSelected(SelectionEvent e) { + // } + // }); setupButtonMouseListeners(vertChk); gd = new GridData(); @@ -514,7 +521,7 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements alarmsDlg.open(); if (!alarmBtn.isDisposed() && mgr.getAlertedAlarms(site, scanTable).isEmpty()) { - turnOffAlarm(); + turnOffAlarm(); } } }); @@ -522,8 +529,7 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements gd = new GridData(SWT.DEFAULT, SWT.CENTER, false, true); gd.widthHint = 135; elevationLbl = new Label(controlComp, SWT.CENTER | SWT.BORDER); - elevationLbl.setText("* No Elevation *"); // TODO - need to add - // elevation + elevationLbl.setText("* No Elevation *"); elevationLbl.setBackground(elevationLabelColor); elevationLbl.setLayoutData(gd); @@ -677,53 +683,6 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements configBtn.setMenu(configPopupMenu); } - /** - * Create the Rank popup menu. - */ - // private void createRankPopupMenu() { - // rankPopupMenu = new Menu(rankBtn); - - /* - * TODO : need to handle default ranking in the list... DMD -- stRank not - * really clear on how the legacy system handle this. - */ - - /* - * Default menu item - */ - // MenuItem defaultMI = new MenuItem(rankPopupMenu, SWT.NONE); - // defaultMI.setText(SCANConfig.getInstance().getDefaultName()); - // defaultMI.setData(SCANConfig.getInstance().getDefaultName()); - // defaultMI.setEnabled(false); - // defaultMI.addSelectionListener(new SelectionAdapter() - // { - // @Override - // public void widgetSelected(SelectionEvent event) - // { - // handleRankMenuEvent(event); - // } - // }); - // - /* - * Create the remaining rank menus from the configuration - */ - // String[] ranks = SCANConfig.getInstance().getRankColumns(scanTable); - // - // for (String rankStr : ranks) { - // MenuItem mi = new MenuItem(rankPopupMenu, SWT.NONE); - // mi.setText(rankStr); - // mi.setData(rankStr); - // mi.addSelectionListener(new SelectionAdapter() { - // @Override - // public void widgetSelected(SelectionEvent event) { - // handleRankMenuEvent(event); - // } - // }); - // } - // - // rankBtn.setMenu(rankPopupMenu); - // } - /** * Display the Create/Edit trend dialog. */ @@ -893,9 +852,6 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements linkToFrameChk.getSelection()); IMonitorConfigurationEvent imce = new IMonitorConfigurationEvent(this); this.fireConfigUpdate(imce); - - // System.out.println("######## Link to frame is : " + - // linkToFrameChk.getSelection()); } /** @@ -925,15 +881,6 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements } } - /** - * Shell close action. - */ - @Override - protected void shellCloseAction() { - // TODO Auto-generated method stub - - } - /** * Shell dispose action. */ @@ -970,7 +917,6 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements @Override protected void setShellText() { shell.setText(this.site + " DMD Table"); - } /** @@ -994,19 +940,14 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements public void notify(IMonitorEvent me) { if (me.getSource() instanceof IMonitor) { ScanMonitor scan = (ScanMonitor) me.getSource(); - Date time = null; - try { - if (getLinkToFrame(scanTable.name())) { - time = (scan).getScanTime(scanTable, site); - } else { - time = (scan).getMostRecent(scan, scanTable.name(), site) - .getRefTime(); - } - } catch (Exception e) { - statusHandler.handle(Priority.ERROR, "Unable to retrieve time", - e); + + // If scan is null return since nothing will be done. + if (scan == null) { + return; } + Date time = getScanTime(scan); + if ((time != null) && scan.isInstantiated()) { ScanDataGenerator sdg = new ScanDataGenerator(site); ScanTableData data = null; @@ -1070,7 +1011,9 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements && currentTime.equals(scan.getMostRecent(scan, scanTable.name(), site).getRefTime()) && !scanCfg.getAlarmsDisabled(scanTable)) { - dmdTableComp.checkBlink(sdg, scan.getMostRecent(scan, scanTable.name(), site).getRefTime()); + dmdTableComp.checkBlink(sdg, + scan.getMostRecent(scan, scanTable.name(), site) + .getRefTime()); if (mgr.getAlertedAlarms(site, scanTable).size() > 0) { alarmBtn.setVisible(true); addAlarmTimer(); @@ -1298,19 +1241,21 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements dmdTableComp.alarmSelection(ident); } - - public void turnOffAlarm() { - if (alarmBtn != null && !alarmBtn.isDisposed()) { - alarmBtn.setVisible(false); - } - mgr.setRing(false); - } + @Override + public void turnOffAlarm() { + if (alarmBtn != null && !alarmBtn.isDisposed()) { + alarmBtn.setVisible(false); + } + mgr.setRing(false); + } + + @Override public void turnOnAlarm() { - if (alarmBtn != null && !alarmBtn.isDisposed()) { - alarmBtn.setVisible(true); - } + if (alarmBtn != null && !alarmBtn.isDisposed()) { + alarmBtn.setVisible(true); + } mgr.setRing(true); - } + } } diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANMesoTableComp.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANMesoTableComp.java index 6d6f5df076..35aa8612bb 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANMesoTableComp.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANMesoTableComp.java @@ -20,7 +20,6 @@ package com.raytheon.uf.viz.monitor.scan.tables; import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.TableItem; @@ -38,6 +37,7 @@ import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 2, 2009 #3039 lvenable Initial creation + * Apr 29, 2013 #1945 lvenable Code cleanup for SCAN performance. * * * @@ -45,11 +45,6 @@ import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables; * @version 1.0 */ public class SCANMesoTableComp extends SCANTable { - // private Point mouseMovePt = new Point(0, 0); - - private Point mouseDownPt = new Point(0, 0); - - // private Point prevMousePt = new Point(-9999, -9999); /** * Constructor. @@ -68,49 +63,6 @@ public class SCANMesoTableComp extends SCANTable { init(); } - /** - * Set the column images for the table columns. - */ - // @Override - // protected void setColumnImages() { - // TableColumn[] tCols = table.getColumns(); - // - // for (int i = 0; i < tCols.length; i++) { - // String colName = (String) tCols[i].getData(); - // Image img = new Image(this.getDisplay(), imageWidth, imageHeight); - // - // GC gc = new GC(img); - // gc.setFont(columnFont); - // - // // Set the initial foreground and background colors. - // gc.setForeground(this.getDisplay().getSystemColor(SWT.COLOR_WHITE)); - // gc.setBackground(this.getDisplay().getSystemColor(SWT.COLOR_BLACK)); - // - // // Set the background color to the sort color if that column is - // // sorted. - // if (sortedColumnIndex == -1) { - // scanCfg.getDefaultName(); - // String sortColName = scanCfg.getDefaultRank(this.scanTable); - // int colIndex = scanCfg.getColumnIndex(scanTable, sortColName); - // sortedColumnIndex = colIndex; - // } - // if (table.indexOf(tCols[i]) == sortedColumnIndex) { - // gc.setBackground(scanCfg.getScanColor(ScanColors.Sort)); - // } - // - // gc.fillRectangle(0, 0, imageWidth, imageHeight); - // - // int xCoord = (imageWidth / 2) - (colName.length() * textWidth / 2); - // - // gc.drawText(colName, xCoord, 3, true); - // - // gc.dispose(); - // tCols[i].setImage(img); - // - // img.dispose(); - // } - // } - @Override protected void tableMouseDownAction(MouseEvent event) { mouseDownPt.x = event.x; @@ -154,13 +106,4 @@ public class SCANMesoTableComp extends SCANTable { } } } - - // @Override - // protected void tableMouseMoveAction(MouseEvent event) { - // /* - // * The legacy system has tool tip text indicating trend dialogs can be - // * launched but that is not the case. There should not be tool tip text - // * at this time. - // */ - // } } diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANMesoTableDlg.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANMesoTableDlg.java index e837e49f45..a2dead5a7b 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANMesoTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANMesoTableDlg.java @@ -60,9 +60,29 @@ import com.raytheon.uf.viz.monitor.scan.commondialogs.SCANAttributesDlg; import com.raytheon.uf.viz.monitor.scan.commondialogs.SCANColorThreshDlg; import com.raytheon.uf.viz.monitor.scan.data.ScanDataGenerator; +/** + * + * Scan dialog for the MESO table. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 29, 2013 #1945      lvenable    Code cleanup for SCAN performance.
+ * 
+ * 
+ * + * @author lvenable + * @version 1.0 + */ public class SCANMesoTableDlg extends AbstractTableDlg implements IAttributeUpdate, IThresholdUpdate { + /* + * Buttons at the top of the dialog and the popup menus. + */ private Button configBtn; private Button rankBtn; @@ -96,6 +116,16 @@ public class SCANMesoTableDlg extends AbstractTableDlg implements private Date currentTime = null; + /** + * Constructor. + * + * @param parentShell + * Parent shell. + * @param site + * Site name. + * @param tableData + * Data to be displayed in the table. + */ public SCANMesoTableDlg(Shell parentShell, String site, SCANTableData tableData) { super(parentShell); @@ -221,11 +251,16 @@ public class SCANMesoTableDlg extends AbstractTableDlg implements vertChk.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); vertChk.setSelection(mesoCfgMgr.getScanMesoCfgXML().getFilterOption()); vertChk.setLayoutData(gd); - vertChk.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - } - }); + + /* + * The vertical table is a techblocked DR. This selection listener will + * be commented out until it is needed. + */ + // vertChk.addSelectionListener(new SelectionAdapter() { + // @Override + // public void widgetSelected(SelectionEvent e) { + // } + // }); setupButtonMouseListeners(vertChk); gd = new GridData(); @@ -353,47 +388,6 @@ public class SCANMesoTableDlg extends AbstractTableDlg implements configBtn.setMenu(configPopupMenu); } - // private void createRankPopupMenu() { - // rankPopupMenu = new Menu(rankBtn); - - // TODO : need to handle default ranking in the list... MESO -- mdaSR - - /* - * Default menu item - */ - // MenuItem defaultMI = new MenuItem(rankPopupMenu, SWT.NONE); - // defaultMI.setText(SCANConfig.getInstance().getDefaultName()); - // defaultMI.setData(SCANConfig.getInstance().getDefaultName()); - // defaultMI.setEnabled(false); - // defaultMI.addSelectionListener(new SelectionAdapter() - // { - // @Override - // public void widgetSelected(SelectionEvent event) - // { - // handleRankMenuEvent(event); - // } - // }); - // - /* - * Create the remaining rank menus from the configuration - */ - // String[] ranks = SCANConfig.getInstance().getRankColumns(scanTable); - // - // for (String rankStr : ranks) { - // MenuItem mi = new MenuItem(rankPopupMenu, SWT.NONE); - // mi.setText(rankStr); - // mi.setData(rankStr); - // mi.addSelectionListener(new SelectionAdapter() { - // @Override - // public void widgetSelected(SelectionEvent event) { - // handleRankMenuEvent(event); - // } - // }); - // } - // - // rankBtn.setMenu(rankPopupMenu); - // } - private void displayAttributesDialog() { if ((attributeDlg == null) || (attributeDlg.getParent().isDisposed() == true)) { @@ -459,12 +453,6 @@ public class SCANMesoTableDlg extends AbstractTableDlg implements this.fireDialogShutdown(this); } - @Override - protected void shellCloseAction() { - // TODO : this method may be deleted from the abstract - // class if it is not needed - } - @Override protected void shellDisposeAction() { shell.addDisposeListener(new DisposeListener() { @@ -474,16 +462,6 @@ public class SCANMesoTableDlg extends AbstractTableDlg implements unregisterDialogFromMonitor(); } }); - - // shell.addShellListener(new ShellAdapter() - // { - // @Override - // public void shellClosed(ShellEvent e) - // { - // System.out.println("MESO dialog SHELL CLOSED"); - // unregisterDialog(); - // } - // }); } @Override @@ -506,36 +484,29 @@ public class SCANMesoTableDlg extends AbstractTableDlg implements @Override public void notify(IMonitorEvent me) { if (me.getSource() instanceof IMonitor) { - // System.out.println("SCAN MESO Table Notify Event Received"); ScanMonitor scan = (ScanMonitor) me.getSource(); - Date time = null; - try { - if (getLinkToFrame(scanTable.name())) { - time = scan.getScanTime(scanTable, site); - } else { - time = scan.getMostRecent(scan, scanTable.name(), site) - .getRefTime(); - } - } catch (Exception e) { + + // If scan is null return since nothing will be done. + if (scan == null || scanTableComp.isDisposed()) { + return; } + + Date time = getScanTime(scan); + if (time != null) { ScanDataGenerator sdg = new ScanDataGenerator(site); - // scanTableComp.setTableData(sdg.generateMesoData(scan - // .getTableData(ScanTables.MESO, time))); ScanTableData data = scan.getTableData(ScanTables.MESO, site, time); - if (!scanTableComp.isDisposed()) { - scanTableComp.setTableData(sdg.generateMesoData(data)); - setShellText(); - if (getLinkToFrame(scanTable.name())) { - currentTime = scan.getDialogTime(scanTable, site); - } else { - currentTime = time; - } - updateTimeLabel(); + scanTableComp.setTableData(sdg.generateMesoData(data)); + + if (getLinkToFrame(scanTable.name())) { + currentTime = scan.getDialogTime(scanTable, site); + } else { + currentTime = time; } + updateTimeLabel(); } } } @@ -647,14 +618,14 @@ public class SCANMesoTableDlg extends AbstractTableDlg implements return false; } - @Override - public void turnOffAlarm() { - mgr.setRing(false); - } + @Override + public void turnOffAlarm() { + mgr.setRing(false); + } - @Override - public void turnOnAlarm() { - mgr.setRing(true); - } + @Override + public void turnOnAlarm() { + mgr.setRing(true); + } } diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANTable.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANTable.java index 2ed9667086..88a5372425 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANTable.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANTable.java @@ -62,15 +62,26 @@ import com.raytheon.uf.viz.monitor.scan.ScanMonitor; import com.raytheon.uf.viz.monitor.scan.data.ScanDataGenerator; import com.raytheon.uf.viz.monitor.scan.tables.SCANAlarmAlertManager.AlertedAlarms; -/* Modification History: - * Date Ticket# Name Change - * ------------ ---------- ------------ -------------------------- - * 02/23/2012 14538 Xiaochuan Fix TVS table default rank. +/** * - * 03/15/2012 13939 Mike Duff For a SCAN Alarms issue - * + * Abstract scan table class used for the CELL, DMD, MESO, and TVS tables.. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * 02/23/2012   14538      Xiaochuan   Fix TVS table default rank.
+ * 03/15/2012   13939      Mike Duff   For a SCAN Alarms issue
+ * Apr 29, 2013 #1945      lvenable    Improved SCAN performance, reworked
+ *                                     some bad code, and some code cleanup.
+ * 
+ * 
+ * + * @author lvenable + * @version 1.0 */ - public abstract class SCANTable extends Composite { protected Table table; @@ -140,6 +151,24 @@ public abstract class SCANTable extends Composite { protected Point prevMousePt = new Point(-9999, -9999); + /** + * Last sorted column index. This is set to -2 because sortedColumnIndex is + * set to -1 and they should not have the same initial value at start up. + */ + protected int lastSortColIndex = -2; + + /** + * Constructor. + * + * @param parent + * Parent composite. + * @param tableData + * Data to be display into the table. + * @param tableActionCB + * Callback when the table is clicked. + * @param site + * Site name. + */ public SCANTable(Composite parent, SCANTableData tableData, ITableAction tableActionCB, String site) { super(parent, 0); @@ -176,8 +205,6 @@ public abstract class SCANTable extends Composite { createTableItems(); - // packColumns(); - sortedColumnIndex = -1; sortTableUsingConfig(); @@ -185,6 +212,7 @@ public abstract class SCANTable extends Composite { showHideTableColumns(); this.addDisposeListener(new DisposeListener() { + @Override public void widgetDisposed(DisposeEvent arg0) { if ((scanTable == ScanTables.CELL) || (scanTable == ScanTables.DMD)) { @@ -209,11 +237,6 @@ public abstract class SCANTable extends Composite { gd.heightHint = 175; gd.widthHint = scanCfg.getDefaultTableWidth(scanTable); - // ********************************************************** - // ********************************************************** - // ********************************************************** - // ********************************************************** - boolean[] visCols = scanCfg.getVisibleColumns(scanTable); int tableWidth = 0; @@ -223,17 +246,6 @@ public abstract class SCANTable extends Composite { } } - System.out.println("widthHint = " + gd.widthHint); - System.out.println("tableWidth = " + tableWidth); - - // ********************************************************** - // ********************************************************** - // ********************************************************** - // ********************************************************** - // ********************************************************** - - // table = new Table(this, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL - // | SWT.FULL_SELECTION); table = new Table(this, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); table.setLayoutData(gd); table.setHeaderVisible(true); @@ -243,13 +255,9 @@ public abstract class SCANTable extends Composite { gc.dispose(); table.addListener(SWT.PaintItem, new Listener() { + @Override public void handleEvent(Event event) { - // if (scanTable != ScanTables.CELL) { - // // System.out.println("scanTable = " + scanTable.name()); - // // System.out.println("in paintListener"); - // } - if (tableData.getTableRows().size() != 0) { table.deselectAll(); event.gc.setForeground(lineColor); @@ -262,10 +270,7 @@ public abstract class SCANTable extends Composite { rect.height); // Draw an extra line on the edges of the table cell to hide - // the - // white lines - // dividing the columns; - // event.gc.setLineWidth(2); + // the white lines dividing the columns; event.gc.drawLine(rect.x + rect.width - 2, rect.y - 1, rect.x + rect.width - 2, rect.y - 1 + rect.height); @@ -284,9 +289,6 @@ public abstract class SCANTable extends Composite { } } else { - // System.out.println("scanTable = " + scanTable.name()); - // System.out.println("event.index = " + event.index); - if ((event.index >= 0) || (event.index <= 6)) { int offset = 0; @@ -299,7 +301,6 @@ public abstract class SCANTable extends Composite { event.gc.setForeground(getParent().getShell() .getDisplay().getSystemColor(SWT.COLOR_GREEN)); - // event.gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); int y = event.y + (event.height - extent.y) / 2; event.gc.drawString(noDataStr, event.x - offset, y); @@ -357,7 +358,6 @@ public abstract class SCANTable extends Composite { @Override public void widgetSelected(SelectionEvent event) { tableColumnSelectAction(event); - } }); @@ -380,13 +380,6 @@ public abstract class SCANTable extends Composite { } setColumnImages(); - - // - // TODO : Rank is default so we have to sort by the default - fix this - // - // TableColumn stc = table.getColumn(0); - - // TODO : Will need to fix with the default ranking sortedColumnIndex = -1; } @@ -545,15 +538,14 @@ public abstract class SCANTable extends Composite { tableData = td; if ((tableData == null) || (tableData.getTableRows().size() == 0)) { - // System.out.println("*** no data"); - // table.setEnabled(true); + table.removeAll(); /* * This TableItem is needed to draw "No Detections" on. Do not * remove it. */ - TableItem item = new TableItem(table, SWT.NONE); + new TableItem(table, SWT.NONE); table.setBackground(getParent().getShell().getDisplay() .getSystemColor(SWT.COLOR_BLACK)); @@ -629,10 +621,10 @@ public abstract class SCANTable extends Composite { return; } - if( scanTable == ScanTables.TVS && sortedIndex == -1) - { + if (scanTable == ScanTables.TVS && sortedIndex == -1) { sortedIndex = TVSTable.valueOf("IDENT").ordinal(); } + // get the ident, if a row is outlined in blue if (tableIndex >= 0) { SCANTableRowData stdr = tableData.getTableRows().get(tableIndex); @@ -670,12 +662,9 @@ public abstract class SCANTable extends Composite { } else { tableData.sortDefault(); } + createTableItems(); - // packColumns(); - - showHideTableColumns(); - if (timer != null) { timer.cancel(); } @@ -684,11 +673,14 @@ public abstract class SCANTable extends Composite { } ScanDataGenerator sdg = new ScanDataGenerator(site); - if ((scanTable == ScanTables.CELL) || ((scanTable == ScanTables.DMD) - && !mgr.getAlertedAlarms(site, scanTable).isEmpty())) { + if ((scanTable == ScanTables.CELL) + || ((scanTable == ScanTables.DMD) && !mgr.getAlertedAlarms( + site, scanTable).isEmpty())) { ScanMonitor monitor = ScanMonitor.getInstance(); if (monitor.getMostRecent(monitor, scanTable.name(), site) != null) { - checkBlink(sdg, monitor.getMostRecent(monitor, scanTable.name(), site).getRefTime()); + checkBlink(sdg, + monitor.getMostRecent(monitor, scanTable.name(), site) + .getRefTime()); } } @@ -753,7 +745,6 @@ public abstract class SCANTable extends Composite { private void packSingleColumn(TableColumn tc, int index) { tc.pack(); - // tCols[i].setWidth(table.getColumn(i).getWidth() + 5); tc.setWidth(table.getColumn(index).getWidth() + 2); if (tc.getWidth() > defaultColWidth) { @@ -791,20 +782,11 @@ public abstract class SCANTable extends Composite { maxTextLength = colNames[i].length(); } - // System.out.println("--- column name = " + colNames[i]); - // System.out.println("--- extent = " + - // gc.stringExtent(colNames[i])); - if (gc.stringExtent(colNames[i]).x > maxColNameExtent) { maxColNameExtent = gc.stringExtent(colNames[i]).x; } } - // System.out.println("maxColNameExtent = " + maxColNameExtent + " - " - // + scanTable.name()); - - // imageWidth = maxTextLength * textWidth + 6; - // imageWidth = maxColNameExtent + 2; imageWidth = maxColNameExtent; imageHeight = textHeight + 4; @@ -812,6 +794,9 @@ public abstract class SCANTable extends Composite { image.dispose(); } + /** + * Update the column tooltip text. + */ public void updateColumnTips() { if (scanCfg.showTips(scanTable) == false) { TableColumn[] tCols = table.getColumns(); @@ -827,8 +812,6 @@ public abstract class SCANTable extends Composite { (String) tCols[i].getData())); } } - - // TODO - need the column tool tip text to be set } /** @@ -919,6 +902,7 @@ public abstract class SCANTable extends Composite { @Override public void run() { Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { runTimerTask(); } @@ -932,6 +916,7 @@ public abstract class SCANTable extends Composite { @Override public void run() { Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { // Fail-safe check to determine if the we have no @@ -966,9 +951,7 @@ public abstract class SCANTable extends Composite { private void runTimerTask() { // Fail-safe check to determine if the we have - // no - // data - // in the table data. + // no data in the table data. if ((timer != null) && (tableData != null)) { if (tableData.getTableRows().size() == 0) { if (timer != null) { @@ -986,27 +969,26 @@ public abstract class SCANTable extends Composite { boolean allClear = true; ArrayList points = new ArrayList(); - Set alarmList = mgr.getAlertedAlarms(site, scanTable); - for (int i = 0; i < tableData - .getNumberOfDataRows(); i++) { + Set alarmList = mgr.getAlertedAlarms(site, + scanTable); + for (int i = 0; i < tableData.getNumberOfDataRows(); i++) { TableItem ti = table.getItem(i); if (ti == null) { continue; } if ((alarmList != null) && (alarmList.size() > 0)) { - for (AlertedAlarms alarm: alarmList) { - if (tableData.getTableRows().get(i).getIdent().equals(alarm.ident)) { + for (AlertedAlarms alarm : alarmList) { + if (tableData.getTableRows().get(i).getIdent() + .equals(alarm.ident)) { if (alarm.cleared == false) { ti.setBackground(alarm.col, blinkColor); allClear = false; // handle the beep while // looking at // all the cells - if (SCANConfig - .getInstance() - .getAlarmBell( - scanTable)) { + if (SCANConfig.getInstance().getAlarmBell( + scanTable)) { mgr.setRing(true); } } else { @@ -1016,10 +998,9 @@ public abstract class SCANTable extends Composite { } } } - + for (int i = 0; i < points.size(); i++) { - updateThresholds(points.get(i).x, - points.get(i).y); + updateThresholds(points.get(i).x, points.get(i).y); } // checks if there are no more alarms @@ -1030,9 +1011,9 @@ public abstract class SCANTable extends Composite { timer.purge(); } } - } + } } - + public Timer getBlinkTimer() { if (timer == null) { timer = new Timer(); @@ -1056,6 +1037,9 @@ public abstract class SCANTable extends Composite { blinkColor = Display.getDefault().getSystemColor(blinkColorInt); } + /** + * Redraw the table. + */ public void redrawTable() { table.redraw(); } @@ -1066,6 +1050,14 @@ public abstract class SCANTable extends Composite { * DMD do this). */ protected void setColumnImages() { + /* + * If the sort column hasn't changed then return because the images will + * not change. + */ + if (lastSortColIndex == sortedColumnIndex) { + return; + } + TableColumn[] tCols = table.getColumns(); for (int i = 0; i < tCols.length; i++) { @@ -1082,13 +1074,16 @@ public abstract class SCANTable extends Composite { // Set the background color to the sort color if that column is // sorted. - // sortedColumnIndex=-1 is default sort + // sortedColumnIndex=-1 is default sort if (sortedColumnIndex == -1) { scanCfg.getDefaultName(); String sortColName = scanCfg.getDefaultRank(this.scanTable); int colIndex = scanCfg.getColumnIndex(scanTable, sortColName); sortedColumnIndex = colIndex; } + + lastSortColIndex = sortedColumnIndex; + if (table.indexOf(tCols[i]) == sortedColumnIndex) { gc.setBackground(scanCfg.getScanColor(ScanColors.Sort)); } @@ -1124,7 +1119,6 @@ public abstract class SCANTable extends Composite { } Rectangle rect; - // rect = item.getBounds(table.getColumnCount() - 1); rect = item.getBounds(scanCfg.getCountyColumnIndex(scanTable)); if ((scanCfg.showTips(scanTable) == false) @@ -1229,5 +1223,4 @@ public abstract class SCANTable extends Composite { * Mouse event. */ protected abstract void tableMouseDownAction(MouseEvent event); - } diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANTvsTableComp.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANTvsTableComp.java index 0b694e0471..b0efbdd72f 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANTvsTableComp.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANTvsTableComp.java @@ -20,7 +20,6 @@ package com.raytheon.uf.viz.monitor.scan.tables; import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.TableItem; @@ -38,6 +37,7 @@ import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 3, 2009 #3039 lvenable Initial creation + * Apr 29, 2013 #1945 lvenable Code cleanup for SCAN performance. * * * @@ -45,12 +45,19 @@ import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables; * @version 1.0 */ public class SCANTvsTableComp extends SCANTable { - private Point mouseMovePt = new Point(0, 0); - - private Point mouseDownPt = new Point(0, 0); - - private Point prevMousePt = new Point(-9999, -9999); + /** + * Constructor. + * + * @param parent + * Parent composite. + * @param tableData + * Data to be displayed in the table. + * @param tableActionCB + * Callback called when the table is clicked. + * @param site + * The site name. + */ public SCANTvsTableComp(Composite parent, SCANTableData tableData, ITableAction tableActionCB, String site) { super(parent, tableData, tableActionCB, site); @@ -58,46 +65,6 @@ public class SCANTvsTableComp extends SCANTable { init(); } - // @Override - // protected void setColumnImages() { - // TableColumn[] tCols = table.getColumns(); - // - // for (int i = 0; i < tCols.length; i++) { - // String colName = (String) tCols[i].getData(); - // Image img = new Image(this.getDisplay(), imageWidth, imageHeight); - // - // GC gc = new GC(img); - // gc.setFont(columnFont); - // - // // Set the initial foreground and background colors. - // gc.setForeground(this.getDisplay().getSystemColor(SWT.COLOR_WHITE)); - // gc.setBackground(this.getDisplay().getSystemColor(SWT.COLOR_BLACK)); - // - // // Set the background color to the sort color if that column is - // // sorted. - // if (sortedColumnIndex == -1) { - // scanCfg.getDefaultName(); - // String sortColName = scanCfg.getDefaultRank(this.scanTable); - // int colIndex = scanCfg.getColumnIndex(scanTable, sortColName); - // sortedColumnIndex = colIndex; - // } - // if (table.indexOf(tCols[i]) == sortedColumnIndex) { - // gc.setBackground(scanCfg.getScanColor(ScanColors.Sort)); - // } - // - // gc.fillRectangle(0, 0, imageWidth, imageHeight); - // - // int xCoord = (imageWidth / 2) - (colName.length() * textWidth / 2); - // - // gc.drawText(colName, xCoord, 3, true); - // - // gc.dispose(); - // tCols[i].setImage(img); - // - // img.dispose(); - // } - // } - @Override protected void tableMouseDownAction(MouseEvent event) { mouseDownPt.x = event.x; @@ -140,12 +107,4 @@ public class SCANTvsTableComp extends SCANTable { } } } - - // @Override - // protected void tableMouseMoveAction(MouseEvent event) { - // /* - // * TODO: Looking at the WES the TVS table is empty. Need to look at the - // * legacy code to determine if there are tool tip texts for the cells. - // */ - // } } diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANTvsTableDlg.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANTvsTableDlg.java index aca8b68deb..fe76b4800e 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANTvsTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/tables/SCANTvsTableDlg.java @@ -59,6 +59,23 @@ import com.raytheon.uf.viz.monitor.scan.commondialogs.SCANAttributesDlg; import com.raytheon.uf.viz.monitor.scan.commondialogs.SCANColorThreshDlg; import com.raytheon.uf.viz.monitor.scan.data.ScanDataGenerator; +/** + * + * Dialog for the SCAN TVS table. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 29, 2013 #1945      lvenable    Code cleanup for SCAN performance.
+ * 
+ * 
+ * + * @author lvenable + * @version 1.0 + */ public class SCANTvsTableDlg extends AbstractTableDlg implements IAttributeUpdate, IThresholdUpdate { private Button configBtn; @@ -91,6 +108,16 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements private Date currentTime = null; + /** + * Constructor. + * + * @param parentShell + * Parent shell. + * @param site + * Site name. + * @param tableData + * Tabel data. + */ public SCANTvsTableDlg(Shell parentShell, String site, SCANTableData tableData) { super(parentShell); @@ -215,11 +242,16 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements vertChk.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); vertChk.setSelection(tvsCfgMgr.getScanTvsCfgXML().getFilterOption()); vertChk.setLayoutData(gd); - vertChk.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - } - }); + + /* + * The vertical table is a techblocked DR. This selection listener will + * be commented out until it is needed. + */ + // vertChk.addSelectionListener(new SelectionAdapter() { + // @Override + // public void widgetSelected(SelectionEvent e) { + // } + // }); setupButtonMouseListeners(vertChk); gd = new GridData(); @@ -347,47 +379,6 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements configBtn.setMenu(configPopupMenu); } - // private void createRankPopupMenu() { - // rankPopupMenu = new Menu(rankBtn); - - // TODO : need to handle default ranking in the list... MESO -- mdaSR - - /* - * Default menu item - */ - // MenuItem defaultMI = new MenuItem(rankPopupMenu, SWT.NONE); - // defaultMI.setText(SCANConfig.getInstance().getDefaultName()); - // defaultMI.setData(SCANConfig.getInstance().getDefaultName()); - // defaultMI.setEnabled(false); - // defaultMI.addSelectionListener(new SelectionAdapter() - // { - // @Override - // public void widgetSelected(SelectionEvent event) - // { - // handleRankMenuEvent(event); - // } - // }); - // - /* - * Create the remaining rank menus from the configuration - */ - // String[] ranks = SCANConfig.getInstance().getRankColumns(scanTable); - // - // for (String rankStr : ranks) { - // MenuItem mi = new MenuItem(rankPopupMenu, SWT.NONE); - // mi.setText(rankStr); - // mi.setData(rankStr); - // mi.addSelectionListener(new SelectionAdapter() { - // @Override - // public void widgetSelected(SelectionEvent event) { - // handleRankMenuEvent(event); - // } - // }); - // } - // - // rankBtn.setMenu(rankPopupMenu); - // } - private void displayAttributesDialog() { if ((attributeDlg == null) || (attributeDlg.getParent().isDisposed() == true)) { @@ -451,18 +442,11 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements this.fireDialogShutdown(this); } - @Override - protected void shellCloseAction() { - // TODO : this method may be deleted from the abstract - // class if it is not needed - } - @Override protected void shellDisposeAction() { shell.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { - System.out.println("TVS dialog DISPOSED"); unregisterDialogFromMonitor(); } }); @@ -470,7 +454,6 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements shell.addShellListener(new ShellAdapter() { @Override public void shellClosed(ShellEvent e) { - System.out.println("TVS dialog SHELL CLOSED"); unregisterDialogFromMonitor(); } }); @@ -496,35 +479,47 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements @Override public void notify(IMonitorEvent me) { if (me.getSource() instanceof IMonitor) { - // System.out.println("SCAN TVS Table Notify Event Received"); ScanMonitor scan = (ScanMonitor) me.getSource(); - Date time = null; - try { - if (getLinkToFrame(scanTable.name())) { - time = scan.getScanTime(scanTable, site); - } else { - time = scan.getMostRecent(scan, scanTable.name(), site) - .getRefTime(); - } - } catch (Exception e) { - } - if (time != null && !scanTableComp.isDisposed()) { - ScanDataGenerator sdg = new ScanDataGenerator(site); - scanTableComp.setTableData(sdg.generateTVSData(scan - .getTableData(ScanTables.TVS, site, time))); - setShellText(); + // If scan is null or the scan table has been disposed then return + // since nothing will be done. + if (scan == null || scanTableComp.isDisposed()) { + return; + } + + Date time = getScanTime(scan); + + if (time != null) { + if (getLinkToFrame(scanTable.name())) { currentTime = scan.getDialogTime(scanTable, site); + updateTimeLabel(); + updateTable(scan, time); } else { - currentTime = time; + if (currentTime == null || !currentTime.equals(time)) { + currentTime = time; + updateTimeLabel(); + updateTable(scan, time); + } } - updateTimeLabel(); - // System.out.println("SCAN TVS Table Updated Time Label"); } } } + /** + * Update the table with new data. + * + * @param scan + * Scan Monitor. + * @param time + * New time. + */ + private void updateTable(ScanMonitor scan, Date time) { + ScanDataGenerator sdg = new ScanDataGenerator(site); + scanTableComp.setTableData(sdg.generateTVSData(scan.getTableData( + ScanTables.TVS, site, time))); + } + @Override public void centerByIdent(String ident) { fireRecenter(ident, ScanTables.TVS, site); @@ -590,9 +585,11 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements // NOT USED } + /* + * Update the threshold in the composite contained in this dialog for the + * desired attribute in the dialog. + */ @Override - // Update the threshold in the composite contained in this dialog for the - // desired attribute in the dialog. public void updateThresh(String attr) { this.scanTableComp.updateThresholds(attr); } @@ -610,13 +607,13 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements return false; } - @Override - public void turnOffAlarm() { - mgr.setRing(false); - } + @Override + public void turnOffAlarm() { + mgr.setRing(false); + } - @Override - public void turnOnAlarm() { - mgr.setRing(true); - } + @Override + public void turnOnAlarm() { + mgr.setRing(true); + } }