Merge "Issue #1945 - SCAN performance improvements and code cleanup." into omaha_13.4.1

Former-commit-id: 0b3a75f01d44718505fe10916e3381a9c5e21103
This commit is contained in:
Lee Venable 2013-04-29 16:10:53 -05:00 committed by Gerrit Code Review
commit 1ef7b8264b
10 changed files with 467 additions and 756 deletions

View file

@ -50,6 +50,7 @@ import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.monitor.scan.config.SCANConfig; import com.raytheon.uf.common.monitor.scan.config.SCANConfig;
import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables; 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.core.alerts.AlertMessage;
import com.raytheon.uf.viz.monitor.IMonitor; import com.raytheon.uf.viz.monitor.IMonitor;
import com.raytheon.uf.viz.monitor.Monitor; 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 * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 21, 2009 #3039 lvenable Initial creation * Nov 21, 2009 #3039 lvenable Initial creation
* Apr 26, 2013 #1945 lvenable Some code cleanup.
* *
* </pre> * </pre>
* *
@ -179,14 +181,10 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor,
initData(); initData();
// fileButtonTipText = "Current Config:\n" +
// scanCfg.getCurrentConfigFileName(scanTable);
setShellText(); setShellText();
setTableType(); setTableType();
initComponents(); initComponents();
shellCloseAction();
shellDisposeAction(); shellDisposeAction();
shell.pack(); shell.pack();
@ -260,7 +258,6 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor,
} }
// Loop and close all of the open dialogs; // Loop and close all of the open dialogs;
Set<ICommonDialogAction> keys = dialogsMap.keySet(); Set<ICommonDialogAction> keys = dialogsMap.keySet();
for (ICommonDialogAction icda : keys) { for (ICommonDialogAction icda : keys) {
@ -476,6 +473,29 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor,
fileBtn.setToolTipText(fileButtonTipText); 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 @Override
public void addMonitorControlListener(IMonitor monitor) { public void addMonitorControlListener(IMonitor monitor) {
getMonitorControlListeners().add(monitor); getMonitorControlListeners().add(monitor);
@ -491,6 +511,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor,
public void fireConfigUpdate(IMonitorConfigurationEvent imce) { public void fireConfigUpdate(IMonitorConfigurationEvent imce) {
final IMonitorConfigurationEvent fimce = imce; final IMonitorConfigurationEvent fimce = imce;
Display.getDefault().asyncExec(new Runnable() { Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() { public void run() {
Iterator<IMonitor> iter = getMonitorControlListeners() Iterator<IMonitor> iter = getMonitorControlListeners()
.iterator(); .iterator();
@ -504,6 +525,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor,
@Override @Override
public void fireKillMonitor() { public void fireKillMonitor() {
Display.getDefault().asyncExec(new Runnable() { Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() { public void run() {
Iterator<IMonitor> iter = getMonitorControlListeners() Iterator<IMonitor> iter = getMonitorControlListeners()
.iterator(); .iterator();
@ -518,6 +540,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor,
public void fireThresholdUpdate(IMonitorThresholdEvent imte) { public void fireThresholdUpdate(IMonitorThresholdEvent imte) {
final IMonitorThresholdEvent fimte = imte; final IMonitorThresholdEvent fimte = imte;
Display.getDefault().asyncExec(new Runnable() { Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() { public void run() {
Iterator<IMonitor> iter = getMonitorControlListeners() Iterator<IMonitor> iter = getMonitorControlListeners()
.iterator(); .iterator();
@ -534,8 +557,8 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor,
* @param ident * @param ident
* @param type * @param type
*/ */
public TrendGraphData getTrendGraphData(ScanTables type, public TrendGraphData getTrendGraphData(ScanTables type, String field,
String field, String ident) { String ident) {
TrendGraphData tgd = null; TrendGraphData tgd = null;
Iterator<IMonitor> iter = getMonitorControlListeners().iterator(); Iterator<IMonitor> iter = getMonitorControlListeners().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
@ -572,6 +595,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor,
final ScanTables ftype = type; final ScanTables ftype = type;
final String ficao = icao; final String ficao = icao;
Display.getDefault().asyncExec(new Runnable() { Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() { public void run() {
Iterator<IMonitor> iter = getMonitorControlListeners() Iterator<IMonitor> iter = getMonitorControlListeners()
.iterator(); .iterator();
@ -590,6 +614,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor,
*/ */
public void fireScanPaint() { public void fireScanPaint() {
Display.getDefault().asyncExec(new Runnable() { Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() { public void run() {
Iterator<IMonitor> iter = getMonitorControlListeners() Iterator<IMonitor> iter = getMonitorControlListeners()
.iterator(); .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 // TODO: What needs to be done here is to grab the current selected
// trend set // trend set and fire a trend set for the passed in ID and table
// and fire a trend set for the passed in ID and table
// this will mean firing a get graphData Event back to the monitor // this will mean firing a get graphData Event back to the monitor
System.out.println("Trend Set requested: " + type + " : " + ident);
} }
@Override @Override
@ -635,6 +658,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor,
@Override @Override
public void fireDialogShutdown(IMonitorListener iml) { public void fireDialogShutdown(IMonitorListener iml) {
Display.getDefault().asyncExec(new Runnable() { Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() { public void run() {
Iterator<IMonitor> iter = getMonitorControlListeners() Iterator<IMonitor> iter = getMonitorControlListeners()
.iterator(); .iterator();
@ -646,8 +670,8 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor,
} }
@Override @Override
public TrendGraphData requestTrendGraphData(ScanTables type, public TrendGraphData requestTrendGraphData(ScanTables type, String field,
String field, String ident) { String ident) {
return getTrendGraphData(type, field, 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 * used to notify updates of data to display elements from classes that
* implement the IMonitor interface. * implement the IMonitor interface.
*/ */
@Override
public void fireMonitorEvent() { public void fireMonitorEvent() {
return; return;
} }
@ -694,6 +719,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor,
* listener class as an argument that can be used for targeted * listener class as an argument that can be used for targeted
* notifications. * notifications.
*/ */
@Override
public void fireMonitorEvent(String type) { public void fireMonitorEvent(String type) {
return; 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 * used to notify updates of data to display elements from classes that
* implement the IMonitor interface. * implement the IMonitor interface.
*/ */
@Override
public void fireMonitorEvent(Monitor monitor) { public void fireMonitorEvent(Monitor monitor) {
return; return;
} }
@ -712,6 +739,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor,
* *
* @param pluginName * @param pluginName
*/ */
@Override
public void initObserver(String pluginName, Monitor monitor) { public void initObserver(String pluginName, Monitor monitor) {
return; return;
} }
@ -722,6 +750,7 @@ public abstract class AbstractTableDlg extends Dialog implements IMonitor,
* @param type * @param type
* @return * @return
*/ */
@Override
public ArrayList<Date> getTimeOrderedKeys(IMonitor monitor, String type) { public ArrayList<Date> getTimeOrderedKeys(IMonitor monitor, String type) {
return monitor.getTimeOrderedKeys(monitor, 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. * Abstract methods to be implemented by classes extending this class.
*/ */
@Override
public abstract void notify(IMonitorEvent me); public abstract void notify(IMonitorEvent me);
public abstract void displayTrendSetGraphs(String ident); 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 initComponents();
// protected abstract void update();
protected abstract void setShellText(); protected abstract void setShellText();
protected abstract void shellCloseAction();
protected abstract void shellDisposeAction(); protected abstract void shellDisposeAction();
protected abstract void updateAfterConfigLoad(); 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 updateThresh(String attr);
public abstract void turnOffAlarm(); public abstract void turnOffAlarm();
public abstract void turnOnAlarm(); public abstract void turnOnAlarm();
} }

View file

@ -44,6 +44,7 @@ import com.raytheon.uf.viz.monitor.scan.commondialogs.IRequestTrendGraphData;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Dec 3, 2009 #3039 lvenable Initial creation * Dec 3, 2009 #3039 lvenable Initial creation
* Apr 29, 2013 #1945 lvenable Code cleanup for SCAN performance.
* *
* </pre> * </pre>
* *
@ -59,13 +60,28 @@ public class SCANCellTableComp extends SCANTableTrendGraphLayer {
private static final String UNWARNED_SVR_TOOLTIP = "\nA storm meeting Severe " private static final String UNWARNED_SVR_TOOLTIP = "\nA storm meeting Severe "
+ "Weather warning\ncriteria is outside any SVR warning polygon."; + "Weather warning\ncriteria is outside any SVR warning polygon.";
// private Point mouseMovePt = new Point(0, 0); /** Radius interpolation column name. */
// private String radVarColName = "";
// private Point mouseDownPt = new Point(0, 0);
//
// private Point prevMousePt = new Point(-9999, -9999);
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) { IRequestTrendGraphData requestDataCallback, String site) {
super(parent, tableData, tableActionCB, requestDataCallback, site); super(parent, tableData, tableActionCB, requestDataCallback, site);
@ -105,22 +121,24 @@ public class SCANCellTableComp extends SCANTableTrendGraphLayer {
if (colIndex == 0) { if (colIndex == 0) {
tableIndex = rowIndex; tableIndex = rowIndex;
if ((tableIndex >= 0) || (tableIndex > table.getItemCount())) { if ((tableIndex >= 0) || (tableIndex > table.getItemCount())) {
tableActionCB.centerByStormId(table.getItem(tableIndex).getText()); tableActionCB.centerByStormId(table.getItem(tableIndex)
.getText());
redrawTable(); redrawTable();
} }
} else { } else {
String name = (String) table.getColumn(colIndex).getData(); String name = (String) table.getColumn(colIndex).getData();
if (scanCfg.canViewTrend(scanTable, name) == true) { 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); displayTrendGraphDialog(ident, name);
} }
} }
} else if (event.button == 3) { } else if (event.button == 3) {
if (colIndex == 0) { if (colIndex == 0) {
String ident = tableData.getTableRows().get(rowIndex).getTableCellData(0).getCellText(); String ident = tableData.getTableRows().get(rowIndex)
.getTableCellData(0).getCellText();
displayTrendSetsGraphDialog(ident); displayTrendSetsGraphDialog(ident);
} }
} }
@ -141,10 +159,10 @@ public class SCANCellTableComp extends SCANTableTrendGraphLayer {
} }
Rectangle rect; Rectangle rect;
// rect = item.getBounds(table.getColumnCount() - 1);
rect = item.getBounds(scanCfg.getCountyColumnIndex(scanTable)); 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.x = -9999;
prevMousePt.y = -9999; prevMousePt.y = -9999;
table.setToolTipText(null); table.setToolTipText(null);
@ -162,17 +180,22 @@ public class SCANCellTableComp extends SCANTableTrendGraphLayer {
prevMousePt.x = mouseMovePt.x; prevMousePt.x = mouseMovePt.x;
prevMousePt.y = mouseMovePt.y; 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) { 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) { if (wt == WARN_TYPE.SEVERE) {
toolTip = toolTip.concat(UNWARNED_SVR_TOOLTIP); toolTip = toolTip.concat(UNWARNED_SVR_TOOLTIP);
} else if (wt == WARN_TYPE.TVS) { } else if (wt == WARN_TYPE.TVS) {
toolTip = toolTip.concat(UNWARNED_TOR_TOOLTIP); toolTip = toolTip.concat(UNWARNED_TOR_TOOLTIP);
} }
} else if (((String) table.getColumn(i).getData()).equals(CELLTable.COUNTY.getColName())) { } else if (((String) table.getColumn(i).getData())
toolTip = tableData.getTableRows().get(table.indexOf(item)).getTableCellData(i).getCellText(); .equals(CELLTable.COUNTY.getColName())) {
toolTip = tableData.getTableRows().get(table.indexOf(item))
.getTableCellData(i).getCellText();
} }
table.setToolTipText(toolTip); table.setToolTipText(toolTip);
@ -191,6 +214,17 @@ public class SCANCellTableComp extends SCANTableTrendGraphLayer {
*/ */
@Override @Override
protected void setColumnImages() { 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(); TableColumn[] tCols = table.getColumns();
for (int i = 0; i < tCols.length; i++) { for (int i = 0; i < tCols.length; i++) {
@ -215,13 +249,16 @@ public class SCANCellTableComp extends SCANTableTrendGraphLayer {
*/ */
if (scanCfg.isRadVar(scanTable, colName) == true) { if (scanCfg.isRadVar(scanTable, colName) == true) {
radVarColName = colName;
gc.setBackground(scanCfg.getScanColor(ScanColors.RadVar)); gc.setBackground(scanCfg.getScanColor(ScanColors.RadVar));
} }
// Set the foreground color to the clutter control color if the // 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) { 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 // 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)); gc.setBackground(scanCfg.getScanColor(ScanColors.Sort));
} }
lastSortColIndex = sortedColumnIndex;
gc.fillRectangle(0, 0, imageWidth, imageHeight); gc.fillRectangle(0, 0, imageWidth, imageHeight);
int colNameExt = gc.stringExtent(colName).x; int colNameExt = gc.stringExtent(colName).x;
// int xCoord = (imageWidth / 2) - (colName.length() * textWidth /
// 2);
int xCoord = (imageWidth / 2) - (colNameExt / 2); int xCoord = (imageWidth / 2) - (colNameExt / 2);
gc.drawText(colName, xCoord, 3, true); gc.drawText(colName, xCoord, 3, true);

View file

@ -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.MESOTable;
import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanColors; 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.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.IMonitor;
import com.raytheon.uf.viz.monitor.events.IMonitorConfigurationEvent; import com.raytheon.uf.viz.monitor.events.IMonitorConfigurationEvent;
import com.raytheon.uf.viz.monitor.events.IMonitorEvent; 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 * Nov 21, 2009 #3039 lvenable Initial creation
* *
* 03/15/2012 13939 Mike Duff For a SCAN Alarms issue * 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.
* *
* </pre> * </pre>
* *
@ -99,7 +102,7 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
private boolean killDialog = false; private boolean killDialog = false;
/* /*
* Action button at the top of the dialog. * Action buttons at the top of the dialog.
*/ */
private Button configBtn; private Button configBtn;
@ -180,6 +183,10 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
private SCANAlarmsDlg alarmDlg = null; private SCANAlarmsDlg alarmDlg = null;
/** Date format for the time label. */
private SimpleDateFormat dateFmt = new SimpleDateFormat(
"E MMM dd HH:mm yyyy");
/** /**
* Constructor. * Constructor.
* *
@ -209,6 +216,7 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
*/ */
@Override @Override
protected void initComponents() { protected void initComponents() {
dateFmt.setTimeZone(TimeZone.getTimeZone("GMT"));
createTopControls(); createTopControls();
createCellTable(); createCellTable();
createFilePopupMenu(); createFilePopupMenu();
@ -231,7 +239,7 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
} }
/** /**
* * Add an alarm timer.
*/ */
private void addAlarmTimer() { private void addAlarmTimer() {
if (scanTableComp.timer != null) { if (scanTableComp.timer != null) {
@ -239,6 +247,7 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
@Override @Override
public void run() { public void run() {
Display.getDefault().asyncExec(new Runnable() { Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() { public void run() {
if (shell.isDisposed()) { if (shell.isDisposed()) {
scanTableComp.timer.cancel(); scanTableComp.timer.cancel();
@ -437,11 +446,16 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
vertChk.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); vertChk.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
vertChk.setSelection(cellCfgMgr.getScanCellCfgXML().getFilterOption()); vertChk.setSelection(cellCfgMgr.getScanCellCfgXML().getFilterOption());
vertChk.setLayoutData(gd); 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); setupButtonMouseListeners(vertChk);
gd = new GridData(); gd = new GridData();
@ -475,7 +489,7 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
alarmDlg.open(); alarmDlg.open();
if (!alarmBtn.isDisposed() if (!alarmBtn.isDisposed()
&& (mgr.getAlertedAlarmCount(site, scanTable) == 0)) { && (mgr.getAlertedAlarmCount(site, scanTable) == 0)) {
turnOffAlarm(); turnOffAlarm();
} }
} }
}); });
@ -489,52 +503,19 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
@Override @Override
public void turnOffAlarm() { public void turnOffAlarm() {
if (alarmBtn != null && !alarmBtn.isDisposed()) { if (alarmBtn != null && !alarmBtn.isDisposed()) {
alarmBtn.setVisible(false); alarmBtn.setVisible(false);
} }
mgr.setRing(false); mgr.setRing(false);
} }
@Override @Override
public void turnOnAlarm() { public void turnOnAlarm() {
if (alarmBtn != null && !alarmBtn.isDisposed()) { if (alarmBtn != null && !alarmBtn.isDisposed()) {
alarmBtn.setVisible(true); alarmBtn.setVisible(true);
} }
mgr.setRing(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. * 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); fileBtn.setMenu(filePopupMenu);
} }
@ -903,6 +871,7 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
*/ */
private void displayMesoTableDialog() { private void displayMesoTableDialog() {
Display.getDefault().asyncExec(new Runnable() { Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() { public void run() {
Iterator<IMonitor> iter = getMonitorControlListeners() Iterator<IMonitor> iter = getMonitorControlListeners()
.iterator(); .iterator();
@ -921,6 +890,7 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
*/ */
private void displayTvsTableDialog() { private void displayTvsTableDialog() {
Display.getDefault().asyncExec(new Runnable() { Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() { public void run() {
Iterator<IMonitor> iter = getMonitorControlListeners() Iterator<IMonitor> iter = getMonitorControlListeners()
.iterator(); .iterator();
@ -943,8 +913,6 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
return; return;
} }
SimpleDateFormat dateFmt = new SimpleDateFormat("E MMM dd HH:mm yyyy");
dateFmt.setTimeZone(TimeZone.getTimeZone("GMT"));
timeLbl.setText(dateFmt.format(currentTime)); timeLbl.setText(dateFmt.format(currentTime));
} }
@ -1012,144 +980,6 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
mb.open(); 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. * Shell dispose action.
*/ */
@ -1164,7 +994,6 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
@Override @Override
public void shellClosed(ShellEvent e) { public void shellClosed(ShellEvent e) {
e.doit = killDialog; e.doit = killDialog;
// unregisterDialog();
} }
}); });
} }
@ -1186,6 +1015,22 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
shell.setText(this.site + " CELL Table"); 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. * Notify when the table data needs to be updated.
*/ */
@ -1193,18 +1038,15 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
public void notify(IMonitorEvent me) { public void notify(IMonitorEvent me) {
if (me.getSource() instanceof IMonitor) { if (me.getSource() instanceof IMonitor) {
ScanMonitor scan = (ScanMonitor) me.getSource(); ScanMonitor scan = (ScanMonitor) me.getSource();
Date time = null;
try { // If scan is null return since nothing will be done.
if (getLinkToFrame(scanTable.name())) { if (scan == null) {
time = scan.getScanTime(scanTable, site); return;
} else {
time = scan.getMostRecent(scan, scanTable.name(), site)
.getRefTime();
}
} catch (Exception e) {
} }
if ((time != null) && (scan != null)) { Date time = getScanTime(scan);
if ((time != null)) {
ScanDataGenerator sdg = new ScanDataGenerator(site); ScanDataGenerator sdg = new ScanDataGenerator(site);
@ -1218,21 +1060,18 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
sdg.setUnwarnedCells(warnings); sdg.setUnwarnedCells(warnings);
} }
tableData = sdg.generateCellData((scan).getTableData(scanTable,
site, time));
scanTableComp.setTableData(tableData);
setShellText();
if (getLinkToFrame(scanTable.name())) { if (getLinkToFrame(scanTable.name())) {
currentTime = scan.getDialogTime(scanTable, site);
currentTime = (scan).getDialogTime(scanTable, site); updateTimeLabel();
updateTable(scan, time, sdg);
} else { } else {
currentTime = time; if (currentTime == null || !currentTime.equals(time)) {
currentTime = time;
updateTimeLabel();
updateTable(scan, time, sdg);
}
} }
updateTimeLabel();
scan.fireMonitorEvent(SCANMesoTableDlg.class.getName()); scan.fireMonitorEvent(SCANMesoTableDlg.class.getName());
scan.fireMonitorEvent(SCANTvsTableDlg.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 // closes the alarm dialog if new data comes in or user switches
// frame // frame
Date scanMostRecentTime = null; Date scanMostRecentTime = null;
try { DataTime dataTime = scan.getMostRecent(scan, scanTable.name(),
scanMostRecentTime = scan.getMostRecent(scan, site);
scanTable.name(), site).getRefTime(); if (dataTime != null) {
} catch (NullPointerException npe) { scanMostRecentTime = dataTime.getRefTime();
// scan has been turned off
} }
if (scanMostRecentTime != null) { if (scanMostRecentTime != null) {
@ -1265,13 +1103,14 @@ public class SCANCellTableDlg extends AbstractTableDlg implements
scanTableComp.checkBlink(sdg, scanMostRecentTime); scanTableComp.checkBlink(sdg, scanMostRecentTime);
if (mgr.getAlertedAlarms(site, scanTable).size() > 0) { if (mgr.getAlertedAlarms(site, scanTable).size() > 0) {
boolean displayAlarmBtn = false; boolean displayAlarmBtn = false;
for (AlertedAlarms alarm: mgr.getAlertedAlarms(site, scanTable)) { for (AlertedAlarms alarm : mgr.getAlertedAlarms(
site, scanTable)) {
if (!alarm.cleared) { if (!alarm.cleared) {
displayAlarmBtn = true; displayAlarmBtn = true;
break; break;
} }
} }
alarmBtn.setVisible(displayAlarmBtn); alarmBtn.setVisible(displayAlarmBtn);
addAlarmTimer(); addAlarmTimer();
} else { } else {

View file

@ -27,7 +27,6 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseEvent;
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.Point;
import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableColumn;
@ -55,6 +54,8 @@ import com.raytheon.uf.viz.monitor.scan.commondialogs.TimeHeightDlg;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Dec 3, 2009 #3039 lvenable Initial creation * Dec 3, 2009 #3039 lvenable Initial creation
* Apr 26, 2013 #1945 lvenable Improved SCAN performance, reworked
* some bad code, and some code cleanup.
* *
* </pre> * </pre>
* *
@ -63,16 +64,14 @@ import com.raytheon.uf.viz.monitor.scan.commondialogs.TimeHeightDlg;
*/ */
public class SCANDmdTableComp extends SCANTableTrendGraphLayer implements public class SCANDmdTableComp extends SCANTableTrendGraphLayer implements
IRequestTimeHeightData { 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 TimeHeightDlg timeHeightDlg = null;
private IRequestTimeHeightData timeHeightCB; private IRequestTimeHeightData timeHeightCB;
/** Clutter control column name. */
private String clutterColName = "";
public SCANDmdTableComp(Composite parent, SCANTableData tableData, public SCANDmdTableComp(Composite parent, SCANTableData tableData,
ITableAction tableActionCB, ITableAction tableActionCB,
IRequestTrendGraphData requestDataCallback, IRequestTrendGraphData requestDataCallback,
@ -85,6 +84,15 @@ public class SCANDmdTableComp extends SCANTableTrendGraphLayer implements
@Override @Override
protected void setColumnImages() { 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(); TableColumn[] tCols = table.getColumns();
for (int i = 0; i < tCols.length; i++) { 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)); gc.setBackground(this.getDisplay().getSystemColor(SWT.COLOR_BLACK));
// Set the foreground color to the clutter control color if the // Set the foreground color to the clutter control color if the
// column // column is a clutter control.
// is a clutter control.
if (scanCfg.isClutterControl(scanTable, colName) == true) { if (scanCfg.isClutterControl(scanTable, colName) == true) {
clutterColName = colName;
gc.setForeground(scanCfg gc.setForeground(scanCfg
.getScanColor(ScanColors.ClutterControl)); .getScanColor(ScanColors.ClutterControl));
} }
@ -120,12 +128,12 @@ public class SCANDmdTableComp extends SCANTableTrendGraphLayer implements
gc.setBackground(scanCfg.getScanColor(ScanColors.Sort)); gc.setBackground(scanCfg.getScanColor(ScanColors.Sort));
} }
lastSortColIndex = sortedColumnIndex;
gc.fillRectangle(0, 0, imageWidth, imageHeight); gc.fillRectangle(0, 0, imageWidth, imageHeight);
int colNameExt = gc.stringExtent(colName).x; int colNameExt = gc.stringExtent(colName).x;
// int xCoord = (imageWidth / 2) - (colName.length() * textWidth /
// 2);
int xCoord = (imageWidth / 2) - (colNameExt / 2); int xCoord = (imageWidth / 2) - (colNameExt / 2);
gc.drawText(colName, xCoord, 3, true); gc.drawText(colName, xCoord, 3, true);
@ -201,12 +209,6 @@ public class SCANDmdTableComp extends SCANTableTrendGraphLayer implements
@Override @Override
protected void tableMouseMoveAction(MouseEvent event) { 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.x = event.x;
mouseMovePt.y = event.y; mouseMovePt.y = event.y;
@ -219,7 +221,6 @@ public class SCANDmdTableComp extends SCANTableTrendGraphLayer implements
} }
Rectangle rect; Rectangle rect;
// rect = item.getBounds(table.getColumnCount() - 2);
rect = item.getBounds(scanCfg.getCountyColumnIndex(scanTable)); rect = item.getBounds(scanCfg.getCountyColumnIndex(scanTable));
if ((scanCfg.showTips(scanTable) == false) if ((scanCfg.showTips(scanTable) == false)
@ -282,9 +283,9 @@ public class SCANDmdTableComp extends SCANTableTrendGraphLayer implements
public void redrawTimeHeightGraph() { public void redrawTimeHeightGraph() {
if ((timeHeightDlg == null) || timeHeightDlg.isDisposed()) { if ((timeHeightDlg == null) || timeHeightDlg.isDisposed()) {
return; return;
} else {
timeHeightDlg.redrawGraph();
} }
timeHeightDlg.redrawGraph();
} }
public boolean timeHeightDisplayed() { public boolean timeHeightDisplayed() {

View file

@ -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.monitor.scan.config.SCANConfigEnums.ScanTables;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.monitor.IMonitor; import com.raytheon.uf.viz.monitor.IMonitor;
import com.raytheon.uf.viz.monitor.events.IMonitorConfigurationEvent; import com.raytheon.uf.viz.monitor.events.IMonitorConfigurationEvent;
import com.raytheon.uf.viz.monitor.events.IMonitorEvent; import com.raytheon.uf.viz.monitor.events.IMonitorEvent;
@ -90,6 +89,8 @@ import com.raytheon.viz.ui.EditorUtil;
* Apr 29, 2010 lvenable Initial creation * Apr 29, 2010 lvenable Initial creation
* *
* 03/15/2012 13939 Mike Duff For a SCAN Alarms issue * 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.
* *
* </pre> * </pre>
* *
@ -315,6 +316,7 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements
@Override @Override
public void run() { public void run() {
Display.getDefault().asyncExec(new Runnable() { Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() { public void run() {
if (shell.isDisposed()) { if (shell.isDisposed()) {
dmdTableComp.timer.cancel(); dmdTableComp.timer.cancel();
@ -473,11 +475,16 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements
vertChk.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); vertChk.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
vertChk.setSelection(dmdConfigMgr.getScanDmdCfgXML().getFilterOption()); vertChk.setSelection(dmdConfigMgr.getScanDmdCfgXML().getFilterOption());
vertChk.setLayoutData(gd); 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); setupButtonMouseListeners(vertChk);
gd = new GridData(); gd = new GridData();
@ -514,7 +521,7 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements
alarmsDlg.open(); alarmsDlg.open();
if (!alarmBtn.isDisposed() if (!alarmBtn.isDisposed()
&& mgr.getAlertedAlarms(site, scanTable).isEmpty()) { && 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 = new GridData(SWT.DEFAULT, SWT.CENTER, false, true);
gd.widthHint = 135; gd.widthHint = 135;
elevationLbl = new Label(controlComp, SWT.CENTER | SWT.BORDER); elevationLbl = new Label(controlComp, SWT.CENTER | SWT.BORDER);
elevationLbl.setText("* No Elevation *"); // TODO - need to add elevationLbl.setText("* No Elevation *");
// elevation
elevationLbl.setBackground(elevationLabelColor); elevationLbl.setBackground(elevationLabelColor);
elevationLbl.setLayoutData(gd); elevationLbl.setLayoutData(gd);
@ -677,53 +683,6 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements
configBtn.setMenu(configPopupMenu); 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. * Display the Create/Edit trend dialog.
*/ */
@ -893,9 +852,6 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements
linkToFrameChk.getSelection()); linkToFrameChk.getSelection());
IMonitorConfigurationEvent imce = new IMonitorConfigurationEvent(this); IMonitorConfigurationEvent imce = new IMonitorConfigurationEvent(this);
this.fireConfigUpdate(imce); 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. * Shell dispose action.
*/ */
@ -970,7 +917,6 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements
@Override @Override
protected void setShellText() { protected void setShellText() {
shell.setText(this.site + " DMD Table"); shell.setText(this.site + " DMD Table");
} }
/** /**
@ -994,19 +940,14 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements
public void notify(IMonitorEvent me) { public void notify(IMonitorEvent me) {
if (me.getSource() instanceof IMonitor) { if (me.getSource() instanceof IMonitor) {
ScanMonitor scan = (ScanMonitor) me.getSource(); ScanMonitor scan = (ScanMonitor) me.getSource();
Date time = null;
try { // If scan is null return since nothing will be done.
if (getLinkToFrame(scanTable.name())) { if (scan == null) {
time = (scan).getScanTime(scanTable, site); return;
} else {
time = (scan).getMostRecent(scan, scanTable.name(), site)
.getRefTime();
}
} catch (Exception e) {
statusHandler.handle(Priority.ERROR, "Unable to retrieve time",
e);
} }
Date time = getScanTime(scan);
if ((time != null) && scan.isInstantiated()) { if ((time != null) && scan.isInstantiated()) {
ScanDataGenerator sdg = new ScanDataGenerator(site); ScanDataGenerator sdg = new ScanDataGenerator(site);
ScanTableData<?> data = null; ScanTableData<?> data = null;
@ -1070,7 +1011,9 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements
&& currentTime.equals(scan.getMostRecent(scan, && currentTime.equals(scan.getMostRecent(scan,
scanTable.name(), site).getRefTime()) scanTable.name(), site).getRefTime())
&& !scanCfg.getAlarmsDisabled(scanTable)) { && !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) { if (mgr.getAlertedAlarms(site, scanTable).size() > 0) {
alarmBtn.setVisible(true); alarmBtn.setVisible(true);
addAlarmTimer(); addAlarmTimer();
@ -1298,19 +1241,21 @@ public class SCANDmdTableDlg extends AbstractTableDlg implements
dmdTableComp.alarmSelection(ident); 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() { public void turnOnAlarm() {
if (alarmBtn != null && !alarmBtn.isDisposed()) { if (alarmBtn != null && !alarmBtn.isDisposed()) {
alarmBtn.setVisible(true); alarmBtn.setVisible(true);
} }
mgr.setRing(true); mgr.setRing(true);
} }
} }

View file

@ -20,7 +20,6 @@
package com.raytheon.uf.viz.monitor.scan.tables; package com.raytheon.uf.viz.monitor.scan.tables;
import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.TableItem;
@ -38,6 +37,7 @@ import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Dec 2, 2009 #3039 lvenable Initial creation * Dec 2, 2009 #3039 lvenable Initial creation
* Apr 29, 2013 #1945 lvenable Code cleanup for SCAN performance.
* *
* </pre> * </pre>
* *
@ -45,11 +45,6 @@ import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables;
* @version 1.0 * @version 1.0
*/ */
public class SCANMesoTableComp extends SCANTable { 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. * Constructor.
@ -68,49 +63,6 @@ public class SCANMesoTableComp extends SCANTable {
init(); 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 @Override
protected void tableMouseDownAction(MouseEvent event) { protected void tableMouseDownAction(MouseEvent event) {
mouseDownPt.x = event.x; 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.
// */
// }
} }

View file

@ -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.commondialogs.SCANColorThreshDlg;
import com.raytheon.uf.viz.monitor.scan.data.ScanDataGenerator; import com.raytheon.uf.viz.monitor.scan.data.ScanDataGenerator;
/**
*
* Scan dialog for the MESO table.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 29, 2013 #1945 lvenable Code cleanup for SCAN performance.
*
* </pre>
*
* @author lvenable
* @version 1.0
*/
public class SCANMesoTableDlg extends AbstractTableDlg implements public class SCANMesoTableDlg extends AbstractTableDlg implements
IAttributeUpdate, IThresholdUpdate { IAttributeUpdate, IThresholdUpdate {
/*
* Buttons at the top of the dialog and the popup menus.
*/
private Button configBtn; private Button configBtn;
private Button rankBtn; private Button rankBtn;
@ -96,6 +116,16 @@ public class SCANMesoTableDlg extends AbstractTableDlg implements
private Date currentTime = null; 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, public SCANMesoTableDlg(Shell parentShell, String site,
SCANTableData tableData) { SCANTableData tableData) {
super(parentShell); super(parentShell);
@ -221,11 +251,16 @@ public class SCANMesoTableDlg extends AbstractTableDlg implements
vertChk.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); vertChk.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
vertChk.setSelection(mesoCfgMgr.getScanMesoCfgXML().getFilterOption()); vertChk.setSelection(mesoCfgMgr.getScanMesoCfgXML().getFilterOption());
vertChk.setLayoutData(gd); 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); setupButtonMouseListeners(vertChk);
gd = new GridData(); gd = new GridData();
@ -353,47 +388,6 @@ public class SCANMesoTableDlg extends AbstractTableDlg implements
configBtn.setMenu(configPopupMenu); 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() { private void displayAttributesDialog() {
if ((attributeDlg == null) if ((attributeDlg == null)
|| (attributeDlg.getParent().isDisposed() == true)) { || (attributeDlg.getParent().isDisposed() == true)) {
@ -459,12 +453,6 @@ public class SCANMesoTableDlg extends AbstractTableDlg implements
this.fireDialogShutdown(this); this.fireDialogShutdown(this);
} }
@Override
protected void shellCloseAction() {
// TODO : this method may be deleted from the abstract
// class if it is not needed
}
@Override @Override
protected void shellDisposeAction() { protected void shellDisposeAction() {
shell.addDisposeListener(new DisposeListener() { shell.addDisposeListener(new DisposeListener() {
@ -474,16 +462,6 @@ public class SCANMesoTableDlg extends AbstractTableDlg implements
unregisterDialogFromMonitor(); unregisterDialogFromMonitor();
} }
}); });
// shell.addShellListener(new ShellAdapter()
// {
// @Override
// public void shellClosed(ShellEvent e)
// {
// System.out.println("MESO dialog SHELL CLOSED");
// unregisterDialog();
// }
// });
} }
@Override @Override
@ -506,36 +484,29 @@ public class SCANMesoTableDlg extends AbstractTableDlg implements
@Override @Override
public void notify(IMonitorEvent me) { public void notify(IMonitorEvent me) {
if (me.getSource() instanceof IMonitor) { if (me.getSource() instanceof IMonitor) {
// System.out.println("SCAN MESO Table Notify Event Received");
ScanMonitor scan = (ScanMonitor) me.getSource(); ScanMonitor scan = (ScanMonitor) me.getSource();
Date time = null;
try { // If scan is null return since nothing will be done.
if (getLinkToFrame(scanTable.name())) { if (scan == null || scanTableComp.isDisposed()) {
time = scan.getScanTime(scanTable, site); return;
} else {
time = scan.getMostRecent(scan, scanTable.name(), site)
.getRefTime();
}
} catch (Exception e) {
} }
Date time = getScanTime(scan);
if (time != null) { if (time != null) {
ScanDataGenerator sdg = new ScanDataGenerator(site); ScanDataGenerator sdg = new ScanDataGenerator(site);
// scanTableComp.setTableData(sdg.generateMesoData(scan
// .getTableData(ScanTables.MESO, time)));
ScanTableData<?> data = scan.getTableData(ScanTables.MESO, ScanTableData<?> data = scan.getTableData(ScanTables.MESO,
site, time); site, time);
if (!scanTableComp.isDisposed()) { scanTableComp.setTableData(sdg.generateMesoData(data));
scanTableComp.setTableData(sdg.generateMesoData(data));
setShellText(); if (getLinkToFrame(scanTable.name())) {
if (getLinkToFrame(scanTable.name())) { currentTime = scan.getDialogTime(scanTable, site);
currentTime = scan.getDialogTime(scanTable, site); } else {
} else { currentTime = time;
currentTime = time;
}
updateTimeLabel();
} }
updateTimeLabel();
} }
} }
} }
@ -647,14 +618,14 @@ public class SCANMesoTableDlg extends AbstractTableDlg implements
return false; return false;
} }
@Override @Override
public void turnOffAlarm() { public void turnOffAlarm() {
mgr.setRing(false); mgr.setRing(false);
} }
@Override @Override
public void turnOnAlarm() { public void turnOnAlarm() {
mgr.setRing(true); mgr.setRing(true);
} }
} }

View file

@ -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.data.ScanDataGenerator;
import com.raytheon.uf.viz.monitor.scan.tables.SCANAlarmAlertManager.AlertedAlarms; 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..
* *
* <pre>
*
* 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.
*
* </pre>
*
* @author lvenable
* @version 1.0
*/ */
public abstract class SCANTable extends Composite { public abstract class SCANTable extends Composite {
protected Table table; protected Table table;
@ -140,6 +151,24 @@ public abstract class SCANTable extends Composite {
protected Point prevMousePt = new Point(-9999, -9999); 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, public SCANTable(Composite parent, SCANTableData tableData,
ITableAction tableActionCB, String site) { ITableAction tableActionCB, String site) {
super(parent, 0); super(parent, 0);
@ -176,8 +205,6 @@ public abstract class SCANTable extends Composite {
createTableItems(); createTableItems();
// packColumns();
sortedColumnIndex = -1; sortedColumnIndex = -1;
sortTableUsingConfig(); sortTableUsingConfig();
@ -185,6 +212,7 @@ public abstract class SCANTable extends Composite {
showHideTableColumns(); showHideTableColumns();
this.addDisposeListener(new DisposeListener() { this.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent arg0) { public void widgetDisposed(DisposeEvent arg0) {
if ((scanTable == ScanTables.CELL) if ((scanTable == ScanTables.CELL)
|| (scanTable == ScanTables.DMD)) { || (scanTable == ScanTables.DMD)) {
@ -209,11 +237,6 @@ public abstract class SCANTable extends Composite {
gd.heightHint = 175; gd.heightHint = 175;
gd.widthHint = scanCfg.getDefaultTableWidth(scanTable); gd.widthHint = scanCfg.getDefaultTableWidth(scanTable);
// **********************************************************
// **********************************************************
// **********************************************************
// **********************************************************
boolean[] visCols = scanCfg.getVisibleColumns(scanTable); boolean[] visCols = scanCfg.getVisibleColumns(scanTable);
int tableWidth = 0; 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 = new Table(this, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
table.setLayoutData(gd); table.setLayoutData(gd);
table.setHeaderVisible(true); table.setHeaderVisible(true);
@ -243,13 +255,9 @@ public abstract class SCANTable extends Composite {
gc.dispose(); gc.dispose();
table.addListener(SWT.PaintItem, new Listener() { table.addListener(SWT.PaintItem, new Listener() {
@Override
public void handleEvent(Event event) { 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) { if (tableData.getTableRows().size() != 0) {
table.deselectAll(); table.deselectAll();
event.gc.setForeground(lineColor); event.gc.setForeground(lineColor);
@ -262,10 +270,7 @@ public abstract class SCANTable extends Composite {
rect.height); rect.height);
// Draw an extra line on the edges of the table cell to hide // Draw an extra line on the edges of the table cell to hide
// the // the white lines dividing the columns;
// white lines
// dividing the columns;
// event.gc.setLineWidth(2);
event.gc.drawLine(rect.x + rect.width - 2, rect.y - 1, event.gc.drawLine(rect.x + rect.width - 2, rect.y - 1,
rect.x + rect.width - 2, rect.y - 1 + rect.height); rect.x + rect.width - 2, rect.y - 1 + rect.height);
@ -284,9 +289,6 @@ public abstract class SCANTable extends Composite {
} }
} else { } else {
// System.out.println("scanTable = " + scanTable.name());
// System.out.println("event.index = " + event.index);
if ((event.index >= 0) || (event.index <= 6)) { if ((event.index >= 0) || (event.index <= 6)) {
int offset = 0; int offset = 0;
@ -299,7 +301,6 @@ public abstract class SCANTable extends Composite {
event.gc.setForeground(getParent().getShell() event.gc.setForeground(getParent().getShell()
.getDisplay().getSystemColor(SWT.COLOR_GREEN)); .getDisplay().getSystemColor(SWT.COLOR_GREEN));
// event.gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
int y = event.y + (event.height - extent.y) / 2; int y = event.y + (event.height - extent.y) / 2;
event.gc.drawString(noDataStr, event.x - offset, y); event.gc.drawString(noDataStr, event.x - offset, y);
@ -357,7 +358,6 @@ public abstract class SCANTable extends Composite {
@Override @Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
tableColumnSelectAction(event); tableColumnSelectAction(event);
} }
}); });
@ -380,13 +380,6 @@ public abstract class SCANTable extends Composite {
} }
setColumnImages(); 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; sortedColumnIndex = -1;
} }
@ -545,15 +538,14 @@ public abstract class SCANTable extends Composite {
tableData = td; tableData = td;
if ((tableData == null) || (tableData.getTableRows().size() == 0)) { if ((tableData == null) || (tableData.getTableRows().size() == 0)) {
// System.out.println("*** no data");
// table.setEnabled(true);
table.removeAll(); table.removeAll();
/* /*
* This TableItem is needed to draw "No Detections" on. Do not * This TableItem is needed to draw "No Detections" on. Do not
* remove it. * remove it.
*/ */
TableItem item = new TableItem(table, SWT.NONE); new TableItem(table, SWT.NONE);
table.setBackground(getParent().getShell().getDisplay() table.setBackground(getParent().getShell().getDisplay()
.getSystemColor(SWT.COLOR_BLACK)); .getSystemColor(SWT.COLOR_BLACK));
@ -629,10 +621,10 @@ public abstract class SCANTable extends Composite {
return; return;
} }
if( scanTable == ScanTables.TVS && sortedIndex == -1) if (scanTable == ScanTables.TVS && sortedIndex == -1) {
{
sortedIndex = TVSTable.valueOf("IDENT").ordinal(); sortedIndex = TVSTable.valueOf("IDENT").ordinal();
} }
// get the ident, if a row is outlined in blue // get the ident, if a row is outlined in blue
if (tableIndex >= 0) { if (tableIndex >= 0) {
SCANTableRowData stdr = tableData.getTableRows().get(tableIndex); SCANTableRowData stdr = tableData.getTableRows().get(tableIndex);
@ -670,12 +662,9 @@ public abstract class SCANTable extends Composite {
} else { } else {
tableData.sortDefault(); tableData.sortDefault();
} }
createTableItems(); createTableItems();
// packColumns();
showHideTableColumns();
if (timer != null) { if (timer != null) {
timer.cancel(); timer.cancel();
} }
@ -684,11 +673,14 @@ public abstract class SCANTable extends Composite {
} }
ScanDataGenerator sdg = new ScanDataGenerator(site); ScanDataGenerator sdg = new ScanDataGenerator(site);
if ((scanTable == ScanTables.CELL) || ((scanTable == ScanTables.DMD) if ((scanTable == ScanTables.CELL)
&& !mgr.getAlertedAlarms(site, scanTable).isEmpty())) { || ((scanTable == ScanTables.DMD) && !mgr.getAlertedAlarms(
site, scanTable).isEmpty())) {
ScanMonitor monitor = ScanMonitor.getInstance(); ScanMonitor monitor = ScanMonitor.getInstance();
if (monitor.getMostRecent(monitor, scanTable.name(), site) != null) { 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) { private void packSingleColumn(TableColumn tc, int index) {
tc.pack(); tc.pack();
// tCols[i].setWidth(table.getColumn(i).getWidth() + 5);
tc.setWidth(table.getColumn(index).getWidth() + 2); tc.setWidth(table.getColumn(index).getWidth() + 2);
if (tc.getWidth() > defaultColWidth) { if (tc.getWidth() > defaultColWidth) {
@ -791,20 +782,11 @@ public abstract class SCANTable extends Composite {
maxTextLength = colNames[i].length(); 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) { if (gc.stringExtent(colNames[i]).x > maxColNameExtent) {
maxColNameExtent = gc.stringExtent(colNames[i]).x; maxColNameExtent = gc.stringExtent(colNames[i]).x;
} }
} }
// System.out.println("maxColNameExtent = " + maxColNameExtent + " - "
// + scanTable.name());
// imageWidth = maxTextLength * textWidth + 6;
// imageWidth = maxColNameExtent + 2;
imageWidth = maxColNameExtent; imageWidth = maxColNameExtent;
imageHeight = textHeight + 4; imageHeight = textHeight + 4;
@ -812,6 +794,9 @@ public abstract class SCANTable extends Composite {
image.dispose(); image.dispose();
} }
/**
* Update the column tooltip text.
*/
public void updateColumnTips() { public void updateColumnTips() {
if (scanCfg.showTips(scanTable) == false) { if (scanCfg.showTips(scanTable) == false) {
TableColumn[] tCols = table.getColumns(); TableColumn[] tCols = table.getColumns();
@ -827,8 +812,6 @@ public abstract class SCANTable extends Composite {
(String) tCols[i].getData())); (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 @Override
public void run() { public void run() {
Display.getDefault().asyncExec(new Runnable() { Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() { public void run() {
runTimerTask(); runTimerTask();
} }
@ -932,6 +916,7 @@ public abstract class SCANTable extends Composite {
@Override @Override
public void run() { public void run() {
Display.getDefault().asyncExec(new Runnable() { Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() { public void run() {
// Fail-safe check to determine if the we have no // Fail-safe check to determine if the we have no
@ -966,9 +951,7 @@ public abstract class SCANTable extends Composite {
private void runTimerTask() { private void runTimerTask() {
// Fail-safe check to determine if the we have // Fail-safe check to determine if the we have
// no // no data in the table data.
// data
// in the table data.
if ((timer != null) && (tableData != null)) { if ((timer != null) && (tableData != null)) {
if (tableData.getTableRows().size() == 0) { if (tableData.getTableRows().size() == 0) {
if (timer != null) { if (timer != null) {
@ -986,27 +969,26 @@ public abstract class SCANTable extends Composite {
boolean allClear = true; boolean allClear = true;
ArrayList<Point> points = new ArrayList<Point>(); ArrayList<Point> points = new ArrayList<Point>();
Set<AlertedAlarms> alarmList = mgr.getAlertedAlarms(site, scanTable); Set<AlertedAlarms> alarmList = mgr.getAlertedAlarms(site,
for (int i = 0; i < tableData scanTable);
.getNumberOfDataRows(); i++) { for (int i = 0; i < tableData.getNumberOfDataRows(); i++) {
TableItem ti = table.getItem(i); TableItem ti = table.getItem(i);
if (ti == null) { if (ti == null) {
continue; continue;
} }
if ((alarmList != null) && (alarmList.size() > 0)) { if ((alarmList != null) && (alarmList.size() > 0)) {
for (AlertedAlarms alarm: alarmList) { for (AlertedAlarms alarm : alarmList) {
if (tableData.getTableRows().get(i).getIdent().equals(alarm.ident)) { if (tableData.getTableRows().get(i).getIdent()
.equals(alarm.ident)) {
if (alarm.cleared == false) { if (alarm.cleared == false) {
ti.setBackground(alarm.col, blinkColor); ti.setBackground(alarm.col, blinkColor);
allClear = false; allClear = false;
// handle the beep while // handle the beep while
// looking at // looking at
// all the cells // all the cells
if (SCANConfig if (SCANConfig.getInstance().getAlarmBell(
.getInstance() scanTable)) {
.getAlarmBell(
scanTable)) {
mgr.setRing(true); mgr.setRing(true);
} }
} else { } else {
@ -1016,10 +998,9 @@ public abstract class SCANTable extends Composite {
} }
} }
} }
for (int i = 0; i < points.size(); i++) { for (int i = 0; i < points.size(); i++) {
updateThresholds(points.get(i).x, updateThresholds(points.get(i).x, points.get(i).y);
points.get(i).y);
} }
// checks if there are no more alarms // checks if there are no more alarms
@ -1030,9 +1011,9 @@ public abstract class SCANTable extends Composite {
timer.purge(); timer.purge();
} }
} }
} }
} }
public Timer getBlinkTimer() { public Timer getBlinkTimer() {
if (timer == null) { if (timer == null) {
timer = new Timer(); timer = new Timer();
@ -1056,6 +1037,9 @@ public abstract class SCANTable extends Composite {
blinkColor = Display.getDefault().getSystemColor(blinkColorInt); blinkColor = Display.getDefault().getSystemColor(blinkColorInt);
} }
/**
* Redraw the table.
*/
public void redrawTable() { public void redrawTable() {
table.redraw(); table.redraw();
} }
@ -1066,6 +1050,14 @@ public abstract class SCANTable extends Composite {
* DMD do this). * DMD do this).
*/ */
protected void setColumnImages() { 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(); TableColumn[] tCols = table.getColumns();
for (int i = 0; i < tCols.length; i++) { 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 // Set the background color to the sort color if that column is
// sorted. // sorted.
// sortedColumnIndex=-1 is default sort // sortedColumnIndex=-1 is default sort
if (sortedColumnIndex == -1) { if (sortedColumnIndex == -1) {
scanCfg.getDefaultName(); scanCfg.getDefaultName();
String sortColName = scanCfg.getDefaultRank(this.scanTable); String sortColName = scanCfg.getDefaultRank(this.scanTable);
int colIndex = scanCfg.getColumnIndex(scanTable, sortColName); int colIndex = scanCfg.getColumnIndex(scanTable, sortColName);
sortedColumnIndex = colIndex; sortedColumnIndex = colIndex;
} }
lastSortColIndex = sortedColumnIndex;
if (table.indexOf(tCols[i]) == sortedColumnIndex) { if (table.indexOf(tCols[i]) == sortedColumnIndex) {
gc.setBackground(scanCfg.getScanColor(ScanColors.Sort)); gc.setBackground(scanCfg.getScanColor(ScanColors.Sort));
} }
@ -1124,7 +1119,6 @@ public abstract class SCANTable extends Composite {
} }
Rectangle rect; Rectangle rect;
// rect = item.getBounds(table.getColumnCount() - 1);
rect = item.getBounds(scanCfg.getCountyColumnIndex(scanTable)); rect = item.getBounds(scanCfg.getCountyColumnIndex(scanTable));
if ((scanCfg.showTips(scanTable) == false) if ((scanCfg.showTips(scanTable) == false)
@ -1229,5 +1223,4 @@ public abstract class SCANTable extends Composite {
* Mouse event. * Mouse event.
*/ */
protected abstract void tableMouseDownAction(MouseEvent event); protected abstract void tableMouseDownAction(MouseEvent event);
} }

View file

@ -20,7 +20,6 @@
package com.raytheon.uf.viz.monitor.scan.tables; package com.raytheon.uf.viz.monitor.scan.tables;
import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.TableItem;
@ -38,6 +37,7 @@ import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Dec 3, 2009 #3039 lvenable Initial creation * Dec 3, 2009 #3039 lvenable Initial creation
* Apr 29, 2013 #1945 lvenable Code cleanup for SCAN performance.
* *
* </pre> * </pre>
* *
@ -45,12 +45,19 @@ import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables;
* @version 1.0 * @version 1.0
*/ */
public class SCANTvsTableComp extends SCANTable { 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, public SCANTvsTableComp(Composite parent, SCANTableData tableData,
ITableAction tableActionCB, String site) { ITableAction tableActionCB, String site) {
super(parent, tableData, tableActionCB, site); super(parent, tableData, tableActionCB, site);
@ -58,46 +65,6 @@ public class SCANTvsTableComp extends SCANTable {
init(); 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 @Override
protected void tableMouseDownAction(MouseEvent event) { protected void tableMouseDownAction(MouseEvent event) {
mouseDownPt.x = event.x; 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.
// */
// }
} }

View file

@ -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.commondialogs.SCANColorThreshDlg;
import com.raytheon.uf.viz.monitor.scan.data.ScanDataGenerator; import com.raytheon.uf.viz.monitor.scan.data.ScanDataGenerator;
/**
*
* Dialog for the SCAN TVS table.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 29, 2013 #1945 lvenable Code cleanup for SCAN performance.
*
* </pre>
*
* @author lvenable
* @version 1.0
*/
public class SCANTvsTableDlg extends AbstractTableDlg implements public class SCANTvsTableDlg extends AbstractTableDlg implements
IAttributeUpdate, IThresholdUpdate { IAttributeUpdate, IThresholdUpdate {
private Button configBtn; private Button configBtn;
@ -91,6 +108,16 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements
private Date currentTime = null; private Date currentTime = null;
/**
* Constructor.
*
* @param parentShell
* Parent shell.
* @param site
* Site name.
* @param tableData
* Tabel data.
*/
public SCANTvsTableDlg(Shell parentShell, String site, public SCANTvsTableDlg(Shell parentShell, String site,
SCANTableData tableData) { SCANTableData tableData) {
super(parentShell); super(parentShell);
@ -215,11 +242,16 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements
vertChk.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); vertChk.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
vertChk.setSelection(tvsCfgMgr.getScanTvsCfgXML().getFilterOption()); vertChk.setSelection(tvsCfgMgr.getScanTvsCfgXML().getFilterOption());
vertChk.setLayoutData(gd); 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); setupButtonMouseListeners(vertChk);
gd = new GridData(); gd = new GridData();
@ -347,47 +379,6 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements
configBtn.setMenu(configPopupMenu); 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() { private void displayAttributesDialog() {
if ((attributeDlg == null) if ((attributeDlg == null)
|| (attributeDlg.getParent().isDisposed() == true)) { || (attributeDlg.getParent().isDisposed() == true)) {
@ -451,18 +442,11 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements
this.fireDialogShutdown(this); this.fireDialogShutdown(this);
} }
@Override
protected void shellCloseAction() {
// TODO : this method may be deleted from the abstract
// class if it is not needed
}
@Override @Override
protected void shellDisposeAction() { protected void shellDisposeAction() {
shell.addDisposeListener(new DisposeListener() { shell.addDisposeListener(new DisposeListener() {
@Override @Override
public void widgetDisposed(DisposeEvent e) { public void widgetDisposed(DisposeEvent e) {
System.out.println("TVS dialog DISPOSED");
unregisterDialogFromMonitor(); unregisterDialogFromMonitor();
} }
}); });
@ -470,7 +454,6 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements
shell.addShellListener(new ShellAdapter() { shell.addShellListener(new ShellAdapter() {
@Override @Override
public void shellClosed(ShellEvent e) { public void shellClosed(ShellEvent e) {
System.out.println("TVS dialog SHELL CLOSED");
unregisterDialogFromMonitor(); unregisterDialogFromMonitor();
} }
}); });
@ -496,35 +479,47 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements
@Override @Override
public void notify(IMonitorEvent me) { public void notify(IMonitorEvent me) {
if (me.getSource() instanceof IMonitor) { if (me.getSource() instanceof IMonitor) {
// System.out.println("SCAN TVS Table Notify Event Received");
ScanMonitor scan = (ScanMonitor) me.getSource(); 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())) { if (getLinkToFrame(scanTable.name())) {
currentTime = scan.getDialogTime(scanTable, site); currentTime = scan.getDialogTime(scanTable, site);
updateTimeLabel();
updateTable(scan, time);
} else { } 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 @Override
public void centerByIdent(String ident) { public void centerByIdent(String ident) {
fireRecenter(ident, ScanTables.TVS, site); fireRecenter(ident, ScanTables.TVS, site);
@ -590,9 +585,11 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements
// NOT USED // NOT USED
} }
/*
* Update the threshold in the composite contained in this dialog for the
* desired attribute in the dialog.
*/
@Override @Override
// Update the threshold in the composite contained in this dialog for the
// desired attribute in the dialog.
public void updateThresh(String attr) { public void updateThresh(String attr) {
this.scanTableComp.updateThresholds(attr); this.scanTableComp.updateThresholds(attr);
} }
@ -610,13 +607,13 @@ public class SCANTvsTableDlg extends AbstractTableDlg implements
return false; return false;
} }
@Override @Override
public void turnOffAlarm() { public void turnOffAlarm() {
mgr.setRing(false); mgr.setRing(false);
} }
@Override @Override
public void turnOnAlarm() { public void turnOnAlarm() {
mgr.setRing(true); mgr.setRing(true);
} }
} }