Merge "Issue #1353 Changes for non-blocking AttributeThresholdDlg, BasinTrendDlg and ConfigSummaryDlg." into development

Former-commit-id: ca3afef8fe6a7a5840a35af569927a1e8e1a6bfd
This commit is contained in:
Lee Venable 2012-12-07 08:49:23 -06:00 committed by Gerrit Code Review
commit 4630059ce6
5 changed files with 147 additions and 125 deletions

View file

@ -37,6 +37,23 @@ import com.raytheon.uf.viz.monitor.ffmp.ui.dialogs.FFMPConfig.ThreshColNames;
import com.raytheon.uf.viz.monitor.ffmp.xml.FFMPTableColumnXML;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
* FFMP Basin Table Threshold attribute display dialog.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Initial creation
* Dec 6, 2012 1353 rferrel Changes for non-blocking dialog.
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class AttributeThresholdDlg extends CaveSWTDialog {
private Text upperText;
@ -61,7 +78,7 @@ public class AttributeThresholdDlg extends CaveSWTDialog {
public AttributeThresholdDlg(Shell parent, ThreshColNames threshCol,
IThreshDisplay threshActionCB) {
super(parent);
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
this.threshCol = threshCol;
this.threshActionCB = threshActionCB;

View file

@ -287,7 +287,7 @@ public class AttributesDlg extends CaveSWTDialog {
closeBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
shell.dispose();
close();
}
});
}

View file

@ -22,11 +22,10 @@ package com.raytheon.uf.viz.monitor.ffmp.ui.dialogs;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import org.eclipse.swt.SWT;
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.graphics.Color;
@ -55,6 +54,23 @@ import com.raytheon.uf.viz.monitor.ffmp.ui.rsc.FFMPResource;
import com.raytheon.uf.viz.monitor.ffmp.xml.FFMPConfigBasinXML;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
* Display FFMP Basin Trend Graph.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Initial creation
* Dec 6, 2012 1353 rferrel Code clean up for non-blocking dialog.
*
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class BasinTrendDlg extends CaveSWTDialog {
/**
* Main composite.
@ -125,12 +141,12 @@ public class BasinTrendDlg extends CaveSWTDialog {
/**
* QPFSCAN radio button.
*/
private ArrayList<Button> qpfRdos = new ArrayList<Button>();
private List<Button> qpfRdos = new ArrayList<Button>();
/**
* RFCFFG radio button.
*/
private ArrayList<Button> ffgRdos = new ArrayList<Button>();
private List<Button> ffgRdos = new ArrayList<Button>();
/**
* Background color for controls and graph.
@ -176,11 +192,11 @@ public class BasinTrendDlg extends CaveSWTDialog {
/**
* Arrays of buttons for time durations, under-lay, and plots.
*/
private ArrayList<Button> timeDurationButtons;
private List<Button> timeDurationButtons;
private ArrayList<Button> underlayButtons;
private List<Button> underlayButtons;
private ArrayList<Button> plotButtons;
private List<Button> plotButtons;
/**
* Ratio item label.
@ -215,7 +231,7 @@ public class BasinTrendDlg extends CaveSWTDialog {
private FFMPResource resource;
private final ArrayList<ISourceUpdate> sourceListeners = new ArrayList<ISourceUpdate>();
private final List<ISourceUpdate> sourceListeners = new ArrayList<ISourceUpdate>();
/**
* Constructor.
@ -236,23 +252,17 @@ public class BasinTrendDlg extends CaveSWTDialog {
this.resource = resource;
this.graphData = graphData;
// try {
// this.graphData = resource.getGraphData(pfaf);
// } catch (VizException e) {
// e.printStackTrace();
// }
this.pfaf = pfaf;
this.vgb = vgb;
this.currentDate = date;
this.graphData.setDisplayDate(date);
// Print the graph data
// this.graphData.printGraphData();
}
/**
* Create the layout for the shell.
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
*/
@Override
protected Layout constructShellLayout() {
@ -265,8 +275,12 @@ public class BasinTrendDlg extends CaveSWTDialog {
return mainLayout;
}
/**
* Initialize the components on the display.
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
@Override
protected void initializeComponents(Shell shell) {
@ -290,22 +304,6 @@ public class BasinTrendDlg extends CaveSWTDialog {
* Set the Basin Trend graphing parameters.
*/
updateGraph();
// setBasinTrendGraphParms();
shell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
largeLabelFont.dispose();
medLabelFont.dispose();
smallLabelFont.dispose();
bgColor.dispose();
rateColor.dispose();
qpeColor.dispose();
qpfColor.dispose();
guidColor.dispose();
vgbColor.dispose();
}
});
}
/**
@ -349,11 +347,6 @@ public class BasinTrendDlg extends CaveSWTDialog {
colorName = ffmpCfg.getBasinTrendPlotColorName("VGB");
vgbColor = new Color(getDisplay(), new RGB(135, 206, 235));
/*
* Get reverse X Axis flag.
*/
// reverseXAxis = ffmpCfg.getFFMPConfigData().getReverseXAxis();
}
/**
@ -584,7 +577,8 @@ public class BasinTrendDlg extends CaveSWTDialog {
.getTableConfigData(resource.getSiteKey());
// FfmpTableConfig tableConf = FfmpTableConfig.getInstance();
String columnName = ffmpTableCfgData.getTableColumnAttr(
ffmpTableCfgData.getTableColumnKeys()[3]).getColumnNameWithSpace();
ffmpTableCfgData.getTableColumnKeys()[3])
.getColumnNameWithSpace();
String qpfType = columnName.substring(0, columnName.indexOf(" "));
int i = 0;
@ -804,10 +798,23 @@ public class BasinTrendDlg extends CaveSWTDialog {
});
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
*/
@Override
protected void disposed() {
// FFMPConfig.getInstance().getFFMPConfigData().setReverseXAxis(false);
sourceListeners.clear();
largeLabelFont.dispose();
medLabelFont.dispose();
smallLabelFont.dispose();
bgColor.dispose();
rateColor.dispose();
qpeColor.dispose();
qpfColor.dispose();
guidColor.dispose();
vgbColor.dispose();
}
/**
@ -958,14 +965,10 @@ public class BasinTrendDlg extends CaveSWTDialog {
updatePlotSelection(plotBtn, false);
}
// TODO : moved code outside of loop
// updateColorLegend();
// updateGraph();
}
if (guidSrc != null) {
for (Button ffg: ffgRdos) {
for (Button ffg : ffgRdos) {
if (ffg.getText().equalsIgnoreCase(guidSrc)) {
ffg.setSelection(true);
} else {
@ -1164,7 +1167,8 @@ public class BasinTrendDlg extends CaveSWTDialog {
* Set the basin trend graph parameters from the configuration.
*/
private void setBasinTrendGraphParms() {
FFMPConfigBasinXML configBasin = FFMPConfig.getInstance().getFFMPConfigData();
FFMPConfigBasinXML configBasin = FFMPConfig.getInstance()
.getFFMPConfigData();
/*
* Time duration
*/
@ -1187,7 +1191,7 @@ public class BasinTrendDlg extends CaveSWTDialog {
}
if ((underlay == Underlays.DIFF) || (underlay == Underlays.RATIO)) {
String guidSource = null;
for (Button ffg: ffgRdos) {
for (Button ffg : ffgRdos) {
if (ffg.getSelection()) {
guidSource = ffg.getText();
}
@ -1196,7 +1200,8 @@ public class BasinTrendDlg extends CaveSWTDialog {
guidSource = ffgRdos.get(0).getText();
}
if (guidSource != null) {
configBasin.setUnderlay(underlay.getUnderlayName() + "," + guidSource);
configBasin.setUnderlay(underlay.getUnderlayName() + ","
+ guidSource);
} else {
configBasin.setUnderlay(underlay.getUnderlayName());
}

View file

@ -20,9 +20,9 @@
package com.raytheon.uf.viz.monitor.ffmp.ui.dialogs;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.MouseTrackListener;
import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
@ -33,21 +33,28 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class ConfigSummaryDlg extends Dialog implements MouseListener,
MouseTrackListener {
/**
* Dialog shell.
*/
private Shell shell;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
* The display control.
*/
private Display display;
/**
* Display FFMP Basin Table's configuration summary data.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Initial creation
* Dec 6, 2012 1353 rferrel Convert to CaveSWTDialog and made non-blocking.
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class ConfigSummaryDlg extends CaveSWTDialog {
/**
* Canvas to display the information.
@ -132,8 +139,8 @@ public class ConfigSummaryDlg extends Dialog implements MouseListener,
/**
* Data labels.
*/
String[] dataLabels = new String[] { "Layer", "Link to Frame",
"Worst Case", "Zoom: Maintain Layer",
private final String[] dataLabels = new String[] { "Layer",
"Link to Frame", "Worst Case", "Zoom: Maintain Layer",
"Zoom: only Basins in Parent", "Include CWAs", "D2D Click Action",
"D2D Display Type", "Auto-Refresh" };
@ -149,7 +156,7 @@ public class ConfigSummaryDlg extends Dialog implements MouseListener,
*/
public ConfigSummaryDlg(Shell parent, Point controlLocation,
ConfigSummaryData cfgSumData) {
super(parent, 0);
super(parent, SWT.NO_TRIM, CAVE.DO_NOT_BLOCK);
this.controlLoc = controlLocation;
this.cfgSumData = cfgSumData;
@ -157,15 +164,15 @@ public class ConfigSummaryDlg extends Dialog implements MouseListener,
cfgData = this.cfgSumData.getDisplayData();
}
/**
* Open method to show the dialog.
/*
* (non-Javadoc)
*
* @return Null.
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
public Object open() {
Shell parent = getParent();
display = parent.getDisplay();
shell = new Shell(parent, SWT.NO_TRIM);
@Override
protected void initializeComponents(Shell shell) {
// Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, false);
@ -175,25 +182,10 @@ public class ConfigSummaryDlg extends Dialog implements MouseListener,
// Initialize all of the controls and layouts
initializeComponents();
shell.pack();
shell.setLocation(controlLoc.x - 100, controlLoc.y - 100);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
leftSideColor.dispose();
rightSideColor.dispose();
textFont.dispose();
return null;
}
private void initializeComponents() {
Display display = shell.getDisplay();
/*
* Setup the font and colors.
*/
@ -227,8 +219,21 @@ public class ConfigSummaryDlg extends Dialog implements MouseListener,
* Add mouse listeners to the canvas so it will be closed when the user
* moves the mouse outside the dialog or it is clicked.
*/
canvas.addMouseTrackListener(this);
canvas.addMouseListener(this);
canvas.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseExit(MouseEvent e) {
close();
}
});
canvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
close();
}
});
}
/**
@ -238,6 +243,7 @@ public class ConfigSummaryDlg extends Dialog implements MouseListener,
* Graphic context.
*/
private void drawCanvas(GC gc) {
Display display = shell.getDisplay();
gc.setFont(textFont);
gc.setTextAntialias(SWT.ON);
@ -300,6 +306,7 @@ public class ConfigSummaryDlg extends Dialog implements MouseListener,
* Make the calculation used for draw the data on the canvas.
*/
private void makeCalculations() {
Display display = shell.getDisplay();
Image image = new Image(display, 100, 100);
GC gc = new GC(image);
gc.setFont(textFont);
@ -331,34 +338,26 @@ public class ConfigSummaryDlg extends Dialog implements MouseListener,
+ (spaceBetweenText * dataLabels.length - 1);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
*/
@Override
public void mouseDoubleClick(MouseEvent e) {
// do nothing
protected void preOpened() {
super.preOpened();
shell.setLocation(controlLoc.x - 100, controlLoc.y - 100);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
*/
@Override
public void mouseDown(MouseEvent e) {
shell.dispose();
}
@Override
public void mouseUp(MouseEvent e) {
// do nothing
}
@Override
public void mouseEnter(MouseEvent e) {
// do nothing
}
@Override
public void mouseExit(MouseEvent e) {
shell.dispose();
}
@Override
public void mouseHover(MouseEvent e) {
// do nothing
protected void disposed() {
leftSideColor.dispose();
rightSideColor.dispose();
textFont.dispose();
}
}

View file

@ -1144,6 +1144,9 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
Point buttonLoc = getDisplay().map(configSummaryBtn, null, x,
y + configSummaryBtn.getSize().y);
// Create each time since data may have changed. Since the dialog closes
// with either a mouse click or moving the mouse off the dialog nothing
// can be done by the user until the non-blocking dialog is close.
ConfigSummaryDlg cfgSumDlg = new ConfigSummaryDlg(shell, buttonLoc,
cfgSumData);
cfgSumDlg.open();
@ -1254,13 +1257,11 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
}
private void displayThresholdsDialog(ThreshColNames colName) {
if ((attrThreshDlg == null) || (attrThreshDlg.isDisposed() == true)) {
if (attrThreshDlg == null) {
attrThreshDlg = new AttributeThresholdDlg(shell, colName, this);
attrThreshDlg.open();
attrThreshDlg = null;
} else {
attrThreshDlg.newThreshold(colName);
}
attrThreshDlg.open();
attrThreshDlg.newThreshold(colName);
}
/**