Issue #1578 Changes for non-blocking FlashFloodGuidanceDlg.

Change-Id: I00efe50ba8e0fe11fcca560ef2d07293c9bdf771

Former-commit-id: 78a7d02fd2 [formerly d3fd2d7f0591f6fbe15d522a6c909f4509fede94]
Former-commit-id: bb69390c9b
This commit is contained in:
Roger Ferrel 2013-02-07 08:27:18 -06:00
parent 5e2b33206c
commit 0c5e92eb7f
3 changed files with 59 additions and 43 deletions

View file

@ -20,7 +20,7 @@
package com.raytheon.viz.hydro.flashfloodguidance;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
@ -48,6 +48,7 @@ import com.raytheon.uf.viz.core.RGBColors;
* ------------ ---------- ----------- --------------------------
* 29 NOV 2007 373 lvenable Initial creation
* 12 Oct 2009 2256 mpduff Implmented the code.
* 07 Feb 2012 1578 rferrel Code clean up non-blocking dialogs.
*
* </pre>
*
@ -119,7 +120,7 @@ public class ColorLegendComp extends Composite {
/**
* Array of legend color bar data.
*/
private ArrayList<ColorLegendBarData> barDataArray;
private List<ColorLegendBarData> barDataArray;
/**
* Constructor.
@ -130,7 +131,7 @@ public class ColorLegendComp extends Composite {
* Array of legend color bar data.
*/
public ColorLegendComp(Composite parent,
ArrayList<ColorLegendBarData> barDataArray) {
List<ColorLegendBarData> barDataArray) {
super(parent, SWT.NONE);
this.parent = parent;
@ -152,7 +153,7 @@ public class ColorLegendComp extends Composite {
* Array of legend color bar data.
*/
public ColorLegendComp(Composite parent, String title,
ArrayList<ColorLegendBarData> barDataArray) {
List<ColorLegendBarData> barDataArray) {
super(parent, SWT.NONE);
this.parent = parent;
@ -196,7 +197,8 @@ public class ColorLegendComp extends Composite {
if ((font != null) && (font.isDisposed() == false)) {
font.dispose();
}
if ((currentColor != null) && (currentColor.isDisposed() == false)) {
if ((currentColor != null)
&& (currentColor.isDisposed() == false)) {
currentColor.dispose();
}
}
@ -219,7 +221,7 @@ public class ColorLegendComp extends Composite {
if ((productText == null) || (productText.length() < 1)) {
return;
}
// Draw the FFG line text
e.gc.drawString(ffgLineText, 3, 0, true);
@ -251,8 +253,8 @@ public class ColorLegendComp extends Composite {
+ "-- setting color to white...");
currentColor = new Color(parent.getDisplay(), 255, 255, 255);
} else {
currentColor = new Color(parent.getDisplay(), RGBColors
.getRGBColor(barData.getColorName()));
currentColor = new Color(parent.getDisplay(),
RGBColors.getRGBColor(barData.getColorName()));
}
e.gc.setBackground(currentColor);
@ -272,8 +274,8 @@ public class ColorLegendComp extends Composite {
String barText;
if (i == 0) {
barText = String.format(">= %5.2f---", barData
.getDuration());
barText = String.format(">= %5.2f---",
barData.getDuration());
textY += 11;
} else if (barData.getDuration() == -8888) {
double duration = lowestValue;// - 0.01;
@ -283,32 +285,32 @@ public class ColorLegendComp extends Composite {
barText = " MISSING";
textY += 2;
} else {
barText = String.format(" %5.2f---", barData
.getDuration());
barText = String.format(" %5.2f---",
barData.getDuration());
textY += 11;
}
e.gc.drawString(barText, 3, textY, true);
}
}
/**
* Set the text to display above the legend color bar.
*
* @param line1
* The first line of text
* The first line of text
* @param line2
* The second line of text
* The second line of text
*/
public void setDisplayText(String line1, String line2) {
if ((line1 != null) && (line1.length() > 0)) {
ffgLineText = line1;
}
if ((line2 != null) && (line2.length() > 0)) {
productText = line2;
}
legendCanvas.redraw();
}
}

View file

@ -39,6 +39,7 @@ import org.eclipse.ui.PlatformUI;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 6/27/06 lvenable Initial Creation.
* 02/07/2013 1758 rferrel Changes for non-blocking FlashFloodGuidanceDlg.
*
* </pre>
*
@ -46,15 +47,25 @@ import org.eclipse.ui.PlatformUI;
*
*/
public class FlashFloodGuidanceAction extends AbstractHandler {
private FlashFloodGuidanceDlg flashFloodDlg;
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
FlashFloodGuidanceDlg flashFloodDlg = new FlashFloodGuidanceDlg(shell);
flashFloodDlg.open();
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
* .ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
if (flashFloodDlg == null) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
flashFloodDlg = new FlashFloodGuidanceDlg(shell);
}
flashFloodDlg.open();
return null;
}
return null;
}
}

View file

@ -75,6 +75,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* ------------ ---------- ----------- --------------------------
* 29 NOV 2007 373 lvenable Initial creation.
* 13 Oct 2009 2256 mpduff Implement the dialog.
* 07 Feb 2013 1578 rferrel Changes for non-blocking dialog.
*
* </pre>
*
@ -266,12 +267,17 @@ public class FlashFloodGuidanceDlg extends CaveSWTDialog {
* Parent shell.
*/
public FlashFloodGuidanceDlg(Shell parent) {
super(parent);
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
setText("Flash Flood Guidance");
waitCursor = parent.getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
arrowCursor = parent.getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
*/
@Override
protected Layout constructShellLayout() {
// Create the main layout for the shell.
@ -281,11 +287,23 @@ public class FlashFloodGuidanceDlg extends CaveSWTDialog {
return mainLayout;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
*/
@Override
protected void disposed() {
font.dispose();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
@Override
protected void initializeComponents(Shell shell) {
font = new Font(shell.getDisplay(), "Monospace", 11, SWT.NORMAL);
@ -696,22 +714,7 @@ public class FlashFloodGuidanceDlg extends CaveSWTDialog {
java.util.List<Colorvalue> colorSet = HydroDisplayManager.getInstance()
.getFFGColorMap(user_id, "FFG", duration);
// NamedColorUseSet pColorUseSet = null;
// java.util.List<NamedColorUseSet> pColorSetGroup = new
// ArrayList<NamedColorUseSet>();
//
// pColorUseSet = new NamedColorUseSet("FFG1", "Flash Flood Guidance",
// FFGConstants.FFG_LEVELS, FFGConstants.FFG, "GRAY30", "GRAY10",
// 3600);
// pColorSetGroup.add(pColorUseSet);
//
// ArrayList<Colorvalue> colorSet = (ArrayList<Colorvalue>)
// GetColorValues
// // .get_colorvalues(user_id, app_name, "FFG1", 3600, "E",
// .get_colorvalues(user_id, app_name, "FFG", 3600, "E",
// pColorSetGroup);
ArrayList<ColorLegendBarData> list = new ArrayList<ColorLegendBarData>();
java.util.List<ColorLegendBarData> list = new ArrayList<ColorLegendBarData>();
list.add(new ColorLegendBarData(colorSet.get(7).getId()
.getThresholdValue(), colorSet.get(7).getColorname()
.getColorName()));
@ -781,7 +784,7 @@ public class FlashFloodGuidanceDlg extends CaveSWTDialog {
private void readGriddedFfgProduct() {
FlashFloodGuidanceDataManager dman = FlashFloodGuidanceDataManager
.getInstance();
ArrayList<String> list = new ArrayList<String>();
java.util.List<String> list = new ArrayList<String>();
Map<String, String> sortedMap = new HashMap<String, String>();
dataMap.clear();