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:
Ron Anderson 2015-07-14 10:40:35 -05:00
parent c1724c364e
commit f010ad8605
2 changed files with 94 additions and 95 deletions

View file

@ -79,7 +79,7 @@ import com.raytheon.uf.viz.alertviz.config.AlertMetadata;
* *
*/ */
public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener, public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
MouseListener { MouseListener, DisposeListener {
private static final int MAX_INITIAL_LINES = 5; private static final int MAX_INITIAL_LINES = 5;
private static final int WIDTH_IN_CHARS = 135; private static final int WIDTH_IN_CHARS = 135;
@ -266,9 +266,9 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
private Label fillerLbl; 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. * Initialized flag indicating if the control have been initialized.
@ -289,14 +289,14 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
* @param expanded * @param expanded
* Expanded flag. * Expanded flag.
* @param listener * @param listener
* Hide listener. * Event listener.
* @param startUpRGB * @param startUpRGB
* Color to be displayed at startup. * Color to be displayed at startup.
*/ */
public AlertPopupMessageDlg(Shell parent, StatusMessage statMsg, public AlertPopupMessageDlg(Shell parent, StatusMessage statMsg,
boolean expanded, Listener listener, RGB startUpRGB) { boolean expanded, Listener listener, RGB startUpRGB) {
super(parent, 0); super(parent, 0);
hideListener = listener; eventListener = listener;
statMsgArray.add(statMsg); statMsgArray.add(statMsg);
this.expanded = expanded; this.expanded = expanded;
this.first = true; this.first = true;
@ -314,6 +314,8 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
shell = new Shell(parent, SWT.ON_TOP | SWT.RESIZE); shell = new Shell(parent, SWT.ON_TOP | SWT.RESIZE);
shell.setText("Alert Visualization Popup Message Dialog"); shell.setText("Alert Visualization Popup Message Dialog");
shell.addDisposeListener(this);
// Create the main layout for the shell. // Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, false); GridLayout mainLayout = new GridLayout(1, false);
mainLayout.marginWidth = 0; mainLayout.marginWidth = 0;
@ -330,28 +332,28 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
setBackgroundColors(startUp); setBackgroundColors(startUp);
// listener event triggers when shell set to not be visible // 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) {
@Override while (statMsgArray.size() != 0) {
public void widgetDisposed(DisposeEvent e) { if (!display.readAndDispatch()) {
while (statMsgArray.size() != 0) { display.sleep();
if (!display.readAndDispatch()) {
display.sleep();
}
}
bgColor.dispose();
} }
}); }
bgColor.dispose();
initialized = false;
labelFont.dispose();
} }
/** /**
* Open method used to display the dialog. * Open method used to display the dialog.
* *
* @return True/False/null.
*/ */
public Object open() { private void open() {
setInitialDialogLocation(); setInitialDialogLocation();
@ -366,12 +368,6 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
display.sleep(); display.sleep();
} }
} }
initialized = false;
labelFont.dispose();
return null;
} }
/** /**
@ -553,7 +549,7 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
ackAllBtn.addSelectionListener(new SelectionAdapter() { ackAllBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
acknowledgeAllMessages(true); acknowledgeAllMessages();
} }
}); });
@ -782,9 +778,6 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
} }
msgLogList.select(currentIndex); msgLogList.select(currentIndex);
if (initialized == true) {
showDialog(true);
}
} }
/** /**
@ -900,7 +893,7 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
/** /**
* Acknowledge all of the messages. * Acknowledge all of the messages.
*/ */
public void acknowledgeAllMessages(boolean confirmPrompt) { public void acknowledgeAllMessages() {
int index = msgLogList.getSelectionIndex(); int index = msgLogList.getSelectionIndex();
int result = SWT.CANCEL; int result = SWT.CANCEL;
@ -914,28 +907,26 @@ public class AlertPopupMessageDlg extends Dialog implements MouseMoveListener,
showHideLog(); showHideLog();
} }
if (confirmPrompt) { ConfirmationDlg cd = new ConfirmationDlg(shell,
ConfirmationDlg cd = new ConfirmationDlg(shell, "Are you sure you want to acknowledge all popup messages?",
"Are you sure you want to acknowledge all popup messages?", SWT.ICON_QUESTION);
SWT.ICON_QUESTION);
if ((msgLogList != null) && !msgLogList.isDisposed()) { if ((msgLogList != null) && !msgLogList.isDisposed()) {
Rectangle logBounds = msgLogList.getBounds(); Rectangle logBounds = msgLogList.getBounds();
Point logDisplayOrigin = msgLogList.toDisplay(0, 0); Point logDisplayOrigin = msgLogList.toDisplay(0, 0);
logBounds.x = logDisplayOrigin.x; logBounds.x = logDisplayOrigin.x;
logBounds.y = logDisplayOrigin.y; logBounds.y = logDisplayOrigin.y;
cd.setAvoidedArea(logBounds); cd.setAvoidedArea(logBounds);
} }
result = cd.open(); result = cd.open();
if (result != SWT.YES) { if (result != SWT.YES) {
if ((result == SWT.CANCEL) && expandedForPrompt) { if ((result == SWT.CANCEL) && expandedForPrompt) {
expanded = false; expanded = false;
showHideLog(); showHideLog();
}
return;
} }
return;
} }
String userName = System.getProperty("user.name"); 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 * @param show
* True to show dialog, false to hide. * True to show dialog, false to hide.
*/ */
public void showDialog(boolean show) { public void showDialog() {
shell.setLocation(dialogXY); if (initialized) {
shell.setVisible(show); shell.setLocation(dialogXY);
shell.setVisible(true);
showSelectedListData(); showSelectedListData();
msgLogList.showSelection(); msgLogList.showSelection();
} else {
open();
}
} }
/** /**

View file

@ -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. * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
* *
* U.S. EXPORT CONTROLLED TECHNICAL DATA * U.S. EXPORT CONTROLLED TECHNICAL DATA
@ -21,7 +22,6 @@ package com.raytheon.uf.viz.alertviz.ui.dialogs;
import java.io.File; import java.io.File;
import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplication;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MenuDetectEvent; import org.eclipse.swt.events.MenuDetectEvent;
import org.eclipse.swt.events.MenuDetectListener; import org.eclipse.swt.events.MenuDetectListener;
@ -359,7 +359,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
*/ */
private void createTray() { private void createTray() {
trayItem = new TrayItem(tray, SWT.NONE); trayItem = new TrayItem(tray, SWT.NONE);
addToolTip(); updateToolTip();
trayItemMenu = new Menu(shell, SWT.POP_UP); trayItemMenu = new Menu(shell, SWT.POP_UP);
@ -378,9 +378,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
if ((alertPopupDlg != null) if (alertPopupDlg != null) {
&& (alertPopupDlg.getNumberOfMessages() > 0)) {
cancelTimer();
openAlertPopupDialog(); openAlertPopupDialog();
} }
} }
@ -459,9 +457,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
showPopup.addSelectionListener(new SelectionAdapter() { showPopup.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
if (alertPopupDlg != null) { openAlertPopupDialog();
openAlertPopupDialog();
}
} }
}); });
@ -471,19 +467,13 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
ackAll.addSelectionListener(new SelectionAdapter() { ackAll.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
// Verify user meant to acknowledge all messages if (alertPopupDlg != null) {
boolean rval = MessageDialog.openConfirm(shell, "Confirm", alertPopupDlg.showDialog();
"Acknowledge all messages?"); alertPopupDlg.acknowledgeAllMessages();
} else {
if (rval == true) { // should never happen
if (alertPopupDlg != null) { Container.logInternal(Priority.ERROR,
alertPopupDlg.acknowledgeAllMessages(false); "alertPopupDlg unexpectedly null");
alertPopupDlg = null;
addToolTip();
ackAll.setEnabled(false);
showPopup.setEnabled(false);
}
cancelTimer();
} }
} }
}); });
@ -699,16 +689,17 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
// Pop-up message // Pop-up message
if (amd.isPopup() == true) { if (amd.isPopup() == true) {
if ((alertPopupDlg == null) || (alertPopupDlg.isDisposed() == true)) { if (alertPopupDlg == null) {
alertPopupDlg = new AlertPopupMessageDlg(shell, statMsg, alertPopupDlg = new AlertPopupMessageDlg(shell, statMsg,
gConfig.isExpandedPopup(), this, amd.getBackground()); gConfig.isExpandedPopup(), this, amd.getBackground());
showPopup.setEnabled(true);
ackAll.setEnabled(true);
startBlinkTrayTimer();
} else { } else {
alertPopupDlg.addNewMessage(statMsg, amd); alertPopupDlg.addNewMessage(statMsg, amd);
} }
startBlinkTrayTimer();
addToolTip(); updateToolTip();
showPopup.setEnabled(true);
ackAll.setEnabled(true);
if (doNotDisturb == false) { if (doNotDisturb == false) {
openAlertPopupDialog(); openAlertPopupDialog();
} }
@ -747,15 +738,12 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
* Opens the alert pop-up dialog * Opens the alert pop-up dialog
*/ */
public void openAlertPopupDialog() { public void openAlertPopupDialog() {
if ((alertPopupDlg != null) && (alertPopupDlg.dialogIsOpen() == true)) { if (alertPopupDlg != null) {
alertPopupDlg.showDialog(true); alertPopupDlg.showDialog();
} else { } else {
alertPopupDlg.open(); // should never happen
alertPopupDlg = null; Container.logInternal(Priority.ERROR,
cancelTimer(); "alertPopupDlg unexpectedly null");
addToolTip();
ackAll.setEnabled(false);
showPopup.setEnabled(showAlertDlg);
} }
} }
@ -785,7 +773,7 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
* Adds a tool tip to the tray icon, if messages need to be acknowledged, * Adds a tool tip to the tray icon, if messages need to be acknowledged,
* shows the number, otherwise displays general text. * shows the number, otherwise displays general text.
*/ */
private void addToolTip() { private void updateToolTip() {
if (alertPopupDlg == null) { if (alertPopupDlg == null) {
this.trayItem.setToolTipText("AlertViz Menu"); this.trayItem.setToolTipText("AlertViz Menu");
} else { } else {
@ -819,10 +807,26 @@ public class AlertVisualization implements ITimerAction, IAudioAction,
*/ */
@Override @Override
public void handleEvent(Event event) { public void handleEvent(Event event) {
ackAll.setEnabled(true); switch (event.type) {
showPopup.setEnabled(true); case SWT.Hide:
startBlinkTrayTimer(); ackAll.setEnabled(true);
addToolTip(); 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 @Override