diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/statusline/StatBar.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/statusline/StatBar.java index 41a8d15075..7b832f008f 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/statusline/StatBar.java +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/statusline/StatBar.java @@ -53,6 +53,7 @@ import com.raytheon.viz.ui.statusline.StatusStore.IStatusListener; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jul 14, 2008 #1223 randerso Initial creation + * Oct 22, 2012 #1229 rferrel Changes for non-blocking ViewMessageDialog. * * * @@ -276,6 +277,6 @@ public class StatBar extends ContributionItem implements IStatusListener { } private void viewMessages() { - statusStore.getViewMessagesDialog().open(); + statusStore.openViewMessagesDialog(); } } diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/statusline/StatusStore.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/statusline/StatusStore.java index 19c53fbf38..4edc7ac867 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/statusline/StatusStore.java +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/statusline/StatusStore.java @@ -39,6 +39,7 @@ import com.raytheon.viz.ui.statusline.StatusMessage.Importance; * ------------ ---------- ----------- -------------------------- * Jul 14, 2008 randerso Initial creation * Sep 12, 2008 wdougherty Added updateStatusTextI() method + * Oct 22, 2012 1229 rferrel Changes for non-blocking ViewMessagesDialog. * * * @@ -196,7 +197,8 @@ public class StatusStore { } // Update View Message display - if (viewDialog != null) { + if (viewDialog != null && viewDialog.getShell() != null + && !viewDialog.isDisposed()) { viewDialog.updateText(); } // Update Urgent Messages display @@ -243,13 +245,17 @@ public class StatusStore { }); } - public ViewMessagesDialog getViewMessagesDialog() { - if (viewDialog == null) { + public void openViewMessagesDialog() { + if (viewDialog == null || viewDialog.getShell() == null + || viewDialog.isDisposed()) { this.viewDialog = new ViewMessagesDialog(Display.getDefault() .getActiveShell(), this.messageBuffer, this.importanceDict, "View Messages"); + viewDialog.setBlockOnOpen(false); + viewDialog.open(); + } else { + viewDialog.bringToTop(); } - return viewDialog; } public StatBar getStatusBar() { diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/statusline/ViewMessagesDialog.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/statusline/ViewMessagesDialog.java index 0ae0da8d96..864497d828 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/statusline/ViewMessagesDialog.java +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/statusline/ViewMessagesDialog.java @@ -20,11 +20,11 @@ package com.raytheon.viz.ui.statusline; import java.text.SimpleDateFormat; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TimeZone; -import org.eclipse.jface.dialogs.Dialog; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; @@ -32,12 +32,14 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; +import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; import com.raytheon.viz.ui.statusline.StatusMessage.Importance; /** @@ -48,6 +50,7 @@ import com.raytheon.viz.ui.statusline.StatusMessage.Importance; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * May 19, 2008 Eric Babin Initial Creation + * Oct 22, 2012 1229 rferrel Converted to CaveJFACEDialog. * * * @@ -55,7 +58,7 @@ import com.raytheon.viz.ui.statusline.StatusMessage.Importance; * @version 1.0 */ -public class ViewMessagesDialog extends Dialog { +public class ViewMessagesDialog extends CaveJFACEDialog { private SimpleDateFormat sdf; @@ -71,6 +74,11 @@ public class ViewMessagesDialog extends Dialog { private Font font; + /** + * Track colors used so they can be reused and disposed. + */ + private final Map colorMap = new HashMap(); + /** * @param parent */ @@ -130,7 +138,9 @@ public class ViewMessagesDialog extends Dialog { /* * (non-Javadoc) * - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) + * @see + * org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets + * .Shell) */ @Override protected void configureShell(Shell shell) { @@ -155,11 +165,21 @@ public class ViewMessagesDialog extends Dialog { String s = sdf.format(m.getMessageDate()) + " " + m.getMessageText() + "\n"; - // TODO: need to ensure colors are disposed + RGB rgb = importance.getForegroundColor(); + Color foregroundColor = colorMap.get(rgb); + if (foregroundColor == null) { + foregroundColor = new Color(top.getDisplay(), rgb); + colorMap.put(rgb, foregroundColor); + } + + rgb = importance.getBackgroundColor(); + Color backgroundColor = colorMap.get(rgb); + if (backgroundColor == null) { + backgroundColor = new Color(top.getDisplay(), rgb); + colorMap.put(rgb, backgroundColor); + } styleRanges[i++] = new StyleRange(startIndex, s.length(), - new Color(top.getDisplay(), importance - .getForegroundColor()), new Color(top - .getDisplay(), importance.getBackgroundColor())); + foregroundColor, backgroundColor); styledText.setText(styledText.getText() + s); @@ -168,4 +188,13 @@ public class ViewMessagesDialog extends Dialog { } } + @Override + public boolean close() { + for (Color color : colorMap.values()) { + color.dispose(); + } + colorMap.clear(); + return super.close(); + } + }