Changes for alertviz exit

Former-commit-id: bd73fb18a8 [formerly f0e7a527e4] [formerly e4718d87aa] [formerly bd73fb18a8 [formerly f0e7a527e4] [formerly e4718d87aa] [formerly b2254f8df4 [formerly e4718d87aa [formerly fbc018e6786730b7b597fbe5a179dc6880186b99]]]]
Former-commit-id: b2254f8df4
Former-commit-id: bd3240e530 [formerly 9a59cbc9de] [formerly 0b73c6cd0b03145d357ead8f21e1fc31967a23cb [formerly b2f5691167]]
Former-commit-id: 66329ad5abad76f6048942a06d4237f61351887a [formerly 3b7d7ad2ad]
Former-commit-id: 10cfe30d45
This commit is contained in:
Roger Ferrel 2012-01-30 16:21:02 -06:00
parent e2c62ab096
commit 8583722a44
4 changed files with 71 additions and 13 deletions

View file

@ -21,6 +21,7 @@ package com.raytheon.uf.viz.alertviz.ui.dialogs;
import java.io.File;
import java.io.FileNotFoundException;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MenuDetectEvent;
@ -90,6 +91,7 @@ import com.raytheon.uf.viz.core.VizApp;
* changed.
* 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
* </pre>
*
* @author lvenable
@ -102,7 +104,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
/**
* Dialog shell.
*/
private Shell shell;
protected Shell shell;
/**
* The display control.
@ -132,7 +134,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
/**
* A pop-up menu for the tray item.
*/
private Menu trayItemMenu;
protected Menu trayItemMenu;
/**
* Show alert visualization menu item.
@ -212,13 +214,15 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
/**
* Is this running as a standalone application
*/
private final boolean runningStandalone;
protected final boolean runningStandalone;
private Rectangle prevLocation = null;
private ConfigContext configContext;
private Configuration prevConfigFile;
private Integer exitStatus = IApplication.EXIT_OK;
/**
* Constructor.
@ -381,7 +385,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
/**
* Create the tray menu items.
*/
private void createTrayMenuItems() {
protected void createTrayMenuItems() {
showAlertDialogMI = new MenuItem(trayItemMenu, SWT.CHECK);
showAlertDialogMI.setText("Show Alert Dialog");
@ -810,6 +814,10 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
}
}
public Integer getExitStatus() {
return exitStatus;
}
/**
* This is the button click event for the alertPopupDialog. This function is
* called when "Hide Dialog" is clicked.
@ -825,9 +833,13 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
@Override
public void restart() {
if (runningStandalone) {
// exit with an error code. alertViz.sh will then
// restart AlertViz
System.exit(1);
// 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();
}
}

View file

@ -54,6 +54,7 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 29, 2008 #1433 chammack Initial creation
* Jan 12, 2012 #27 rferrel Added createAlertVisualization
* </pre>
*
* @author chammack
@ -126,7 +127,7 @@ public class AlertVizApplication implements IStandaloneComponent {
}
// Job is not running on port, launch UI.
AlertVisualization av = new AlertVisualization(true, display);
AlertVisualization av = createAlertVisualization(true, display);
Throwable t = null;
try {
while (!display.isDisposed()) {
@ -152,13 +153,17 @@ public class AlertVizApplication implements IStandaloneComponent {
display.dispose();
if (t != null) {
// Killed because of error, set exit status to non zero value
System.exit(1);
return IApplication.EXIT_RELAUNCH;
}
}
return IApplication.EXIT_OK;
return av.getExitStatus();
}
protected AlertVisualization createAlertVisualization(
boolean runningStandalone, final Display display) {
return new AlertVisualization(runningStandalone, display);
}
protected void initializeObservers() {
CAVELocalizationNotificationObserver.register();
}

View file

@ -10,6 +10,9 @@ Require-Bundle: com.raytheon.uf.viz.core,
org.eclipse.core.runtime;bundle-version="3.6.0",
org.eclipse.ui;bundle-version="3.6.1",
com.raytheon.uf.viz.thinclient;bundle-version="1.0.0",
com.raytheon.uf.viz.product.alertviz;bundle-version="1.12.1174"
com.raytheon.uf.viz.product.alertviz;bundle-version="1.12.1174",
com.raytheon.uf.viz.alertviz.ui;bundle-version="1.12.1174",
com.raytheon.uf.viz.alertviz;bundle-version="1.12.1174",
com.raytheon.uf.common.message;bundle-version="1.12.1174"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy

View file

@ -19,7 +19,16 @@
**/
package com.raytheon.uf.viz.thinclient.alertviz;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.MessageBox;
import com.raytheon.uf.viz.alertviz.ui.dialogs.AlertVisualization;
import com.raytheon.uf.viz.product.alertviz.AlertVizApplication;
import com.raytheon.uf.viz.thinclient.Activator;
import com.raytheon.uf.viz.thinclient.IThinClientComponent;
import com.raytheon.uf.viz.thinclient.StatsJob;
import com.raytheon.uf.viz.thinclient.ThinClientNotificationManagerJob;
@ -37,6 +46,7 @@ import com.raytheon.uf.viz.thinclient.localization.ThinClientLocalizationInitial
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 29, 2011 mschenke Initial creation
* Jan 12, 2012 27 rferrel Added exit option
*
* </pre>
*
@ -53,7 +63,8 @@ public class ThinAlertVizComponent extends AlertVizApplication implements
@Override
public Object startComponent(String componentName) throws Exception {
// Start network statistics
Activator.getDefault().setComponent(this);
// Start network statistics
statsJob = new StatsJob();
statsJob.schedule();
return super.startComponent(componentName);
@ -82,4 +93,31 @@ public class ThinAlertVizComponent extends AlertVizApplication implements
ThinClientNotificationManagerJob.getInstance();
}
protected AlertVisualization createAlertVisualization(
boolean runningStandalone, final Display display) {
return new AlertVisualization(runningStandalone, display) {
@Override
protected void createTrayMenuItems() {
super.createTrayMenuItems();
if (!runningStandalone) {
new MenuItem(trayItemMenu, SWT.SEPARATOR);
}
MenuItem exitMI = new MenuItem(trayItemMenu, SWT.NONE);
exitMI.setText("Exit...");
exitMI.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION
| SWT.YES | SWT.NO);
mb.setText("Confirm Exit");
mb.setMessage("Any unsaved changes will be lost.\n Are you sure you want to exit?");
if (mb.open() == SWT.YES) {
display.dispose();
}
}
});
}
};
}
}