From de65502fd165b3a590bd87a363f3234e84dea461 Mon Sep 17 00:00:00 2001 From: Lee Venable Date: Mon, 9 Mar 2015 16:52:59 -0500 Subject: [PATCH] Omaha #3856 - check if the timer is running when setting the icon in the timer action method. Former-commit-id: ad840e023f40fe7d35bfeb21f1116d43bc06e472 --- .../ui/dialogs/AlertVisualization.java | 35 ++++++++++++------- .../uf/viz/alertviz/ui/timer/AlertTimer.java | 10 ++---- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertVisualization.java b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertVisualization.java index 0e06626033..0a955bd95a 100644 --- a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertVisualization.java +++ b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/AlertVisualization.java @@ -92,6 +92,10 @@ import com.raytheon.uf.viz.core.VizApp; * 03 May 2011 9101 cjeanbap Pass a clone object into AlertVizPython class. * 31 May 2011 8058 cjeanbap Kill sound based on TextMsgBox id. * 17 Jan 2012 27 rferrel Refactored to allow override of createTrayMenuItems + * 09 Mar 2015 3856 lvenable Added a check to determine if the timer is running before + * changing the icon on the timer action. If it isn't running + * then set the icon to the default image. + * * * * @author lvenable @@ -221,7 +225,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction, private ConfigContext configContext; private Configuration prevConfigFile; - + private Integer exitStatus = IApplication.EXIT_OK; /** @@ -320,6 +324,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction, alertMessageDlg = new AlertMessageDlg(shell, this, showAlertDlg, configData, audioMgr); display.asyncExec(new Runnable() { + @Override public void run() { alertMessageDlg.open(); } @@ -361,6 +366,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction, // Right click action trayItem.addMenuDetectListener(new MenuDetectListener() { + @Override public void menuDetected(MenuDetectEvent de) { trayItemMenu.setVisible(true); } @@ -526,7 +532,11 @@ public class AlertVisualization implements ITimerAction, IAudioAction, blinkCount = 0; } - trayItem.setImage(blinkImages[blinkCount]); + if (this.trayAlertTimer.timerIsRunning()) { + trayItem.setImage(blinkImages[blinkCount]); + } else { + trayItem.setImage(alertVizImg); + } } /** @@ -548,6 +558,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction, } } + @Override public void cancelAudio(int numTextMsgBoxId) { audioMgr.stopTimer(numTextMsgBoxId); } @@ -637,7 +648,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction, && (statMsg.getDetails().contains("Error") || statMsg.getDetails().contains("Exception") || statMsg.getDetails().contains("Throwable") || Container - .hasMissing(statMsg))) { + .hasMissing(statMsg))) { Source source = configData.lookupSource("GDN_ADMIN"); RGB backgroundRBG = null; if (source == null || source.getConfigurationItem() == null) { @@ -815,9 +826,9 @@ public class AlertVisualization implements ITimerAction, IAudioAction, } public Integer getExitStatus() { - return exitStatus; + return exitStatus; } - + /** * This is the button click event for the alertPopupDialog. This function is * called when "Hide Dialog" is clicked. @@ -833,13 +844,13 @@ public class AlertVisualization implements ITimerAction, IAudioAction, @Override public void restart() { if (runningStandalone) { - // Must use EXIT_RELAUNCH. EXIT_RESTART causes the - // executable to do a restart without returning to - // the shell/bat script. This fails. Any other value - // such as Integer(1) the executable attempts to bring - // up an error screen before exiting with the error code. - exitStatus = IApplication.EXIT_RELAUNCH; - display.dispose(); + // Must use EXIT_RELAUNCH. EXIT_RESTART causes the + // executable to do a restart without returning to + // the shell/bat script. This fails. Any other value + // such as Integer(1) the executable attempts to bring + // up an error screen before exiting with the error code. + exitStatus = IApplication.EXIT_RELAUNCH; + display.dispose(); } } diff --git a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/timer/AlertTimer.java b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/timer/AlertTimer.java index 557ee7655b..355eea4cf5 100644 --- a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/timer/AlertTimer.java +++ b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/timer/AlertTimer.java @@ -35,6 +35,7 @@ import org.eclipse.swt.widgets.Display; * 05 Oct 2008 lvenable Initial creation. * 02 Apr 2009 lvenable TTR fixes. * 02 Mar 2015 3856 lvenable Cancel the job if the timer is being canceled. + * 09 Mar 2015 3856 lvenable Cleaned up the cancel logic. * * * @@ -226,22 +227,17 @@ public class AlertTimer { * Setting alertPopupDlg Cancel the timer. */ public void cancelTimer() { + // only synchronize on canceling the timer, don't do the syncExec in // the sync block. - boolean cancel = false; synchronized (this) { if (isRunning) { isRunning = false; - cancel = true; job.cancel(); } } - if (cancel) { - if (parentDisplay.isDisposed() == true) { - return; - } - + if (parentDisplay.isDisposed() == false) { parentDisplay.syncExec(new Runnable() { @Override public void run() {