Omaha #4311 Additional fixes for alertViz to prevent display ressizing to 0 height
and acknowledge confirmation dialog going behind Change-Id: Ie4b3c6f910037db765aa46d619df491bdf7221db Former-commit-id: 5640b3c3594d74614907af06b8f9452c917a04ee
This commit is contained in:
parent
c1724c364e
commit
f010ad8605
2 changed files with 94 additions and 95 deletions
|
@ -79,7 +79,7 @@ import com.raytheon.uf.viz.alertviz.config.AlertMetadata;
|
|||
*
|
||||
*/
|
||||
public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
|
||||
MouseListener {
|
||||
MouseListener, DisposeListener {
|
||||
private static final int MAX_INITIAL_LINES = 5;
|
||||
|
||||
private static final int WIDTH_IN_CHARS = 135;
|
||||
|
@ -266,9 +266,9 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
|
|||
private Label fillerLbl;
|
||||
|
||||
/**
|
||||
* Listens for "Hide Dialog" event, implemented by AlertVisualization class
|
||||
* Listens for Hide and Dispose events
|
||||
*/
|
||||
private final Listener hideListener;
|
||||
private final Listener eventListener;
|
||||
|
||||
/**
|
||||
* Initialized flag indicating if the control have been initialized.
|
||||
|
@ -289,14 +289,14 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
|
|||
* @param expanded
|
||||
* Expanded flag.
|
||||
* @param listener
|
||||
* Hide listener.
|
||||
* Event listener.
|
||||
* @param startUpRGB
|
||||
* Color to be displayed at startup.
|
||||
*/
|
||||
public AlertPopupMessageDlg(Shell parent, StatusMessage statMsg,
|
||||
boolean expanded, Listener listener, RGB startUpRGB) {
|
||||
super(parent, 0);
|
||||
hideListener = listener;
|
||||
eventListener = listener;
|
||||
statMsgArray.add(statMsg);
|
||||
this.expanded = expanded;
|
||||
this.first = true;
|
||||
|
@ -314,6 +314,8 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
|
|||
shell = new Shell(parent, SWT.ON_TOP | SWT.RESIZE);
|
||||
shell.setText("Alert Visualization Popup Message Dialog");
|
||||
|
||||
shell.addDisposeListener(this);
|
||||
|
||||
// Create the main layout for the shell.
|
||||
GridLayout mainLayout = new GridLayout(1, false);
|
||||
mainLayout.marginWidth = 0;
|
||||
|
@ -330,28 +332,28 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
|
|||
setBackgroundColors(startUp);
|
||||
|
||||
// listener event triggers when shell set to not be visible
|
||||
shell.addListener(SWT.Hide, hideListener);
|
||||
shell.addListener(SWT.Hide, eventListener);
|
||||
shell.addListener(SWT.Dispose, eventListener);
|
||||
}
|
||||
|
||||
shell.addDisposeListener(new DisposeListener() {
|
||||
|
||||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
while (statMsgArray.size() != 0) {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
}
|
||||
bgColor.dispose();
|
||||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
while (statMsgArray.size() != 0) {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
});
|
||||
}
|
||||
bgColor.dispose();
|
||||
|
||||
initialized = false;
|
||||
labelFont.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Open method used to display the dialog.
|
||||
*
|
||||
* @return True/False/null.
|
||||
*/
|
||||
public Object open() {
|
||||
private void open() {
|
||||
|
||||
setInitialDialogLocation();
|
||||
|
||||
|
@ -366,12 +368,6 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
|
|||
display.sleep();
|
||||
}
|
||||
}
|
||||
|
||||
initialized = false;
|
||||
|
||||
labelFont.dispose();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -553,7 +549,7 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
|
|||
ackAllBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
acknowledgeAllMessages(true);
|
||||
acknowledgeAllMessages();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -782,9 +778,6 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
|
|||
}
|
||||
|
||||
msgLogList.select(currentIndex);
|
||||
if (initialized == true) {
|
||||
showDialog(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -900,7 +893,7 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
|
|||
/**
|
||||
* Acknowledge all of the messages.
|
||||
*/
|
||||
public void acknowledgeAllMessages(boolean confirmPrompt) {
|
||||
public void acknowledgeAllMessages() {
|
||||
int index = msgLogList.getSelectionIndex();
|
||||
|
||||
int result = SWT.CANCEL;
|
||||
|
@ -914,28 +907,26 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
|
|||
showHideLog();
|
||||
}
|
||||
|
||||
if (confirmPrompt) {
|
||||
ConfirmationDlg cd = new ConfirmationDlg(shell,
|
||||
"Are you sure you want to acknowledge all popup messages?",
|
||||
SWT.ICON_QUESTION);
|
||||
ConfirmationDlg cd = new ConfirmationDlg(shell,
|
||||
"Are you sure you want to acknowledge all popup messages?",
|
||||
SWT.ICON_QUESTION);
|
||||
|
||||
if ((msgLogList != null) && !msgLogList.isDisposed()) {
|
||||
Rectangle logBounds = msgLogList.getBounds();
|
||||
Point logDisplayOrigin = msgLogList.toDisplay(0, 0);
|
||||
logBounds.x = logDisplayOrigin.x;
|
||||
logBounds.y = logDisplayOrigin.y;
|
||||
cd.setAvoidedArea(logBounds);
|
||||
}
|
||||
|
||||
result = cd.open();
|
||||
|
||||
if (result != SWT.YES) {
|
||||
if ((result == SWT.CANCEL) && expandedForPrompt) {
|
||||
expanded = false;
|
||||
showHideLog();
|
||||
}
|
||||
return;
|
||||
if ((msgLogList != null) && !msgLogList.isDisposed()) {
|
||||
Rectangle logBounds = msgLogList.getBounds();
|
||||
Point logDisplayOrigin = msgLogList.toDisplay(0, 0);
|
||||
logBounds.x = logDisplayOrigin.x;
|
||||
logBounds.y = logDisplayOrigin.y;
|
||||
cd.setAvoidedArea(logBounds);
|
||||
}
|
||||
|
||||
result = cd.open();
|
||||
|
||||
if (result != SWT.YES) {
|
||||
if ((result == SWT.CANCEL) && expandedForPrompt) {
|
||||
expanded = false;
|
||||
showHideLog();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
String userName = System.getProperty("user.name");
|
||||
|
@ -987,17 +978,21 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
|
|||
}
|
||||
|
||||
/**
|
||||
* Shows or hides the dialog.
|
||||
* Shows the dialog.
|
||||
*
|
||||
* @param show
|
||||
* True to show dialog, false to hide.
|
||||
*/
|
||||
public void showDialog(boolean show) {
|
||||
shell.setLocation(dialogXY);
|
||||
shell.setVisible(show);
|
||||
public void showDialog() {
|
||||
if (initialized) {
|
||||
shell.setLocation(dialogXY);
|
||||
shell.setVisible(true);
|
||||
|
||||
showSelectedListData();
|
||||
msgLogList.showSelection();
|
||||
showSelectedListData();
|
||||
msgLogList.showSelection();
|
||||
} else {
|
||||
open();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
|
@ -21,7 +22,6 @@ package com.raytheon.uf.viz.alertviz.ui.dialogs;
|
|||
import java.io.File;
|
||||
|
||||
import org.eclipse.equinox.app.IApplication;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.MenuDetectEvent;
|
||||
import org.eclipse.swt.events.MenuDetectListener;
|
||||
|
@ -359,7 +359,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
|
|||
*/
|
||||
private void createTray() {
|
||||
trayItem = new TrayItem(tray, SWT.NONE);
|
||||
addToolTip();
|
||||
updateToolTip();
|
||||
|
||||
trayItemMenu = new Menu(shell, SWT.POP_UP);
|
||||
|
||||
|
@ -378,9 +378,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
|
|||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if ((alertPopupDlg != null)
|
||||
&& (alertPopupDlg.getNumberOfMessages() > 0)) {
|
||||
cancelTimer();
|
||||
if (alertPopupDlg != null) {
|
||||
openAlertPopupDialog();
|
||||
}
|
||||
}
|
||||
|
@ -459,9 +457,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
|
|||
showPopup.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if (alertPopupDlg != null) {
|
||||
openAlertPopupDialog();
|
||||
}
|
||||
openAlertPopupDialog();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -471,19 +467,13 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
|
|||
ackAll.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
// Verify user meant to acknowledge all messages
|
||||
boolean rval = MessageDialog.openConfirm(shell, "Confirm",
|
||||
"Acknowledge all messages?");
|
||||
|
||||
if (rval == true) {
|
||||
if (alertPopupDlg != null) {
|
||||
alertPopupDlg.acknowledgeAllMessages(false);
|
||||
alertPopupDlg = null;
|
||||
addToolTip();
|
||||
ackAll.setEnabled(false);
|
||||
showPopup.setEnabled(false);
|
||||
}
|
||||
cancelTimer();
|
||||
if (alertPopupDlg != null) {
|
||||
alertPopupDlg.showDialog();
|
||||
alertPopupDlg.acknowledgeAllMessages();
|
||||
} else {
|
||||
// should never happen
|
||||
Container.logInternal(Priority.ERROR,
|
||||
"alertPopupDlg unexpectedly null");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -699,16 +689,17 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
|
|||
|
||||
// Pop-up message
|
||||
if (amd.isPopup() == true) {
|
||||
if ((alertPopupDlg == null) || (alertPopupDlg.isDisposed() == true)) {
|
||||
if (alertPopupDlg == null) {
|
||||
alertPopupDlg = new AlertPopupMessageDlg(shell, statMsg,
|
||||
gConfig.isExpandedPopup(), this, amd.getBackground());
|
||||
showPopup.setEnabled(true);
|
||||
ackAll.setEnabled(true);
|
||||
startBlinkTrayTimer();
|
||||
} else {
|
||||
alertPopupDlg.addNewMessage(statMsg, amd);
|
||||
}
|
||||
startBlinkTrayTimer();
|
||||
addToolTip();
|
||||
showPopup.setEnabled(true);
|
||||
ackAll.setEnabled(true);
|
||||
|
||||
updateToolTip();
|
||||
if (doNotDisturb == false) {
|
||||
openAlertPopupDialog();
|
||||
}
|
||||
|
@ -747,15 +738,12 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
|
|||
* Opens the alert pop-up dialog
|
||||
*/
|
||||
public void openAlertPopupDialog() {
|
||||
if ((alertPopupDlg != null) && (alertPopupDlg.dialogIsOpen() == true)) {
|
||||
alertPopupDlg.showDialog(true);
|
||||
if (alertPopupDlg != null) {
|
||||
alertPopupDlg.showDialog();
|
||||
} else {
|
||||
alertPopupDlg.open();
|
||||
alertPopupDlg = null;
|
||||
cancelTimer();
|
||||
addToolTip();
|
||||
ackAll.setEnabled(false);
|
||||
showPopup.setEnabled(showAlertDlg);
|
||||
// should never happen
|
||||
Container.logInternal(Priority.ERROR,
|
||||
"alertPopupDlg unexpectedly null");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -785,7 +773,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
|
|||
* Adds a tool tip to the tray icon, if messages need to be acknowledged,
|
||||
* shows the number, otherwise displays general text.
|
||||
*/
|
||||
private void addToolTip() {
|
||||
private void updateToolTip() {
|
||||
if (alertPopupDlg == null) {
|
||||
this.trayItem.setToolTipText("AlertViz Menu");
|
||||
} else {
|
||||
|
@ -819,10 +807,26 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
|
|||
*/
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
ackAll.setEnabled(true);
|
||||
showPopup.setEnabled(true);
|
||||
startBlinkTrayTimer();
|
||||
addToolTip();
|
||||
switch (event.type) {
|
||||
case SWT.Hide:
|
||||
ackAll.setEnabled(true);
|
||||
showPopup.setEnabled(true);
|
||||
startBlinkTrayTimer();
|
||||
updateToolTip();
|
||||
break;
|
||||
|
||||
case SWT.Dispose:
|
||||
alertPopupDlg = null;
|
||||
cancelTimer();
|
||||
updateToolTip();
|
||||
ackAll.setEnabled(false);
|
||||
showPopup.setEnabled(false);
|
||||
break;
|
||||
default:
|
||||
Container.logInternal(Priority.WARN, "Unexpected event type: "
|
||||
+ event.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue