Merge "Omaha #5513 Fix TextWS GUIs opening on the wrong monitor" into omaha_16.2.1-lx

Former-commit-id: 1e9ff3fd1bca3a909d7b463567d11118a560cb38
This commit is contained in:
Ron Anderson 2016-03-31 13:31:17 -05:00 committed by Gerrit Code Review
commit fb62976c22
10 changed files with 213 additions and 409 deletions

View file

@ -3,5 +3,6 @@ bin.includes = META-INF/,\
localization/,\
plugin.xml,\
res/,\
com.raytheon.viz.texteditor.jar
com.raytheon.viz.texteditor.jar,\
images/
source.com.raytheon.viz.texteditor.jar = src/

View file

Before

Width:  |  Height:  |  Size: 583 B

After

Width:  |  Height:  |  Size: 583 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

View file

@ -19,10 +19,7 @@
**/
package com.raytheon.viz.texteditor.alarmalert.dialogs;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.File;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
@ -35,27 +32,23 @@ import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.viz.texteditor.Activator;
import com.raytheon.viz.texteditor.alarmalert.util.AlarmBeepJob;
import com.raytheon.viz.texteditor.alarmalert.util.FlashBellJob;
/**
* TODO Add Description
* Alarm/Alert Bell
*
* <pre>
*
@ -63,21 +56,23 @@ import com.raytheon.viz.texteditor.alarmalert.util.FlashBellJob;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 21, 2009 mnash Initial creation
* Aug 16, 2010 2187 cjeanbap Fixed a NullPointerException
* Aug 16, 2010 2187 cjeanbap Fixed a NullPointerException
* Dec 23, 2010 7375 cjeanbap Force dialog ON TOP of over Dialog/Windows.
* 03/19/2012 D. Friedman Fix alarming. Disable runloop in open().
* May 18, 2012 jkorman Added flashing alarm image.
* Jul 25, 2012 15122 rferrel Add sound delay interval.
* Mar 06 2013 15827 mgamazaychikov Prevent Alarm Bell window from stealing focus
* from Text Editor.
* from Text Editor.
* Mar 30, 2016 5513 randerso Fixed to display on same monitor as parent,
* significant code cleanup
*
* </pre>
*
* @author mnash
* @version 1.0
*/
public class AlarmAlertBell extends Dialog implements MouseMoveListener,
MouseListener {
public class AlarmAlertBell implements MouseMoveListener, MouseListener {
// delay in milliseconds - flash every 1 1/2 seconds
private static final int FLASH_DELAY = 1500;
@ -85,25 +80,19 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
/**
* Repeat the alarm sound every minute.
*/
private static final long SOUND_DELAY = 60 * 1000L;
private static final long SOUND_DELAY = TimeUtil.MILLIS_PER_MINUTE;
private Shell parentShell;
private Shell parent;
private Shell alarmShell;
private Shell shell;
private Display display;
private CurrentAlarmQueue alarmDlg;
private String bellPath;
private FlashBellJob flasher;
private Image norm_bell;
private Image[] bellImage = new Image[2];
private Image revs_bell;
private boolean invert = false;
private int phase = 0;
private boolean active = false;
@ -111,29 +100,15 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
private AlarmBeepJob abj = null;
private static int locationX = -1;
private static int locationY = -1;
/**
* Mouse origin.
*/
private Point origin;
/**
* Adjusted dialog location.
*/
private Point dialogLoc;
/**
* Actual dialog X, Y coordinate.
*/
private Point dialogXY;
/**
* Move dialog flag.
*/
private boolean moveDialog = false;
private Point dialogXY = null;
/**
* Move label.
@ -146,30 +121,25 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
private Font labelFont;
/**
* @param parentShell
* @param parent
*/
public AlarmAlertBell(Shell parentShell) {
super(parentShell);
this.parentShell = parentShell;
initShell();
public AlarmAlertBell(Shell parent) {
this.parent = parent;
}
public void initShell() {
Shell parent = getParent();
display = parentShell.getDisplay();
private void initShell() {
display = parent.getDisplay();
alarmShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.ON_TOP);
alarmShell.setText("Alarm Alert Bell");
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.ON_TOP);
shell.setText("Alarm Alert Bell");
GridLayout mainLayout = new GridLayout(1, true);
alarmShell.setLayout(mainLayout);
shell.setLayout(mainLayout);
labelFont = new Font(alarmShell.getDisplay(), "Monospace", 14, SWT.BOLD);
labelFont = new Font(shell.getDisplay(), "Monospace", 14, SWT.BOLD);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
gd.horizontalSpan = 3;
moveLabel = new Label(alarmShell, SWT.CENTER | SWT.BORDER);
moveLabel = new Label(shell, SWT.CENTER | SWT.BORDER);
moveLabel.setText("Alarm Bell");
moveLabel.setLayoutData(gd);
moveLabel.setFont(labelFont);
@ -182,18 +152,18 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
setInitialDialogLocation();
alarmShell.addShellListener(new ShellAdapter() {
shell.addShellListener(new ShellAdapter() {
@Override
public void shellClosed(ShellEvent e) {
setLocation();
saveLocation();
}
});
alarmShell.addDisposeListener(new DisposeListener() {
shell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
while (alarmShell.isDisposed()) {
while (shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
@ -201,6 +171,8 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
}
});
setDialogImage();
shell.pack();
}
public Object open(boolean alarm) {
@ -210,21 +182,15 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
abj.schedule();
}
if (alarmShell == null) {
display = parentShell.getDisplay();
if (alarmShell == null) {
initShell();
}
alarmShell.setLocation(locationX, locationY);
alarmShell.pack();
if (shell == null || shell.isDisposed()) {
initShell();
}
alarmShell.setVisible(true);
alarmShell.pack();
shell.setVisible(true);
active = true;
// Start a new flash job only if one isn't currently running!
if (flasher == null) {
invert = false;
phase = 0;
flasher = new FlashBellJob("FlashBell", this, FLASH_DELAY);
}
@ -236,8 +202,8 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
* running.
*/
public void close() {
if (!alarmShell.isDisposed()) {
alarmShell.setVisible(false);
if (shell != null && !shell.isDisposed()) {
shell.close();
}
active = false;
if (flasher != null) {
@ -251,59 +217,34 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
}
private void setInitialDialogLocation() {
if (locationX < 0) {
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int screenWidth = d.width;
int screenHeight = d.height;
if (screenWidth > (screenHeight * 2)) {
screenWidth /= 2;
}
locationX = screenWidth / 2 - 102;
locationY = screenHeight / 2 - 88;
if (dialogXY == null) {
Rectangle bounds = parent.getMonitor().getBounds();
dialogXY = new Point(bounds.x, bounds.y);
}
dialogXY = new Point(locationX, locationY);
shell.setLocation(dialogXY);
}
private void setDialogImage() {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext localization = pm.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.BASE);
LocalizationFile imageFile = PathManagerFactory.getPathManager()
.getLocalizationFile(localization,
"images" + File.separator + "bell.gif");
bellPath = imageFile.getFile().getAbsolutePath();
norm_bell = new Image(display, bellPath);
button = new Button(alarmShell, SWT.IMAGE_GIF);
if (norm_bell != null) {
createInvertImage(bellPath);
button.setImage(norm_bell);
}
ImageDescriptor id = Activator.imageDescriptorFromPlugin(
Activator.PLUGIN_ID, FileUtil.join("images", "bell0.gif"));
bellImage[0] = id.createImage();
id = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID,
FileUtil.join("images", "bell1.gif"));
bellImage[1] = id.createImage();
button = new Button(shell, SWT.PUSH);
button.setImage(bellImage[0]);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (alarmDlg == null) {
alarmDlg = CurrentAlarmQueue.getInstance(getParent());
alarmDlg.setDialogFocus();
alarmDlg.open();
} else {
if (alarmDlg.getShell().isDisposed()) {
alarmDlg = CurrentAlarmQueue.getInstance(alarmShell);
alarmDlg.setDialogFocus();
alarmDlg.open();
} else {
alarmDlg.setDialogFocus();
}
}
CurrentAlarmQueue.getInstance(shell).show();
close();
}
});
}
private void setLocation() {
Point location = alarmShell.getLocation();
locationX = location.x;
locationY = location.y;
private void saveLocation() {
dialogXY = shell.getLocation();
}
@Override
@ -314,12 +255,11 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
@Override
public void mouseDown(MouseEvent e) {
origin = new Point(e.x, e.y);
moveDialog = true;
}
@Override
public void mouseUp(MouseEvent e) {
moveDialog = false;
origin = null;
}
/**
@ -327,31 +267,12 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
*/
@Override
public void mouseMove(MouseEvent e) {
if (origin != null && moveDialog == true) {
if (origin != null) {
// Move the dialog.
dialogLoc = display.map(alarmShell, null, e.x, e.y);
dialogXY.x = dialogLoc.x - origin.x;
dialogXY.y = dialogLoc.y - origin.y;
alarmShell.setLocation(dialogXY.x, dialogXY.y);
}
}
/**
* Create an inverse image of the bell.
*/
private void createInvertImage(String path) {
if (norm_bell != null) {
ImageData id = new ImageData(path);
for (int i = 0; i < id.width; i++) {
for (int j = 0; j < id.height; j++) {
if (id.getPixel(i, j) == 0) {
id.setPixel(i, j, 1);
} else {
id.setPixel(i, j, 0);
}
}
}
revs_bell = new Image(display, id);
Point mouseLoc = shell.toDisplay(e.x, e.y);
dialogXY.x = mouseLoc.x - origin.x;
dialogXY.y = mouseLoc.y - origin.y;
shell.setLocation(dialogXY.x, dialogXY.y);
}
}
@ -368,11 +289,7 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
* Alternate between normal and reverse images.
*/
public void flash() {
if (invert) {
button.setImage(revs_bell);
} else {
button.setImage(norm_bell);
}
invert = !invert;
button.setImage(bellImage[phase]);
phase = (phase + 1) % bellImage.length;
}
}

View file

@ -32,7 +32,6 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@ -74,8 +73,9 @@ import com.raytheon.viz.ui.dialogs.ModeListener;
* Oct 31,2011 8510 rferrel Cleaned up code made more robust
* Sep 20,2011 1196 rferrel Change dialogs so they do not block.
* Mar 05,2013 15173 mgamazaychikov Set the initial location and dimension of
* dialog as it is in A1.
* dialog as it is in A1.
* Jun 23, 2014 #3161 lvenable Added SWT dialog trim to the dialogs for thin client.
* Mar 30, 2016 5513 randerso Fixed to display on same monitor as parent
*
* </pre>
*
@ -125,8 +125,6 @@ public class AlarmAlertDlg extends CaveSWTDialog {
private static final int WIDTH_HINT = 500;
private static Point shellLocation = null;
private ILocalizationFileObserver listener = new ILocalizationFileObserver() {
@Override
public void fileUpdated(FileUpdatedMessage message) {
@ -194,6 +192,10 @@ public class AlarmAlertDlg extends CaveSWTDialog {
opened();
}
@Override
public void preOpened() {
setLocation();
}
@ -203,10 +205,9 @@ public class AlarmAlertDlg extends CaveSWTDialog {
private void setLocation() {
int shellSizeX = getShell().getSize().x;
int shellSizeY = getShell().getSize().y;
Rectangle displayArea = shell.getDisplay().getClientArea();
int locationX = displayArea.width - shellSizeX;
int locationY = displayArea.y + shellSizeY;
shellLocation = new Point(locationX, locationY);
Rectangle bounds = getParent().getMonitor().getBounds();
int locationX = bounds.x + bounds.width - shellSizeX;
int locationY = bounds.y + bounds.height - shellSizeY;
shell.setLocation(locationX, locationY);
return;
}
@ -226,12 +227,8 @@ public class AlarmAlertDlg extends CaveSWTDialog {
// Initialize all of the controls and layouts
initializeComponents();
// Set the shell location
if (shellLocation != null) {
shell.setLocation(shellLocation);
}
shell.addShellListener(new ShellAdapter() {
@Override
public void shellClosed(ShellEvent event) {
forcedClose();
}
@ -267,6 +264,7 @@ public class AlarmAlertDlg extends CaveSWTDialog {
MenuItem saveMenuItem = new MenuItem(fileMenu, SWT.NONE);
saveMenuItem.setText("Save");
saveMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
save();
changeSaveState(false);
@ -276,6 +274,7 @@ public class AlarmAlertDlg extends CaveSWTDialog {
MenuItem saveCloseMenuItem = new MenuItem(fileMenu, SWT.NONE);
saveCloseMenuItem.setText("Save && Close");
saveCloseMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
save();
changeSaveState(false);
@ -286,6 +285,7 @@ public class AlarmAlertDlg extends CaveSWTDialog {
MenuItem closeMenuItem = new MenuItem(fileMenu, SWT.NONE);
closeMenuItem.setText("Close");
closeMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
closeDisplay();
}
@ -297,6 +297,7 @@ public class AlarmAlertDlg extends CaveSWTDialog {
MenuItem saveAsMenuItem = new MenuItem(fileMenu, SWT.NONE);
saveAsMenuItem.setText("Save As...");
saveAsMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
// open dialog
AlarmAlertSaveLoadDlg dialog = new AlarmAlertSaveLoadDlg(shell,
@ -315,6 +316,7 @@ public class AlarmAlertDlg extends CaveSWTDialog {
MenuItem loadMenuItem = new MenuItem(fileMenu, SWT.NONE);
loadMenuItem.setText("Load...");
loadMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
// open dialog
AlarmAlertSaveLoadDlg dialog = new AlarmAlertSaveLoadDlg(shell,
@ -396,6 +398,7 @@ public class AlarmAlertDlg extends CaveSWTDialog {
newAAEntry.setText("New AA Entry");
newAAEntry.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (proximityAlarmDlg != null
&& !proximityAlarmDlg.getShell().isDisposed()) {
@ -431,6 +434,7 @@ public class AlarmAlertDlg extends CaveSWTDialog {
Button newPAEntry = new Button(entryButtons, SWT.PUSH);
newPAEntry.setText("New PA Entry");
newPAEntry.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (proximityAlarmDlg != null
&& !proximityAlarmDlg.getShell().isDisposed()) {
@ -465,6 +469,7 @@ public class AlarmAlertDlg extends CaveSWTDialog {
changeEntry.setText("Change Entry");
changeEntry.setEnabled(false);
changeEntry.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
// Ignore if dialog already being displayed.
if (proximityAlarmDlg != null
@ -540,6 +545,7 @@ public class AlarmAlertDlg extends CaveSWTDialog {
deleteEntry.setText("Delete Entry");
deleteEntry.setEnabled(false);
deleteEntry.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (paList.getSelectionIndex() != -1) {
papList.remove(paList.getSelectionIndex() - 1);
@ -570,6 +576,7 @@ public class AlarmAlertDlg extends CaveSWTDialog {
aaList = new List(shellComp, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
aaList.setLayoutData(gd);
aaList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
int selected = aaList.getSelectionIndex();
if (selected <= siteAdminNumberAA - 1) {
@ -603,6 +610,7 @@ public class AlarmAlertDlg extends CaveSWTDialog {
paList = new List(shellComp, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
paList.setLayoutData(gd);
paList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
int selected = paList.getSelectionIndex();
if (selected <= siteAdminNumberPA - 1) {
@ -652,6 +660,7 @@ public class AlarmAlertDlg extends CaveSWTDialog {
label.setLayoutData(gd);
saveButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
save();
changeSaveState(false);
@ -659,6 +668,7 @@ public class AlarmAlertDlg extends CaveSWTDialog {
});
saveAndCloseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
save();
closeDisplay();
@ -666,6 +676,7 @@ public class AlarmAlertDlg extends CaveSWTDialog {
});
closeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
closeDisplay();
}
@ -871,18 +882,9 @@ public class AlarmAlertDlg extends CaveSWTDialog {
shell.setActive();
}
/*
* public boolean compareLists(java.util.List<AlarmAlertProduct> prev,
* java.util.List<AlarmAlertProduct> curr) { boolean isTrue = true; for (int
* i = 0; i < curr.size(); i++) { if (!prev.isEmpty() && prev.get(i) != null
* && !prev.get(i).equals(curr.get(i))) { isTrue = false; break; } } return
* isTrue; }
*/
private boolean isOperationalMode() {
CAVEMode mode = CAVEMode.getMode();
return (CAVEMode.OPERATIONAL.equals(mode) || CAVEMode.TEST.equals(mode) ? true
: false);
return CAVEMode.OPERATIONAL.equals(mode) || CAVEMode.TEST.equals(mode);
}
private AAPACombined loadLastList() {
@ -899,7 +901,7 @@ public class AlarmAlertDlg extends CaveSWTDialog {
// if currentFile is null use default.xml
// else if currentFile does not exists and is not default.xml use
// default.xml
// else load normally ( non-existant file will be created and return and
// else load normally ( non-existent file will be created and return and
// empty lists of alarms )
if (AlarmAlertDlg.currentFile == null) {
setLastFile("default.xml");
@ -909,7 +911,6 @@ public class AlarmAlertDlg extends CaveSWTDialog {
setLastFile("default.xml");
return loadLastList();
} else {
// setShellText(currentFile.getName());
return AlarmAlertFunctions.loadUserAlarmsFromConfig();
}
}

View file

@ -32,25 +32,18 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.dataplugin.text.alarms.AlarmAlertProduct;
@ -98,18 +91,19 @@ import com.raytheon.viz.ui.dialogs.ModeListener;
* current alarm queue window.
* May 23, 2012 14952 rferrel Now use refTime/createtime to display
* selected product
* Aug 28, 2012 14795 mgamazaychikov Fixed problem with "Unhadled event loop"
* Aug 28, 2012 14795 mgamazaychikov Fixed problem with "Unhandled event loop"
* exception associated with closing "Current
* Alarm Queue" GUI
* Sep 6, 2012 13365 rferrel Accumulate and Display fix.
* Sep 25, 2012 1196 lvenable Dialog refactor for AlarmDisplayWindow.
* Mar 05, 2013 15173 mgamazaychikov The dimensions and location of closed window
* are saved and set on the next open.
* are saved and set on the next open.
* Jun 23, 2014 #3161 lvenable Added SWT dialog trim to the dialogs for thin client.
* Jul 24, 2014 3423 randerso Created eclipse job to get afos command
* execution off the UI thread
* Jul 24, 2014 3423 randerso Created eclipse job to get afos command
* execution off the UI thread
* Sep 09, 2014 3580 mapeters Removed IQueryTransport usage (no longer exists).
*
* Mar 30, 2016 5513 randerso Fixed to display on same monitor as parent,
* significant code cleanup
* </pre>
*
* @author mnash
@ -121,8 +115,6 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(CurrentAlarmQueue.class);
private Font font;
private AlarmAlertDlg dlg = null;
protected AlarmDisplayWindow alarmDisplayDlg;
@ -146,18 +138,6 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
private static CurrentAlarmQueue INSTANCE;
/**
* Location and dimensions of the dialog on the close.
*/
private static Point closeLocation = null;
private static Point closeDimensions = null;
/**
* Redraw flag indicating if the window should redraw on a resize.
*/
private boolean canRedraw = true;
/**
* Maximum width,initial height and offset of the window
*/
@ -165,8 +145,6 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
private static final int INIT_HEIGHT = 200;
private static final int INIT_OFFSET = 15;
/**
* Job to retrieve text products off the UI thread
*/
@ -228,8 +206,14 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
setText("Current Alarm Queue");
}
/**
* Get the current instance
*
* @param parentShell
* @return the instance
*/
public static CurrentAlarmQueue getInstance(Shell parentShell) {
if (INSTANCE == null || INSTANCE.getParent().isDisposed()) {
if (INSTANCE == null || INSTANCE.getShell().isDisposed()) {
INSTANCE = new CurrentAlarmQueue(parentShell);
}
return INSTANCE;
@ -277,11 +261,17 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
opened();
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
/**
* Used to open the dialog when hidden
*/
public void show() {
restore();
}
private void dontActuallyClose() {
hide();
}
@Override
protected Layout constructShellLayout() {
GridLayout mainLayout = new GridLayout(1, false);
@ -290,104 +280,34 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
return mainLayout;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
*/
@Override
protected void disposed() {
font.dispose();
AlarmAlertLists.getInstance().removeListener(this);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
@Override
protected void initializeComponents(final Shell shell) {
setReturnValue(false);
// Create the main layout for the shell.
font = new Font(shell.getDisplay(), "Helvetica", 11, SWT.BOLD);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
shellComp = new Composite(shell, SWT.NONE);
shellComp.setLayout(constructShellLayout());
shellComp.setLayoutData(gd);
/*
* DR15173 - Create a listener to save the location and dimensions of
* closed window.
*/
shell.addShellListener(new ShellAdapter() {
shell.addListener(SWT.Close, new Listener() {
@Override
public void shellClosed(ShellEvent event) {
closeLocation = getShell().getLocation();
closeDimensions = getShell().getSize();
shell.dispose();
}
});
shell.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
if (canRedraw == false) {
return;
}
final Shell resizedShell = (Shell) e.getSource();
final Point point = resizedShell.getSize();
final Point location = resizedShell.getLocation();
canRedraw = false;
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
/*
* DR15173 - Enforce that the window width does not
* exceed the SHELL_WIDTH.
*/
shell.setBounds(location.x, location.y, SHELL_WIDTH,
point.y);
shell.setMinimumSize(SHELL_WIDTH, 0);
canRedraw = true;
}
});
public void handleEvent(Event event) {
dontActuallyClose();
event.doit = false;
}
});
// Initialize all of the controls and layouts
initializeComponents();
// Set the shell location and dimensions.
setShellGeometry();
}
/**
* Sets the geometry for the Current Alarm Queue shell
*/
private void setShellGeometry() {
Rectangle displayArea = shell.getDisplay().getClientArea();
int locationX = displayArea.x + INIT_OFFSET;
int locationY = displayArea.y + INIT_OFFSET;
int width = SHELL_WIDTH;
int height = INIT_HEIGHT;
if (CurrentAlarmQueue.closeLocation != null) {
locationX = CurrentAlarmQueue.closeLocation.x;
locationY = CurrentAlarmQueue.closeLocation.y;
}
if (CurrentAlarmQueue.closeDimensions != null) {
height = CurrentAlarmQueue.closeDimensions.y;
}
shell.setMinimumSize(width, height);
shell.setLocation(locationX, locationY);
return;
shell.setMinimumSize(SHELL_WIDTH, INIT_HEIGHT);
}
/**
@ -411,22 +331,20 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
Composite textComp = new Composite(shellComp, SWT.NONE);
GridLayout gl = new GridLayout(1, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
textComp.setLayout(gl);
GridData textData = new GridData(SWT.FILL, SWT.FILL, true, true);
textComp.setLayoutData(textData);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
textComp.setLayoutData(gd);
listDates = new ArrayList<Date>();
list = new List(textComp, SWT.BORDER | SWT.V_SCROLL | SWT.SINGLE);
list.setLayoutData(textData);
list.addSelectionListener(new SelectionListener() {
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
list.setLayoutData(gd);
list.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
displayList();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
@ -436,7 +354,8 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
private void createButtons() {
Composite buttonComp = new Composite(shellComp, SWT.NONE);
GridLayout gl = new GridLayout(3, false);
gl.marginHeight = 2;
gl.marginHeight = 0;
gl.marginWidth = 0;
buttonComp.setLayout(gl);
// opens the alarm display dialog, checks for open shells
Button openDisplay = new Button(buttonComp, SWT.PUSH);
@ -463,17 +382,10 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
productList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (dlg == null) {
if (dlg == null || dlg.getShell().isDisposed()) {
dlg = new AlarmAlertDlg(shell);
dlg.open();
} else {
if (dlg.getShell() == null || dlg.getShell().isDisposed()) {
dlg = new AlarmAlertDlg(shell);
dlg.open();
} else {
dlg.open();
}
}
dlg.open();
}
});
}
@ -493,7 +405,7 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
listDates.remove(list.getSelectionIndex());
list.remove(list.getSelectionIndex());
if (list.getItemCount() == 0) {
AlarmAlertFunctions.getAlarmalertbell().close();
AlarmAlertFunctions.closeAlarmAlertBell();
}
}
@ -507,7 +419,7 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
public void dialogClosed(Object returnValue) {
if (list != null && !list.isDisposed()
&& list.getItemCount() == 0) {
close();
dontActuallyClose();
}
}
});
@ -538,7 +450,7 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
if (counter.get(command[i]) == null) {
counter.put(command[i], 0);
} else {
counter.put(command[i], (counter.get(command[i]) + 1));
counter.put(command[i], counter.get(command[i]) + 1);
}
}
// For each command, see how far back it needs to go to
@ -548,14 +460,14 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
Integer count = counter.get(command[j]);
if (count > 0) {
String newCom = "-" + count.toString() + ":" + command[j];
counter.put(command[j], (count - 1));
counter.put(command[j], count - 1);
command[j] = newCom;
}
}
AlarmAlertLists.getInstance().getCurrentAlarms().clear();
listDates.clear();
list.removeAll();
AlarmAlertFunctions.getAlarmalertbell().close();
AlarmAlertFunctions.closeAlarmAlertBell();
// Display the Alarm Display Window
if (alarmDisplayDlg == null || alarmDisplayDlg.getShell().isDisposed()) {
@ -608,12 +520,11 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
* Grab the current alarms from the alarm log file
*/
private void populate() {
// TODO populate with the current alerts
// populate with the current alerts
java.util.List<AlarmAlertProduct> alarms = AlarmAlertLists
.getInstance().getCurrentAlarms();
CAVEMode mode = CAVEMode.getMode();
for (int i = 0; i < alarms.size(); i++) {
AlarmAlertProduct aap = alarms.get(i);
for (AlarmAlertProduct aap : alarms) {
if ((CAVEMode.OPERATIONAL.equals(mode) || CAVEMode.TEST
.equals(mode)) && aap.getOperationalMode()) {
addToQueue(aap.getProductId(), aap.getDateReceived());
@ -624,8 +535,12 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
}
}
/**
* Set Focus on this dialog
*/
public void setDialogFocus() {
if (shell != null && !shell.isDisposed()) {
show();
shell.setActive();
}
}
@ -649,8 +564,15 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
return prods;
}
/*
* get text product using wmo command (DR_14624)
/**
* Get text product using wmo command (DR_14624)
*
* @param awipsId
* @param wmoId
* @param site
* @param hdrTime
* @param bbb
* @return product list
*/
public java.util.List<StdTextProduct> getAwipsTextProduct(String awipsId,
String wmoId, String site, String hdrTime, String bbb) {
@ -660,13 +582,6 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
return prodList;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.texteditor.msgs.IAfosBrowserCallback#executeCommand(
* com.raytheon.viz.texteditor.command.ICommand)
*/
@Override
public void executeCommand(ICommand command) {
try {
@ -680,26 +595,11 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.texteditor.msgs.IAfosBrowserCallback#setAfosCmdField
* (java.lang.String)
*/
@Override
public void setAfosCmdField(String cmd) {
// TODO Auto-generated method stub
// unused
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.texteditor.alarmalert.dialogs.ICurrentAlarmListener#
* currentAlarmChanged()
*/
@Override
public void currentAlarmChanged(CurrentAlarmEvent event) {
final AlarmAlertProduct aap = (AlarmAlertProduct) event.getSource();
@ -718,9 +618,4 @@ public class CurrentAlarmQueue extends CaveSWTDialog implements
}
}
}
@Override
protected void opened() {
// shell.setSize(600, 300);
}
}

View file

@ -37,7 +37,6 @@ import java.util.regex.Pattern;
import javax.xml.bind.JAXB;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import com.raytheon.uf.common.dataplugin.text.alarms.AlarmAlertProduct;
import com.raytheon.uf.common.dataplugin.text.alarms.AlarmAlertProduct.ProductType;
@ -86,6 +85,8 @@ import com.vividsolutions.jts.geom.GeometryFactory;
* 11/29/2015 14995 m.gamazaychikov Made sure that non-standard latlons in
* LAT...LON string did not result in error.
* 15/01/2016 5054 randerso Use proper parent shell
* 03/30/2016 5513 randerso Fixed AlarmAlertBell to display on same monitor as parent
* code cleanup
*
*
* </pre>
@ -93,15 +94,6 @@ import com.vividsolutions.jts.geom.GeometryFactory;
* @author mnash
* @version 1.0
*/
/**
* @author michaelg
*
*/
/**
* @author michaelg
*
*/
public class AlarmAlertFunctions {
private static final AlarmAlertProduct.ProductType AA = AlarmAlertProduct.ProductType.Alarm_Alert;
@ -179,7 +171,9 @@ public class AlarmAlertFunctions {
}
protected static void ringBell(boolean sound) {
getAlarmalertbell().open(sound);
if (alarmAlertBell != null) {
alarmAlertBell.open(sound);
}
}
/**
@ -196,12 +190,11 @@ public class AlarmAlertFunctions {
List<AlarmAlertProduct> prods = findMatches(prod.getProductId(),
currentAlarms);
// did we match anything?
boolean alertAlarm = (prods.size() > 0);
boolean alertAlarm = prods.size() > 0;
if (alertAlarm) {
String pId = prods.get(0).getProductId();
// first go get the product. All of the matching product identifiers
// are
// the same so just get the first.
// are the same so just get the first.
List<StdTextProduct> prodList = getProduct(pId);
AlarmAlertProduct productFound = null;
if (prodList.size() > 0) {
@ -210,7 +203,7 @@ public class AlarmAlertFunctions {
String search = p.getSearchString();
boolean match = false;
if ((search != null) && (search.length() > 0)) {
if (search != null && search.length() > 0) {
if (s.indexOf(search) >= 0) {
match = true;
}
@ -629,7 +622,7 @@ public class AlarmAlertFunctions {
pair = false;
dlat = (double) (Integer.parseInt(latitude) / 100.0);
dlong = (double) ((Integer.parseInt(longitude) / 100.0) * (-1.0));
dlong = (double) (Integer.parseInt(longitude) / 100.0 * -1.0);
coordinates.add(new Coordinate(dlong, dlat));
} else {
latitude = currentToken;
@ -875,16 +868,24 @@ public class AlarmAlertFunctions {
}
/**
* @return the alarmalertbell
* @param parent
* parent shell for alarm alert bell
* @return the alarmAlertBell
*/
public static AlarmAlertBell getAlarmalertbell() {
public static AlarmAlertBell getAlarmAlertBell(Shell parent) {
if (alarmAlertBell == null) {
// No synchronize because this must be called on the UI thread
// anyway.
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
alarmAlertBell = new AlarmAlertBell(shell);
alarmAlertBell = new AlarmAlertBell(parent);
}
return alarmAlertBell;
}
/**
* Close the alarm alert bell
*/
public static void closeAlarmAlertBell() {
if (alarmAlertBell != null) {
alarmAlertBell.close();
alarmAlertBell = null;
}
}
}

View file

@ -39,6 +39,7 @@ import com.raytheon.viz.core.mode.CAVEMode;
* Oct 13, 2009 mnash Initial creation
* Jun 07, 2010 5851 cjeanbap Properly stop alarm/alert observer listener.
* Jul 24, 2014 3423 randerso Get afos command execution off the UI thread
* Mar 30, 2016 5513 randerso Code cleanup
*
* </pre>
*
@ -76,13 +77,6 @@ public class AlarmAlertNotificationObserver implements INotificationObserver {
}
}
/*
* (non-Javadoc)
*
* @seecom.raytheon.uf.common.jms.notification.INotificationObserver#
* notificationArrived
* (com.raytheon.uf.common.jms.notification.NotificationMessage[])
*/
@Override
public void notificationArrived(NotificationMessage[] messages) {
for (NotificationMessage message : messages) {
@ -93,8 +87,7 @@ public class AlarmAlertNotificationObserver implements INotificationObserver {
Object payload = message.getMessagePayload();
if (payload instanceof AlarmAlertProduct) {
// ONLY execute AlarmAlert Products when in OPERATIONAL/TEST
// mode
// and the payload is for the OPERATIONAL/TEST mode.
// mode and the payload is for the OPERATIONAL/TEST mode.
AlarmAlertProduct aap = (AlarmAlertProduct) payload;
if ((CAVEMode.OPERATIONAL.equals(mode) || CAVEMode.TEST
.equals(mode)) && aap.getOperationalMode()) {
@ -123,13 +116,11 @@ public class AlarmAlertNotificationObserver implements INotificationObserver {
AlarmAlertProduct aap = null;
public AlarmRun(String p) {
aap = new AlarmAlertProduct();// new AlarmAlertProduct[p.length];
aap = new AlarmAlertProduct();
String[] temp;
// for (int i = 0; i < p.length; i++) {
temp = p.split("_");
aap.setDateReceived(temp[1]);
aap.setProductId(temp[0]);
// }
}
public AlarmRun(AlarmAlertProduct aap) {

View file

@ -45,6 +45,7 @@ import com.raytheon.viz.texteditor.util.VtecUtil;
* May 24, 2010 jsanchez Initial creation
* Apr 25, 2014 DR 16668 D. Friedman Only notify on NEW products.
* Jan 26, 2016 5054 randerso Changed to use display as parent
* Mar 30, 2016 5513 randerso Fixed to return the status of the close prompt
*
* </pre>
*
@ -86,7 +87,7 @@ public class NotifyExpiration {
}
VtecObject vtecObject = VtecUtil.parseMessage(warning);
if ((vtecObject == null) || !"NEW".equals(vtecObject.getAction())) {
if (vtecObject == null || !"NEW".equals(vtecObject.getAction())) {
return;
}
Calendar expire = vtecObject.getEndTime();
@ -98,16 +99,19 @@ public class NotifyExpiration {
tasks.add(notify);
}
public void checkExpirationNotices(Shell shell) {
if ((shell != null) && !tasks.isEmpty()) {
if (MessageDialog.openQuestion(shell, EXIT_TITLE, EXIT_MSG)) {
public boolean checkExpirationNotices(Shell shell) {
boolean shouldClose = true;
if (shell != null && !tasks.isEmpty()) {
shouldClose = MessageDialog.openQuestion(shell, EXIT_TITLE,
EXIT_MSG);
if (shouldClose) {
for (TimerTask t : tasks) {
t.cancel();
}
tasks.clear();
}
}
return shouldClose;
}
public static void remove(NotifyExpirationTask task) {

View file

@ -37,7 +37,9 @@ import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.MessageBox;
@ -69,8 +71,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 9/27/2007 368 lvenable Initial creation.
* 10/11/2007 482 grichard Reformatted file.
* 11/28/2007 520 grichard Implemented build 11 features.
@ -94,13 +96,13 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 02Oct2012 1229 rferrel Option to allow blocking when top dialog.
* 13Dec2012 1353 rferrel Fix bug introduced in the Show all dialogs.
* 30Jan2013 DR 14736 D. Friedman Display local time.
* 24Jun2013 DR 15733 XHuang Display MAX_BUTTON_CNT (8 button).
* 24Jun2013 DR 15733 XHuang Display MAX_BUTTON_CNT (8 button).
* 25July2013 DR 15733 Greg Hull Make dflt and max number of Text Buttons configurable.
* 28Oct2015 5054 randerso Make TextWorkstationDlg appear in upper left corner of
* monitor where parent shell is located
* Jan 26, 2016 5054 randerso Changed to use display as parent
* Jan 26, 2016 5054 randerso Changed to use display as parent
* Feb 15, 2016 4860 njensen Removed references to IAviationObserver
*
* Mar 30, 2016 5513 randerso Fixed to display on same monitor as parent
*
* </pre>
*
@ -181,8 +183,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
NotificationManagerJob.removeQueueObserver(
TextWorkstationConstants.getTextWorkstationQueueName(), null,
this);
notify.checkExpirationNotices(shell);
AlarmAlertFunctions.getAlarmalertbell().close();
AlarmAlertFunctions.closeAlarmAlertBell();
for (TextEditorDialog teDlg : textEditorArray) {
if (teDlg != null) {
teDlg.disposeDialog();
@ -224,16 +225,21 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
createTextButtons();
createWarngenDisplay();
shell.addListener(SWT.Close, new Listener() {
@Override
public void handleEvent(Event event) {
event.doit = notify.checkExpirationNotices(getShell());
}
});
// Opens the alarm queue invisibly, to duplicate A1 functionality.
alarmDlg = CurrentAlarmQueue.getInstance(shell);
alarmDlg.openInvisible();
// Create the alarm alert bell
AlarmAlertFunctions.getAlarmAlertBell(shell);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
*/
@Override
protected void preOpened() {
super.preOpened();
@ -300,7 +306,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
selectUserIdMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if ((userIdDlg == null) || userIdDlg.isDisposed()) {
if (userIdDlg == null || userIdDlg.isDisposed()) {
userIdDlg = new SelectUserIdDlg(shell);
userIdDlg.open();
} else {
@ -459,19 +465,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
alertAlarmBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (alarmDlg == null) {
AlarmAlertNotificationObserver.getInstance();
alarmDlg = CurrentAlarmQueue.getInstance(shell);
alarmDlg.open();
} else {
if (alarmDlg.getShell().isDisposed()) {
AlarmAlertNotificationObserver.getInstance();
alarmDlg = CurrentAlarmQueue.getInstance(shell);
alarmDlg.open();
} else {
alarmDlg.open();
}
}
alarmDlg.show();
}
});
}
@ -645,7 +639,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
// service the queue. This would involve significant changes to
// how we use 3rd party software and can not be implemented at
// this time.
if ((System.currentTimeMillis() - initStartTime) <= delta) {
if (System.currentTimeMillis() - initStartTime <= delta) {
// Slowly increment the delta in case there are a lot of old
// messages.
delta += TextWorkstationDlg.incDelta;