Issue #1229 Changes for non-blocking ViewMessagesDialog.
Change-Id: Id1bd1e36a2d16feec60c82997891577c98296fe7 Former-commit-id:03e8d62864
[formerly602c6d8d2e
] [formerly763c6ea58c
] [formerlye157187c72
[formerly763c6ea58c
[formerly 02e781832ab07685baf2b353df39e156a3190c2c]]] Former-commit-id:e157187c72
Former-commit-id: 55c77a2f3b4b370ad545d36263e6e444d0f32da0 [formerly7c63cb3495
] Former-commit-id:1e6a58354c
This commit is contained in:
parent
4410953289
commit
6c659b159c
3 changed files with 48 additions and 12 deletions
|
@ -53,6 +53,7 @@ import com.raytheon.viz.ui.statusline.StatusStore.IStatusListener;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jul 14, 2008 #1223 randerso Initial creation
|
* Jul 14, 2008 #1223 randerso Initial creation
|
||||||
|
* Oct 22, 2012 #1229 rferrel Changes for non-blocking ViewMessageDialog.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -276,6 +277,6 @@ public class StatBar extends ContributionItem implements IStatusListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void viewMessages() {
|
private void viewMessages() {
|
||||||
statusStore.getViewMessagesDialog().open();
|
statusStore.openViewMessagesDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ import com.raytheon.viz.ui.statusline.StatusMessage.Importance;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jul 14, 2008 randerso Initial creation
|
* Jul 14, 2008 randerso Initial creation
|
||||||
* Sep 12, 2008 wdougherty Added updateStatusTextI() method
|
* Sep 12, 2008 wdougherty Added updateStatusTextI() method
|
||||||
|
* Oct 22, 2012 1229 rferrel Changes for non-blocking ViewMessagesDialog.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -196,7 +197,8 @@ public class StatusStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update View Message display
|
// Update View Message display
|
||||||
if (viewDialog != null) {
|
if (viewDialog != null && viewDialog.getShell() != null
|
||||||
|
&& !viewDialog.isDisposed()) {
|
||||||
viewDialog.updateText();
|
viewDialog.updateText();
|
||||||
}
|
}
|
||||||
// Update Urgent Messages display
|
// Update Urgent Messages display
|
||||||
|
@ -243,13 +245,17 @@ public class StatusStore {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewMessagesDialog getViewMessagesDialog() {
|
public void openViewMessagesDialog() {
|
||||||
if (viewDialog == null) {
|
if (viewDialog == null || viewDialog.getShell() == null
|
||||||
|
|| viewDialog.isDisposed()) {
|
||||||
this.viewDialog = new ViewMessagesDialog(Display.getDefault()
|
this.viewDialog = new ViewMessagesDialog(Display.getDefault()
|
||||||
.getActiveShell(), this.messageBuffer, this.importanceDict,
|
.getActiveShell(), this.messageBuffer, this.importanceDict,
|
||||||
"View Messages");
|
"View Messages");
|
||||||
|
viewDialog.setBlockOnOpen(false);
|
||||||
|
viewDialog.open();
|
||||||
|
} else {
|
||||||
|
viewDialog.bringToTop();
|
||||||
}
|
}
|
||||||
return viewDialog;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatBar getStatusBar() {
|
public StatBar getStatusBar() {
|
||||||
|
|
|
@ -20,11 +20,11 @@
|
||||||
package com.raytheon.viz.ui.statusline;
|
package com.raytheon.viz.ui.statusline;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.custom.StyleRange;
|
import org.eclipse.swt.custom.StyleRange;
|
||||||
import org.eclipse.swt.custom.StyledText;
|
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.Font;
|
||||||
import org.eclipse.swt.graphics.FontMetrics;
|
import org.eclipse.swt.graphics.FontMetrics;
|
||||||
import org.eclipse.swt.graphics.GC;
|
import org.eclipse.swt.graphics.GC;
|
||||||
|
import org.eclipse.swt.graphics.RGB;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Control;
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
|
||||||
import com.raytheon.viz.ui.statusline.StatusMessage.Importance;
|
import com.raytheon.viz.ui.statusline.StatusMessage.Importance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,6 +50,7 @@ import com.raytheon.viz.ui.statusline.StatusMessage.Importance;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* May 19, 2008 Eric Babin Initial Creation
|
* May 19, 2008 Eric Babin Initial Creation
|
||||||
|
* Oct 22, 2012 1229 rferrel Converted to CaveJFACEDialog.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -55,7 +58,7 @@ import com.raytheon.viz.ui.statusline.StatusMessage.Importance;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ViewMessagesDialog extends Dialog {
|
public class ViewMessagesDialog extends CaveJFACEDialog {
|
||||||
|
|
||||||
private SimpleDateFormat sdf;
|
private SimpleDateFormat sdf;
|
||||||
|
|
||||||
|
@ -71,6 +74,11 @@ public class ViewMessagesDialog extends Dialog {
|
||||||
|
|
||||||
private Font font;
|
private Font font;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Track colors used so they can be reused and disposed.
|
||||||
|
*/
|
||||||
|
private final Map<RGB, Color> colorMap = new HashMap<RGB, Color>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parent
|
* @param parent
|
||||||
*/
|
*/
|
||||||
|
@ -130,7 +138,9 @@ public class ViewMessagesDialog extends Dialog {
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (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
|
@Override
|
||||||
protected void configureShell(Shell shell) {
|
protected void configureShell(Shell shell) {
|
||||||
|
@ -155,11 +165,21 @@ public class ViewMessagesDialog extends Dialog {
|
||||||
String s = sdf.format(m.getMessageDate()) + " "
|
String s = sdf.format(m.getMessageDate()) + " "
|
||||||
+ m.getMessageText() + "\n";
|
+ 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(),
|
styleRanges[i++] = new StyleRange(startIndex, s.length(),
|
||||||
new Color(top.getDisplay(), importance
|
foregroundColor, backgroundColor);
|
||||||
.getForegroundColor()), new Color(top
|
|
||||||
.getDisplay(), importance.getBackgroundColor()));
|
|
||||||
|
|
||||||
styledText.setText(styledText.getText() + s);
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue