Issue #1790 Changes for non-blocking ArealDefinitionsDlg, CoopAgencyOfficeDlg, CopyNewLocationDlg and BenchmarkDlg.
Change-Id: Ie4b0cbe02f0ba74ec6678acb20c9d085b08a4cea Former-commit-id:5d23b6a450
[formerly f3eb94989b149efb8651f37d2171615829eabf9d] Former-commit-id:3f79090c6b
This commit is contained in:
parent
f24bd5d02b
commit
be06f98b17
8 changed files with 281 additions and 707 deletions
|
@ -132,6 +132,8 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|||
* 05/09/2011 9151 lbousaid open Modify Location window on double click
|
||||
* 04/16/2013 1790 rferrel Changes for non-blocking AddModifyLocationDlg.
|
||||
* Changes for non-blocking AdministrationDlg.
|
||||
* Changes for non-blocking ArealDefinitionsDlg.
|
||||
* Changes for non-blocking BenchmarkDlg.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -141,7 +143,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|||
public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
||||
IPreferencesListener, IStationFilterListener, IStationListener,
|
||||
KeyListener {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(HydroBaseDlg.class);
|
||||
|
||||
/**
|
||||
|
@ -159,6 +161,16 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
|||
*/
|
||||
private AdministrationDlg adminDlg;
|
||||
|
||||
/**
|
||||
* Allow one areal definitions dialog.
|
||||
*/
|
||||
private ArealDefinitionsDlg arealDlg;
|
||||
|
||||
/**
|
||||
* Allow one benchmark dialog per location.
|
||||
*/
|
||||
private final Map<String, BenchmarkDlg> benchmarkDlgMap = new HashMap<String, BenchmarkDlg>();
|
||||
|
||||
/**
|
||||
* Flood category menu item.
|
||||
*/
|
||||
|
@ -681,9 +693,26 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
|||
benchmarkMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
BenchmarkDlg benchmarkDlg = new BenchmarkDlg(shell,
|
||||
getStationAndName(), getSelectedLocation().getStation());
|
||||
benchmarkDlg.open();
|
||||
String lid = getSelectedLocation().getStation();
|
||||
BenchmarkDlg benchmarkDlg = benchmarkDlgMap.get(lid);
|
||||
if (benchmarkDlg == null) {
|
||||
benchmarkDlg = new BenchmarkDlg(shell, getStationAndName(),
|
||||
lid);
|
||||
benchmarkDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof String) {
|
||||
String lid = returnValue.toString();
|
||||
benchmarkDlgMap.remove(lid);
|
||||
}
|
||||
}
|
||||
});
|
||||
benchmarkDlgMap.put(lid, benchmarkDlg);
|
||||
benchmarkDlg.open();
|
||||
} else {
|
||||
benchmarkDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
});
|
||||
riverGageMenuItems.add(benchmarkMI);
|
||||
|
@ -1020,8 +1049,12 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
|||
arealDefinitionsMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
ArealDefinitionsDlg arealDlg = new ArealDefinitionsDlg(shell);
|
||||
arealDlg.open();
|
||||
if (arealDlg == null || arealDlg.isDisposed()) {
|
||||
arealDlg = new ArealDefinitionsDlg(shell);
|
||||
arealDlg.open();
|
||||
} else {
|
||||
arealDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ import com.raytheon.viz.hydrocommon.datamanager.HydroDBDataManager;
|
|||
import com.raytheon.viz.hydrocommon.util.StnClassSyncUtil;
|
||||
import com.raytheon.viz.hydrocommon.whfslib.GeoUtil;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
* This class displays the Add/Modify location dialog. A flag is passed into the
|
||||
|
@ -79,6 +80,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* wipe out the field (e.g. blank)
|
||||
* 26 Nov 2012 15440 lbousaidi display lat/lon in the GUI in decimal degrees
|
||||
* 16 Apr 2013 1790 rferrel Make dialog non-blocking.
|
||||
* Changes for non-blocking CoopAgencyOfficeDlg.
|
||||
* Changes for non-blocking CopyNewLocationDlg.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -90,6 +93,16 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
public class AddModifyLocationDlg extends CaveSWTDialog implements
|
||||
ICountyStateListener {
|
||||
|
||||
/**
|
||||
* Allow one Coop Agency Office dialog.
|
||||
*/
|
||||
private CoopAgencyOfficeDlg coopAgencyOfficeDlg;
|
||||
|
||||
/**
|
||||
* Allow ojne Copy New dialog.
|
||||
*/
|
||||
private CopyNewLocationDlg copyDlg;
|
||||
|
||||
/**
|
||||
* Font used for controls.
|
||||
*/
|
||||
|
@ -510,10 +523,20 @@ public class AddModifyLocationDlg extends CaveSWTDialog implements
|
|||
copyToNewLocationBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
CopyNewLocationDlg copyDlg = new CopyNewLocationDlg(shell,
|
||||
locData);
|
||||
copyDlg.open();
|
||||
fireUpdateEvent();
|
||||
if (copyDlg == null) {
|
||||
copyDlg = new CopyNewLocationDlg(shell, locData);
|
||||
copyDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
copyDlg = null;
|
||||
fireUpdateEvent();
|
||||
}
|
||||
});
|
||||
copyDlg.open();
|
||||
} else {
|
||||
copyDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1085,10 +1108,21 @@ public class AddModifyLocationDlg extends CaveSWTDialog implements
|
|||
coopAgencyOfficeBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
CoopAgencyOfficeDlg coopAgencyOfficeDlg = new CoopAgencyOfficeDlg(
|
||||
shell, titleString, lid);
|
||||
coopAgencyOfficeDlg.open();
|
||||
updateCoops();
|
||||
if (coopAgencyOfficeDlg == null) {
|
||||
coopAgencyOfficeDlg = new CoopAgencyOfficeDlg(shell,
|
||||
titleString, lid);
|
||||
coopAgencyOfficeDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
coopAgencyOfficeDlg = null;
|
||||
updateCoops();
|
||||
}
|
||||
});
|
||||
coopAgencyOfficeDlg.open();
|
||||
} else {
|
||||
coopAgencyOfficeDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 02 Sep 2008 lvenable Initial creation.
|
||||
* 09 Sep 2009 2772 mpduff Implemented Dialog.
|
||||
* 16 Apr 2013 1790 rferrel Made dialog non-blocking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -81,7 +82,9 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
*
|
||||
*/
|
||||
public class ArealDefinitionsDlg extends CaveSWTDialog {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(ArealDefinitionsDlg.class);
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ArealDefinitionsDlg.class);
|
||||
|
||||
private static final String[] GEOAREA_FILENAMES = { "zones.dat",
|
||||
"counties.dat", "basins.dat", "resvrs.dat" };
|
||||
|
||||
|
@ -155,13 +158,18 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
|||
* Parent shell.
|
||||
*/
|
||||
public ArealDefinitionsDlg(Shell parent) {
|
||||
super(parent);
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||
setText("Areal Definitions");
|
||||
|
||||
waitCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT);
|
||||
arrowCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_ARROW);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||
*/
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
GridLayout mainLayout = new GridLayout(1, false);
|
||||
|
@ -171,11 +179,23 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
|||
return mainLayout;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
|
||||
*/
|
||||
@Override
|
||||
protected void disposed() {
|
||||
controlFont.dispose();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||
* .eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
setReturnValue(false);
|
||||
|
@ -192,9 +212,8 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
|||
loadAreaList(ArealTypeSelection.ZONES);
|
||||
loadAreaImport(ArealTypeSelection.ZONES);
|
||||
} catch (VizException e) {
|
||||
statusHandler.handle(
|
||||
Priority.PROBLEM,
|
||||
"Error updating Geo Area List");
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error updating Geo Area List", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,9 +400,8 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
|||
loadAreaList(selectedType);
|
||||
loadAreaImport(selectedType);
|
||||
} catch (VizException e) {
|
||||
statusHandler.handle(
|
||||
Priority.PROBLEM,
|
||||
"Error updating Geo Area List");
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error updating Geo Area List", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -409,8 +427,8 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
|||
for (GeoAreaData row : areaDataList) {
|
||||
String lat = geoUtils.cvt_latlon_from_double(row.getInteriorLat());
|
||||
String lon = geoUtils.cvt_latlon_from_double(row.getInteriorLon());
|
||||
areaList.add(String.format(GEOAREA_FORMAT, row.getAreaId(), row
|
||||
.getName(), lat, lon));
|
||||
areaList.add(String.format(GEOAREA_FORMAT, row.getAreaId(),
|
||||
row.getName(), lat, lon));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -441,26 +459,23 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
|||
/* confirm import of info */
|
||||
if (defaultMatch) {
|
||||
msg = String
|
||||
.format(
|
||||
"Importing %s data from the default file:\n %s\n\n"
|
||||
+ "This will DELETE all %s data before the import.\n\n",
|
||||
.format("Importing %s data from the default file:\n %s\n\n"
|
||||
+ "This will DELETE all %s data before the import.\n\n",
|
||||
HydroConstants.GEOAREA_DATANAMES[listCbo
|
||||
.getSelectionIndex()], importFile,
|
||||
HydroConstants.GEOAREA_DATANAMES[listCbo
|
||||
.getSelectionIndex()]);
|
||||
} else {
|
||||
msg = String
|
||||
.format(
|
||||
"Importing %s data from a user-specified file:\n %s\n\n"
|
||||
+ "This will DELETE all %s data before the import.\n\n",
|
||||
.format("Importing %s data from a user-specified file:\n %s\n\n"
|
||||
+ "This will DELETE all %s data before the import.\n\n",
|
||||
HydroConstants.GEOAREA_DATANAMES[listCbo
|
||||
.getSelectionIndex()], importFile,
|
||||
HydroConstants.GEOAREA_DATANAMES[listCbo
|
||||
.getSelectionIndex()]);
|
||||
|
||||
msg
|
||||
.concat("(Note: Occasionally save backup file copies of the data\n"
|
||||
+ " to user-specified file - i.e. not the default filename.)\n\n");
|
||||
msg.concat("(Note: Occasionally save backup file copies of the data\n"
|
||||
+ " to user-specified file - i.e. not the default filename.)\n\n");
|
||||
|
||||
msg.concat("Are you sure you wish to import the data?");
|
||||
|
||||
|
@ -476,10 +491,9 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
|||
importGeoArea();
|
||||
loadAreaList(selectedType);
|
||||
} catch (VizException e) {
|
||||
statusHandler.handle(
|
||||
Priority.PROBLEM,
|
||||
"Error importing Geo Data for file: "
|
||||
+ getAreaFilename().getAbsolutePath());
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Error importing Geo Data for file: "
|
||||
+ getAreaFilename().getAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -707,15 +721,13 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
|||
String nameString = null;
|
||||
if (name.length() > LOC_AREANAME_LEN) {
|
||||
log(String
|
||||
.format(
|
||||
"WARNING: truncated name (use 1-%d chars) in line %d: %s",
|
||||
.format("WARNING: truncated name (use 1-%d chars) in line %d: %s",
|
||||
LOC_AREANAME_LEN, linenum, line));
|
||||
|
||||
name.substring(0, 40);
|
||||
} else if (name.length() <= 0) {
|
||||
log(String
|
||||
.format(
|
||||
"WARNING: invalid name (use 1-%d chars) in line %d: %s",
|
||||
.format("WARNING: invalid name (use 1-%d chars) in line %d: %s",
|
||||
LOC_AREANAME_LEN, linenum, line));
|
||||
|
||||
nameString = "UNDEFINED";
|
||||
|
@ -775,9 +787,8 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
|||
GeoAreaData geoData = new GeoAreaData();
|
||||
geoData.setAreaId(id);
|
||||
geoData.setName(nameString);
|
||||
geoData
|
||||
.setBoundaryType(HydroConstants.GEOAREA_DATANAMES[listCbo
|
||||
.getSelectionIndex()]);
|
||||
geoData.setBoundaryType(HydroConstants.GEOAREA_DATANAMES[listCbo
|
||||
.getSelectionIndex()]);
|
||||
geoData.setInteriorLat(intLat);
|
||||
geoData.setInteriorLon(intLon);
|
||||
geoData.setLon(lonPoints);
|
||||
|
@ -896,7 +907,7 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
|||
|
||||
ArrayList<Coordinate> points = getPointsFromArea(data);
|
||||
|
||||
ArrayList<LineSegment> segments = LineSegmentUtil
|
||||
java.util.List<LineSegment> segments = LineSegmentUtil
|
||||
.getSegmentsFromPoints(points);
|
||||
|
||||
binList = LineSegmentUtil.getHrapBinListFromSegments(segments);
|
||||
|
@ -942,8 +953,8 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
|||
* if the first point and the last point are not the same, add a final
|
||||
* point that is the same as the first
|
||||
*/
|
||||
if (!LineSegmentUtil.pointsEqual(points.get(0), points.get(points
|
||||
.size() - 1))) {
|
||||
if (!LineSegmentUtil.pointsEqual(points.get(0),
|
||||
points.get(points.size() - 1))) {
|
||||
coord = new Coordinate(lon[0], lat[0]);
|
||||
points.add(coord);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,9 @@ import org.eclipse.swt.widgets.Shell;
|
|||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.raytheon.uf.common.dataquery.db.QueryResult;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.hydrocommon.data.BenchmarkData;
|
||||
import com.raytheon.viz.hydrocommon.datamanager.HydroDBDataManager;
|
||||
|
@ -53,6 +56,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 02 Sep 2008 lvenable Initial creation.
|
||||
* 17 Dec 2008 1787 askripsk Connect to database.
|
||||
* 17 Apr 2013 1790 rferrel Make dialog non-blocking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -61,6 +65,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
*
|
||||
*/
|
||||
public class BenchmarkDlg extends CaveSWTDialog {
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(BenchmarkDlg.class);
|
||||
|
||||
/**
|
||||
* Control font.
|
||||
|
@ -117,22 +123,30 @@ public class BenchmarkDlg extends CaveSWTDialog {
|
|||
*/
|
||||
private ArrayList<BenchmarkData> benchData;
|
||||
|
||||
/**
|
||||
* Dialog states.
|
||||
*/
|
||||
private enum DialogStates {
|
||||
NO_DATA, DATA_AVAILABLE, NEW_ENTRY
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Non-blocking Constructor.
|
||||
*
|
||||
* @param parent
|
||||
* Parent shell.
|
||||
*/
|
||||
public BenchmarkDlg(Shell parent, String titleInfo, String lid) {
|
||||
super(parent);
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||
setText("Benchmark" + titleInfo);
|
||||
this.lid = lid;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||
*/
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
GridLayout mainLayout = new GridLayout(1, false);
|
||||
|
@ -142,14 +156,26 @@ public class BenchmarkDlg extends CaveSWTDialog {
|
|||
return mainLayout;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
|
||||
*/
|
||||
@Override
|
||||
protected void disposed() {
|
||||
controlFont.dispose();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||
* .eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
setReturnValue(false);
|
||||
setReturnValue(lid);
|
||||
|
||||
controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
|
||||
|
||||
|
@ -158,7 +184,7 @@ public class BenchmarkDlg extends CaveSWTDialog {
|
|||
createInformationGroup();
|
||||
|
||||
createBottomButtons();
|
||||
// Get the dialog data
|
||||
// Get the dialog data
|
||||
getDialogData();
|
||||
}
|
||||
|
||||
|
@ -261,7 +287,7 @@ public class BenchmarkDlg extends CaveSWTDialog {
|
|||
}
|
||||
|
||||
if (close) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -284,7 +310,7 @@ public class BenchmarkDlg extends CaveSWTDialog {
|
|||
cancelBtn.setLayoutData(gd);
|
||||
cancelBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -324,6 +350,9 @@ public class BenchmarkDlg extends CaveSWTDialog {
|
|||
return labelStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data for the lid and update the display.
|
||||
*/
|
||||
private void getDialogData() {
|
||||
if (benchData == null) {
|
||||
benchData = new ArrayList<BenchmarkData>();
|
||||
|
@ -373,9 +402,12 @@ public class BenchmarkDlg extends CaveSWTDialog {
|
|||
*/
|
||||
private String getDisplayString(BenchmarkData currData) {
|
||||
String displayFormat = "%-6s %47s %14s";
|
||||
return String.format(displayFormat, currData.getBenchmarkNumber(), " ",
|
||||
HydroDataUtils.getDisplayString("%14s", "%8.3f", currData
|
||||
.getElevation()));
|
||||
return String.format(
|
||||
displayFormat,
|
||||
currData.getBenchmarkNumber(),
|
||||
" ",
|
||||
HydroDataUtils.getDisplayString("%14s", "%8.3f",
|
||||
currData.getElevation()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -514,8 +546,7 @@ public class BenchmarkDlg extends CaveSWTDialog {
|
|||
MessageBox mbErr = new MessageBox(shell, SWT.ICON_ERROR
|
||||
| SWT.OK);
|
||||
mbErr.setText("Unable to Delete");
|
||||
mbErr
|
||||
.setMessage("An error occurred while trying to delete the record.");
|
||||
mbErr.setMessage("An error occurred while trying to delete the record.");
|
||||
mbErr.open();
|
||||
|
||||
e.printStackTrace();
|
||||
|
@ -550,13 +581,12 @@ public class BenchmarkDlg extends CaveSWTDialog {
|
|||
} else {
|
||||
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
||||
mb.setText("Unable to Save");
|
||||
mb
|
||||
.setMessage("Data for the location must be add via the River Gauge dialog first.");
|
||||
mb.setMessage("Data for the location must be add via the River Gauge dialog first.");
|
||||
mb.open();
|
||||
}
|
||||
} catch (VizException e) {
|
||||
// don't care, just return false
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM, "Checking constraints", e);
|
||||
}
|
||||
|
||||
return rval;
|
||||
|
|
|
@ -1,527 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.viz.hydrobase.dialogs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Layout;
|
||||
import org.eclipse.swt.widgets.List;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.hydrocommon.data.CityData;
|
||||
import com.raytheon.viz.hydrocommon.datamanager.HydroDBDataManager;
|
||||
import com.raytheon.viz.hydrocommon.util.HydroDataUtils;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
||||
/**
|
||||
* This class displays the Cities dialog.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 02 Sep 2008 lvenable Initial creation.
|
||||
* 08 Jan 2008 1802 askripsk Connected to DB.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author lvenable
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
public class CitiesDlg extends CaveSWTDialog {
|
||||
|
||||
/**
|
||||
* Control font.
|
||||
*/
|
||||
private Font controlFont;
|
||||
|
||||
/**
|
||||
* Cities list control.
|
||||
*/
|
||||
private List citiesList;
|
||||
|
||||
/**
|
||||
* City text control.
|
||||
*/
|
||||
private Text cityTF;
|
||||
|
||||
/**
|
||||
* State text control.
|
||||
*/
|
||||
private Text stateTF;
|
||||
|
||||
/**
|
||||
* Latitude text control.
|
||||
*/
|
||||
private Text latTF;
|
||||
|
||||
/**
|
||||
* Longitude text control.
|
||||
*/
|
||||
private Text lonTF;
|
||||
|
||||
/**
|
||||
* Display precedence combo box.
|
||||
*/
|
||||
private Combo displayPrecCbo;
|
||||
|
||||
/**
|
||||
* Population text control.
|
||||
*/
|
||||
private Text populationTF;
|
||||
|
||||
/**
|
||||
* Update button.
|
||||
*/
|
||||
private Button updateBtn;
|
||||
|
||||
/**
|
||||
* Delete button.
|
||||
*/
|
||||
private Button deleteBtn;
|
||||
|
||||
/**
|
||||
* Cache of Cities
|
||||
*/
|
||||
private ArrayList<CityData> cityData;
|
||||
|
||||
/**
|
||||
* States of the dialog
|
||||
*/
|
||||
private enum DialogStates {
|
||||
NO_DATA, DATA_AVAILABLE
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param parent
|
||||
* Parent shell.
|
||||
*/
|
||||
public CitiesDlg(Shell parent) {
|
||||
super(parent);
|
||||
setText("Cities");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
GridLayout mainLayout = new GridLayout(1, false);
|
||||
mainLayout.marginHeight = 2;
|
||||
mainLayout.marginWidth = 2;
|
||||
mainLayout.verticalSpacing = 2;
|
||||
return mainLayout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disposed() {
|
||||
controlFont.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
setReturnValue(false);
|
||||
|
||||
controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
|
||||
|
||||
createCitiesDataList();
|
||||
|
||||
createInformationGroup();
|
||||
|
||||
// Add a separator bar
|
||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
Label sepLbl = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
|
||||
sepLbl.setLayoutData(gd);
|
||||
|
||||
createBottomButtons();
|
||||
|
||||
getDialogData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the Cities data list and label.
|
||||
*/
|
||||
private void createCitiesDataList() {
|
||||
Composite listComp = new Composite(shell, SWT.NONE);
|
||||
listComp.setLayout(new GridLayout(1, false));
|
||||
|
||||
GridData gd = new GridData();
|
||||
gd.horizontalIndent = 4;
|
||||
Label listLbl = new Label(listComp, SWT.NONE);
|
||||
listLbl.setText(getCitiesListText());
|
||||
listLbl.setFont(controlFont);
|
||||
listLbl.setLayoutData(gd);
|
||||
|
||||
gd = new GridData(575, 200);
|
||||
citiesList = new List(listComp, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
|
||||
citiesList.setLayoutData(gd);
|
||||
citiesList.setFont(controlFont);
|
||||
citiesList.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
updateInformation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the Information group and controls.
|
||||
*/
|
||||
private void createInformationGroup() {
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
GridLayout gl = new GridLayout(4, false);
|
||||
gl.horizontalSpacing = 20;
|
||||
Group informationGroup = new Group(shell, SWT.NONE);
|
||||
informationGroup.setLayout(gl);
|
||||
informationGroup.setLayoutData(gd);
|
||||
informationGroup.setText(" Information ");
|
||||
|
||||
Label cityLbl = new Label(informationGroup, SWT.NONE);
|
||||
cityLbl.setText("City:");
|
||||
|
||||
Label stateLbl = new Label(informationGroup, SWT.NONE);
|
||||
stateLbl.setText("State:");
|
||||
|
||||
Label latLbl = new Label(informationGroup, SWT.NONE);
|
||||
latLbl.setText("Lat:");
|
||||
|
||||
Label lonLbl = new Label(informationGroup, SWT.NONE);
|
||||
lonLbl.setText("Lon:");
|
||||
|
||||
gd = new GridData(150, SWT.DEFAULT);
|
||||
cityTF = new Text(informationGroup, SWT.BORDER);
|
||||
cityTF.setLayoutData(gd);
|
||||
cityTF.setTextLimit(20);
|
||||
|
||||
gd = new GridData(30, SWT.DEFAULT);
|
||||
stateTF = new Text(informationGroup, SWT.BORDER);
|
||||
stateTF.setLayoutData(gd);
|
||||
stateTF.setTextLimit(2);
|
||||
|
||||
gd = new GridData(100, SWT.DEFAULT);
|
||||
latTF = new Text(informationGroup, SWT.BORDER);
|
||||
latTF.setLayoutData(gd);
|
||||
|
||||
gd = new GridData(100, SWT.DEFAULT);
|
||||
lonTF = new Text(informationGroup, SWT.BORDER);
|
||||
lonTF.setLayoutData(gd);
|
||||
|
||||
Label displayLbl = new Label(informationGroup, SWT.NONE);
|
||||
displayLbl.setText("Display Precedence:");
|
||||
|
||||
gd = new GridData();
|
||||
gd.horizontalSpan = 3;
|
||||
Label populationLbl = new Label(informationGroup, SWT.NONE);
|
||||
populationLbl.setText("Population:");
|
||||
populationLbl.setLayoutData(gd);
|
||||
|
||||
displayPrecCbo = new Combo(informationGroup, SWT.DROP_DOWN
|
||||
| SWT.READ_ONLY);
|
||||
displayPrecCbo.add("Cities (1)");
|
||||
displayPrecCbo.add("Towns (2)");
|
||||
displayPrecCbo.select(0);
|
||||
|
||||
gd = new GridData(100, SWT.DEFAULT);
|
||||
gd.horizontalSpan = 3;
|
||||
populationTF = new Text(informationGroup, SWT.BORDER);
|
||||
populationTF.setLayoutData(gd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the bottom buttons on the dialog.
|
||||
*/
|
||||
private void createBottomButtons() {
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
Composite buttonComp = new Composite(shell, SWT.NONE);
|
||||
buttonComp.setLayout(new GridLayout(5, true));
|
||||
buttonComp.setLayoutData(gd);
|
||||
|
||||
int buttonWidth = 100;
|
||||
|
||||
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
|
||||
gd.widthHint = buttonWidth;
|
||||
Button okBtn = new Button(buttonComp, SWT.PUSH);
|
||||
okBtn.setText("OK");
|
||||
okBtn.setLayoutData(gd);
|
||||
okBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if (saveRecord()) {
|
||||
shell.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
|
||||
gd.widthHint = buttonWidth;
|
||||
Button addBtn = new Button(buttonComp, SWT.PUSH);
|
||||
addBtn.setText("Add");
|
||||
addBtn.setLayoutData(gd);
|
||||
addBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
saveRecord();
|
||||
}
|
||||
});
|
||||
|
||||
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
|
||||
gd.widthHint = buttonWidth;
|
||||
Button closeBtn = new Button(buttonComp, SWT.PUSH);
|
||||
closeBtn.setText("Close");
|
||||
closeBtn.setLayoutData(gd);
|
||||
closeBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
shell.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
|
||||
gd.widthHint = buttonWidth;
|
||||
updateBtn = new Button(buttonComp, SWT.PUSH);
|
||||
updateBtn.setText("Update");
|
||||
updateBtn.setEnabled(false);
|
||||
updateBtn.setLayoutData(gd);
|
||||
updateBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
saveRecord();
|
||||
}
|
||||
});
|
||||
|
||||
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
|
||||
gd.widthHint = buttonWidth;
|
||||
deleteBtn = new Button(buttonComp, SWT.PUSH);
|
||||
deleteBtn.setText("Delete");
|
||||
deleteBtn.setEnabled(false);
|
||||
deleteBtn.setLayoutData(gd);
|
||||
deleteBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
deleteRecord();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text for the data list label.
|
||||
*
|
||||
* @return Label text.
|
||||
*/
|
||||
private String getCitiesListText() {
|
||||
String format = "%S %S %S %S %S %S";
|
||||
|
||||
String str = String.format(format, "City", "State", "Lat", "Lon",
|
||||
"Procedure", "Pop");
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
private void getDialogData() {
|
||||
try {
|
||||
cityData = HydroDBDataManager.getInstance().getData(CityData.class);
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
private void clearInformation() {
|
||||
cityTF.setText("");
|
||||
stateTF.setText("");
|
||||
latTF.setText("");
|
||||
lonTF.setText("");
|
||||
populationTF.setText("");
|
||||
|
||||
// Display Precedence
|
||||
displayPrecCbo.select(0);
|
||||
}
|
||||
|
||||
private void updateDisplay() {
|
||||
String format = "%-21.21S %2S %10.10S %10.10S %1S %9s";
|
||||
citiesList.removeAll();
|
||||
clearInformation();
|
||||
|
||||
if (cityData.size() > 0) {
|
||||
for (CityData currCity : cityData) {
|
||||
citiesList.add(String.format(format, currCity.getName(),
|
||||
currCity.getState(),
|
||||
HydroDataUtils.getLatLonDisplayString(currCity
|
||||
.getLatitude()),
|
||||
HydroDataUtils.getLatLonDisplayString(currCity
|
||||
.getLongitude()), currCity
|
||||
.getDisplayPrecedence(), HydroDataUtils
|
||||
.getDisplayString(currCity.getPopulation())));
|
||||
}
|
||||
|
||||
updateDialogState(DialogStates.DATA_AVAILABLE);
|
||||
} else {
|
||||
updateDialogState(DialogStates.NO_DATA);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateInformation() {
|
||||
CityData currData = getSelectedRecord();
|
||||
|
||||
if (currData != null) {
|
||||
cityTF.setText(currData.getName());
|
||||
stateTF.setText(currData.getState());
|
||||
latTF.setText(HydroDataUtils.getLatLonDisplayString(currData
|
||||
.getLatitude()));
|
||||
lonTF.setText(HydroDataUtils.getLatLonDisplayString(currData
|
||||
.getLongitude()));
|
||||
populationTF.setText(HydroDataUtils.getDisplayString(currData
|
||||
.getPopulation()));
|
||||
|
||||
// Display Precedence
|
||||
displayPrecCbo.select(currData.getDisplayPrecedence() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean saveRecord() {
|
||||
boolean successful = false;
|
||||
|
||||
if (cityTF.getText().equals("")) {
|
||||
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
||||
mb.setText("Unable to Save");
|
||||
mb.setMessage("The City name cannot be empty.");
|
||||
mb.open();
|
||||
} else {
|
||||
CityData newData = new CityData();
|
||||
|
||||
newData.setName(cityTF.getText());
|
||||
newData.setState(stateTF.getText());
|
||||
|
||||
// Get Latitude
|
||||
Double tmp = HydroDataUtils.getLatitudeFromTF(shell, latTF);
|
||||
if (tmp == null) {
|
||||
return successful;
|
||||
}
|
||||
newData.setLatitude(tmp);
|
||||
|
||||
// Get Latitude
|
||||
tmp = HydroDataUtils.getLongitudeFromTF(shell, lonTF);
|
||||
if (tmp == null) {
|
||||
return successful;
|
||||
}
|
||||
newData.setLongitude(tmp);
|
||||
|
||||
// Display Precedence
|
||||
newData
|
||||
.setDisplayPrecedence(displayPrecCbo.getSelectionIndex() + 1);
|
||||
|
||||
// Population
|
||||
Integer itmp = HydroDataUtils.getIntegerFromTF(shell, populationTF,
|
||||
"Population");
|
||||
if (itmp == null) {
|
||||
return successful;
|
||||
}
|
||||
newData.setPopulation(itmp);
|
||||
|
||||
try {
|
||||
HydroDBDataManager.getInstance().putData(newData);
|
||||
|
||||
getDialogData();
|
||||
|
||||
successful = true;
|
||||
} catch (VizException e) {
|
||||
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
||||
mb.setText("Unable to Save");
|
||||
mb
|
||||
.setMessage("An error occurred while trying to save the City");
|
||||
mb.open();
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return successful;
|
||||
}
|
||||
|
||||
private void deleteRecord() {
|
||||
CityData currData = getSelectedRecord();
|
||||
|
||||
if (currData != null) {
|
||||
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK
|
||||
| SWT.CANCEL);
|
||||
mb.setText("Delete Confirmation");
|
||||
mb.setMessage("Do you wish to delete the selected city?");
|
||||
|
||||
int result = mb.open();
|
||||
|
||||
if (result == SWT.OK) {
|
||||
try {
|
||||
HydroDBDataManager.getInstance().deleteRecord(currData);
|
||||
|
||||
// Refresh the cache
|
||||
getDialogData();
|
||||
} catch (VizException e) {
|
||||
mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
||||
mb.setText("Unable to Delete");
|
||||
mb
|
||||
.setMessage("An error occurred while trying to delete the City");
|
||||
mb.open();
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
||||
mb.setText("Invalid Selection");
|
||||
mb.setMessage("Please select a city first.");
|
||||
mb.open();
|
||||
}
|
||||
}
|
||||
|
||||
private CityData getSelectedRecord() {
|
||||
CityData rval = null;
|
||||
|
||||
if (citiesList.getSelectionCount() > 0) {
|
||||
rval = cityData.get(citiesList.getSelectionIndex());
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
private void updateDialogState(DialogStates currState) {
|
||||
switch (currState) {
|
||||
case NO_DATA:
|
||||
updateBtn.setEnabled(false);
|
||||
deleteBtn.setEnabled(false);
|
||||
break;
|
||||
case DATA_AVAILABLE:
|
||||
updateBtn.setEnabled(true);
|
||||
deleteBtn.setEnabled(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -52,6 +52,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 02 Sep 2008 lvenable Initial creation.
|
||||
* 05 Dec 2008 1744 askripsky Connected data
|
||||
* 17 Apr 2013 1790 rferrel Make dialog non-blocking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -112,7 +113,7 @@ public class CoopAgencyOfficeDlg extends CaveSWTDialog {
|
|||
private ArrayList<LocationAgencyOfficeData> selectedData;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Non-blocking Constructor.
|
||||
*
|
||||
* @param parent
|
||||
* Parent shell.
|
||||
|
@ -120,12 +121,17 @@ public class CoopAgencyOfficeDlg extends CaveSWTDialog {
|
|||
* Dialog title information.
|
||||
*/
|
||||
public CoopAgencyOfficeDlg(Shell parent, String titleInfo, String lid) {
|
||||
super(parent);
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||
setText("Cooperating Agencies/Offices" + titleInfo);
|
||||
|
||||
this.lid = lid;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||
*/
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
// Create the main layout for the shell.
|
||||
|
@ -136,11 +142,23 @@ public class CoopAgencyOfficeDlg extends CaveSWTDialog {
|
|||
return mainLayout;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
|
||||
*/
|
||||
@Override
|
||||
protected void disposed() {
|
||||
controlFont.dispose();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||
* .eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
setReturnValue(false);
|
||||
|
@ -287,7 +305,7 @@ public class CoopAgencyOfficeDlg extends CaveSWTDialog {
|
|||
closeBtn.setLayoutData(gd);
|
||||
closeBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -328,8 +346,8 @@ public class CoopAgencyOfficeDlg extends CaveSWTDialog {
|
|||
selectedList.removeAll();
|
||||
|
||||
for (LocationAgencyOfficeData currAO : selectedData) {
|
||||
selectedList.add(String.format("%-11S %S", currAO
|
||||
.getAgencyCode(), currAO.getOffice()));
|
||||
selectedList.add(String.format("%-11S %S",
|
||||
currAO.getAgencyCode(), currAO.getOffice()));
|
||||
}
|
||||
|
||||
availList.setSelection(0);
|
||||
|
@ -382,9 +400,11 @@ public class CoopAgencyOfficeDlg extends CaveSWTDialog {
|
|||
populateListControl();
|
||||
}
|
||||
|
||||
/***
|
||||
* Get the selected agency/office and send the object to the datamanager to
|
||||
* delete from the DB.
|
||||
*/
|
||||
private void deleteData() {
|
||||
// Get the selected agency/office and
|
||||
// Send the object to the datamanager to delete from the DB
|
||||
if (selectedList.getSelectionCount() > 0) {
|
||||
try {
|
||||
HydroDBDataManager.getInstance().deleteRecord(
|
||||
|
@ -405,6 +425,9 @@ public class CoopAgencyOfficeDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update display with current selection.
|
||||
*/
|
||||
private void updateDisplay() {
|
||||
if (availList.getItemCount() > 0) {
|
||||
AgencyOfficeData currOffice = availData.get(availList
|
||||
|
|
|
@ -26,14 +26,18 @@ import org.eclipse.swt.layout.GridData;
|
|||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Layout;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.swt.widgets.*;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.viz.hydrocommon.data.LocationData;
|
||||
import com.raytheon.viz.hydrocommon.datamanager.AddModifyLocationDataManager;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
@ -57,6 +61,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
*
|
||||
*/
|
||||
public class CopyNewLocationDlg extends CaveSWTDialog {
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(CopyNewLocationDlg.class);
|
||||
|
||||
/**
|
||||
* Source text control.
|
||||
|
@ -90,7 +96,7 @@ public class CopyNewLocationDlg extends CaveSWTDialog {
|
|||
* Parent shell.
|
||||
*/
|
||||
public CopyNewLocationDlg(Shell parent, LocationData sourceData) {
|
||||
super(parent);
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||
setText("Copy to New Location");
|
||||
|
||||
this.sourceData = sourceData;
|
||||
|
@ -159,23 +165,23 @@ public class CopyNewLocationDlg extends CaveSWTDialog {
|
|||
destinationTF = new Text(controlComp, SWT.BORDER);
|
||||
destinationTF.setLayoutData(gd);
|
||||
destinationTF.setFocus();
|
||||
/*Only allow 8 characters to be entered */
|
||||
/* Only allow 8 characters to be entered */
|
||||
destinationTF.setTextLimit(8);
|
||||
destinationTF.addListener(SWT.Verify, new Listener(){
|
||||
public void handleEvent(Event e){
|
||||
String newStr = e.text;
|
||||
char[] newChars = new char[newStr.length()];
|
||||
newStr.getChars(0, newChars.length, newChars, 0);
|
||||
for (int i = 0; i < newChars.length; i++){
|
||||
if (!('0' <= newChars[i] && newChars[i] <= '9') &&
|
||||
!('a' <= newChars[i] && newChars[i] <= 'z') &&
|
||||
!('A' <= newChars[i] && newChars[i] <= 'Z')) {
|
||||
e.doit = false;
|
||||
}
|
||||
}
|
||||
e.text = e.text.toUpperCase();
|
||||
}
|
||||
});
|
||||
destinationTF.addListener(SWT.Verify, new Listener() {
|
||||
public void handleEvent(Event e) {
|
||||
String newStr = e.text;
|
||||
char[] newChars = new char[newStr.length()];
|
||||
newStr.getChars(0, newChars.length, newChars, 0);
|
||||
for (int i = 0; i < newChars.length; i++) {
|
||||
if (!('0' <= newChars[i] && newChars[i] <= '9')
|
||||
&& !('a' <= newChars[i] && newChars[i] <= 'z')
|
||||
&& !('A' <= newChars[i] && newChars[i] <= 'Z')) {
|
||||
e.doit = false;
|
||||
}
|
||||
}
|
||||
e.text = e.text.toUpperCase();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -215,7 +221,7 @@ public class CopyNewLocationDlg extends CaveSWTDialog {
|
|||
copyBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if (copyLocation()) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -227,20 +233,20 @@ public class CopyNewLocationDlg extends CaveSWTDialog {
|
|||
cancelBtn.setLayoutData(gd);
|
||||
cancelBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Populate dialog with information in source data.
|
||||
*/
|
||||
private void initializeData() {
|
||||
sourceTF.setText(sourceData.getLid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the actual copy methods based on the
|
||||
* Calls the actual copy methods based on the user's selections.
|
||||
*
|
||||
* @return True if the data was copied successfully, otherwise False
|
||||
*/
|
||||
|
@ -261,12 +267,7 @@ public class CopyNewLocationDlg extends CaveSWTDialog {
|
|||
}
|
||||
successfulCopy = true;
|
||||
} catch (Exception e) {
|
||||
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
||||
mb.setText("Copy Failure");
|
||||
mb.setMessage("An error occurred while copying the location");
|
||||
mb.open();
|
||||
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM, "Copy Failure", e);
|
||||
}
|
||||
} else {
|
||||
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.viz.hydrobase.dialogs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.viz.hydrobase.data.HrapBinList;
|
||||
import com.raytheon.viz.hydrobase.data.LineSegment;
|
||||
|
@ -36,6 +37,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 15, 2009 2772 mpduff Initial creation
|
||||
* Apr 16, 2013 1790 rferrel Code clean up for non-blocking dialogs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -44,7 +46,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
*/
|
||||
|
||||
public class LineSegmentUtil {
|
||||
private static final int LATLON_NORTHWEST_CORNER = 0;
|
||||
// private static final int LATLON_NORTHWEST_CORNER = 0;
|
||||
|
||||
private static final int LATLON_NORTHEAST_CORNER = 1;
|
||||
|
||||
|
@ -59,15 +61,15 @@ public class LineSegmentUtil {
|
|||
* i+1 th points are used to initialize n-1 segments.
|
||||
*
|
||||
* @param points
|
||||
* ArrayList of Point objects
|
||||
* List of Point objects
|
||||
*/
|
||||
public static ArrayList<LineSegment> getSegmentsFromPoints(
|
||||
ArrayList<Coordinate> points) {
|
||||
ArrayList<LineSegment> lineSegments = new ArrayList<LineSegment>();
|
||||
public static List<LineSegment> getSegmentsFromPoints(
|
||||
List<Coordinate> points) {
|
||||
List<LineSegment> lineSegments = new ArrayList<LineSegment>();
|
||||
|
||||
for (int i = 0; i < points.size() - 1; i++) {
|
||||
LineSegment segment = initLineSegment(points.get(i), points
|
||||
.get(i + 1));
|
||||
LineSegment segment = initLineSegment(points.get(i),
|
||||
points.get(i + 1));
|
||||
lineSegments.add(segment);
|
||||
}
|
||||
|
||||
|
@ -134,17 +136,13 @@ public class LineSegmentUtil {
|
|||
/* set the max and min box */
|
||||
Coordinate min = new Coordinate();
|
||||
seg.setMin(min);
|
||||
seg.getMin().y = (
|
||||
minDouble(seg.getPoint1().y, seg.getPoint2().y));
|
||||
seg.getMin().x = (
|
||||
minDouble(seg.getPoint1().x, seg.getPoint2().x));
|
||||
|
||||
seg.getMin().y = Math.min(seg.getPoint1().y, seg.getPoint2().y);
|
||||
seg.getMin().x = Math.min(seg.getPoint1().x, seg.getPoint2().x);
|
||||
|
||||
Coordinate max = new Coordinate();
|
||||
seg.setMax(max);
|
||||
seg.getMax().y = (
|
||||
maxDouble(seg.getPoint1().y, seg.getPoint2().y));
|
||||
seg.getMax().x = (
|
||||
maxDouble(seg.getPoint1().x, seg.getPoint2().x));
|
||||
seg.getMax().y = Math.max(seg.getPoint1().y, seg.getPoint2().y);
|
||||
seg.getMax().x = Math.max(seg.getPoint1().x, seg.getPoint2().x);
|
||||
|
||||
return seg;
|
||||
}
|
||||
|
@ -170,16 +168,16 @@ public class LineSegmentUtil {
|
|||
* area.
|
||||
*
|
||||
* @param segments
|
||||
* ArrayList of LineSegment objects
|
||||
* List of LineSegment objects
|
||||
*/
|
||||
public static HrapBinList getHrapBinListFromSegments(
|
||||
ArrayList<LineSegment> segments) {
|
||||
List<LineSegment> segments) {
|
||||
HrapBinList binList = new HrapBinList();
|
||||
Coordinate maxLatLon;
|
||||
Coordinate minLatLon;
|
||||
Coordinate startLatLon;
|
||||
Coordinate endLatLon;
|
||||
ArrayList<Coordinate> points = new ArrayList<Coordinate>();
|
||||
List<Coordinate> points = new ArrayList<Coordinate>();
|
||||
double r;
|
||||
double c;
|
||||
double maxCol;
|
||||
|
@ -206,7 +204,8 @@ public class LineSegmentUtil {
|
|||
* longitude box defined by the max lat/lon and the min lat/lon pairs
|
||||
* retrieved above.
|
||||
*/
|
||||
Coordinate hrap = HrapUtil.latLonToHrap(new Coordinate(minLatLon.x, maxLatLon.y));
|
||||
Coordinate hrap = HrapUtil.latLonToHrap(new Coordinate(minLatLon.x,
|
||||
maxLatLon.y));
|
||||
minRow = hrap.y;
|
||||
maxRow = hrap.y;
|
||||
minCol = hrap.x;
|
||||
|
@ -215,18 +214,18 @@ public class LineSegmentUtil {
|
|||
for (int i = LATLON_NORTHEAST_CORNER; i <= LATLON_SOUTHWEST_CORNER; i++) {
|
||||
switch (i) {
|
||||
case LATLON_NORTHEAST_CORNER:
|
||||
hrap = HrapUtil
|
||||
.latLonToHrap(new Coordinate(maxLatLon.x, maxLatLon.y));
|
||||
hrap = HrapUtil.latLonToHrap(new Coordinate(maxLatLon.x,
|
||||
maxLatLon.y));
|
||||
break;
|
||||
|
||||
case LATLON_SOUTHEAST_CORNER:
|
||||
hrap = HrapUtil
|
||||
.latLonToHrap(new Coordinate(maxLatLon.x, minLatLon.y));
|
||||
hrap = HrapUtil.latLonToHrap(new Coordinate(maxLatLon.x,
|
||||
minLatLon.y));
|
||||
break;
|
||||
|
||||
case LATLON_SOUTHWEST_CORNER:
|
||||
hrap = HrapUtil
|
||||
.latLonToHrap(new Coordinate(minLatLon.x, minLatLon.y));
|
||||
hrap = HrapUtil.latLonToHrap(new Coordinate(minLatLon.x,
|
||||
minLatLon.y));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -263,11 +262,13 @@ public class LineSegmentUtil {
|
|||
numIntersections = 0;
|
||||
|
||||
/* init the first lat lon point */
|
||||
startLatLon = new Coordinate(HrapUtil.hrapToLatLon(new Coordinate(minCol - 0.5, r)));
|
||||
startLatLon = new Coordinate(HrapUtil.hrapToLatLon(new Coordinate(
|
||||
minCol - 0.5, r)));
|
||||
|
||||
for (c = minCol + 0.5; c <= maxCol; c++) {
|
||||
/* get the lat lon coordinate from the hrap row and column */
|
||||
endLatLon = new Coordinate(HrapUtil.hrapToLatLon(new Coordinate(c, r)));
|
||||
endLatLon = new Coordinate(
|
||||
HrapUtil.hrapToLatLon(new Coordinate(c, r)));
|
||||
|
||||
/* create a segment from start to end */
|
||||
segment = initLineSegment(startLatLon, endLatLon);
|
||||
|
@ -289,7 +290,8 @@ public class LineSegmentUtil {
|
|||
if (inside) {
|
||||
binList.getEndCols().set(index, (long) c);
|
||||
binList.setNumBins(binList.getNumBins() + 1);
|
||||
singleBinArea = HrapUtil.getHrapBinArea(new Coordinate(c, r));
|
||||
singleBinArea = HrapUtil.getHrapBinArea(new Coordinate(
|
||||
c, r));
|
||||
binList.setArea(binList.getArea() + singleBinArea);
|
||||
} else {
|
||||
/* previous bin was outside */
|
||||
|
@ -298,7 +300,8 @@ public class LineSegmentUtil {
|
|||
binList.getEndCols().add((long) c);
|
||||
|
||||
binList.setNumBins(binList.getNumBins() + 1);
|
||||
singleBinArea = HrapUtil.getHrapBinArea(new Coordinate(c, r));
|
||||
singleBinArea = HrapUtil.getHrapBinArea(new Coordinate(
|
||||
c, r));
|
||||
binList.setArea(binList.getArea() + singleBinArea);
|
||||
|
||||
inside = true;
|
||||
|
@ -314,61 +317,27 @@ public class LineSegmentUtil {
|
|||
binList.setNumRows(binList.getNumRows() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
startLatLon = endLatLon;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return binList;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the minimum of two doubles.
|
||||
*
|
||||
* @param num1
|
||||
* first value to check
|
||||
* @param num2
|
||||
* second value to check
|
||||
* @return the smaller of the two, num1 or num2
|
||||
*/
|
||||
public static double minDouble(double num1, double num2) {
|
||||
if (num1 < num2) {
|
||||
return num1;
|
||||
} else {
|
||||
return num2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the maximum of two doubles.
|
||||
*
|
||||
* @param num1
|
||||
* first value to check
|
||||
* @param num2
|
||||
* second value to check
|
||||
* @return the larger of the two, num1 or num2
|
||||
*/
|
||||
public static double maxDouble(double num1, double num2) {
|
||||
if (num1 > num2) {
|
||||
return num1;
|
||||
} else {
|
||||
return num2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the max x and y values for a list of segments.
|
||||
*
|
||||
* @param segments
|
||||
* ArrayList<LineSegment>
|
||||
* List<LineSegment>
|
||||
* @return Max Point of the segment list
|
||||
*/
|
||||
public static Coordinate getMaxXY(ArrayList<LineSegment> segments) {
|
||||
public static Coordinate getMaxXY(List<LineSegment> segments) {
|
||||
Coordinate p = segments.get(0).getMax();
|
||||
|
||||
for (int i = 1; i < segments.size(); i++) {
|
||||
p.x = (maxDouble(segments.get(i).getMax().x, p.x));
|
||||
p.y = (maxDouble(segments.get(i).getMax().y, p.y));
|
||||
p.x = Math.max(segments.get(i).getMax().x, p.x);
|
||||
p.y = Math.max(segments.get(i).getMax().y, p.y);
|
||||
}
|
||||
|
||||
return p;
|
||||
|
@ -378,18 +347,18 @@ public class LineSegmentUtil {
|
|||
* Determines the min x and y values for a list of segments.
|
||||
*
|
||||
* @param segments
|
||||
* ArrayList<LineSegment>
|
||||
* List<LineSegment>
|
||||
* @return Min Point of the segment list
|
||||
*/
|
||||
public static Coordinate getMinXY(ArrayList<LineSegment> segments) {
|
||||
public static Coordinate getMinXY(List<LineSegment> segments) {
|
||||
Coordinate p = new Coordinate();
|
||||
|
||||
p.x = (segments.get(0).getMin().x);
|
||||
p.y = (segments.get(0).getMin().y);
|
||||
|
||||
for (int i = 1; i < segments.size(); i++) {
|
||||
p.x = (minDouble(segments.get(i).getMin().x, p.x));
|
||||
p.y = (minDouble(segments.get(i).getMin().y, p.y));
|
||||
p.x = Math.min(segments.get(i).getMin().x, p.x);
|
||||
p.y = Math.min(segments.get(i).getMin().y, p.y);
|
||||
}
|
||||
|
||||
return p;
|
||||
|
@ -406,10 +375,10 @@ public class LineSegmentUtil {
|
|||
* @param numSegments
|
||||
* Number of segments
|
||||
*/
|
||||
public static ArrayList<Coordinate> getIntersectionPoints(LineSegment segment,
|
||||
ArrayList<LineSegment> segments) {
|
||||
public static List<Coordinate> getIntersectionPoints(LineSegment segment,
|
||||
List<LineSegment> segments) {
|
||||
Coordinate intersectPoint;
|
||||
ArrayList<Coordinate> points = new ArrayList<Coordinate>();
|
||||
List<Coordinate> points = new ArrayList<Coordinate>();
|
||||
|
||||
for (int i = 0; i < segments.size(); i++) {
|
||||
intersectPoint = getIntersectionOfSegments(segment, segments.get(i));
|
||||
|
@ -431,7 +400,8 @@ public class LineSegmentUtil {
|
|||
* LineSegment 2
|
||||
* @return The intersection point, null if no intersection
|
||||
*/
|
||||
public static Coordinate getIntersectionOfSegments(LineSegment s1, LineSegment s2) {
|
||||
public static Coordinate getIntersectionOfSegments(LineSegment s1,
|
||||
LineSegment s2) {
|
||||
Coordinate p = new Coordinate(0, 0);
|
||||
double x;
|
||||
double y;
|
||||
|
@ -461,10 +431,10 @@ public class LineSegmentUtil {
|
|||
* see if vertical segment is in the x range of the non vertical
|
||||
* segment
|
||||
*/
|
||||
if (isBetweenInclusive(tempVertical.getXValue(), tempNonVertical
|
||||
.getMin().x, tempNonVertical.getMax().x)) {
|
||||
y = evaluateLineSegmentAtX(tempNonVertical, tempVertical
|
||||
.getXValue());
|
||||
if (isBetweenInclusive(tempVertical.getXValue(),
|
||||
tempNonVertical.getMin().x, tempNonVertical.getMax().x)) {
|
||||
y = evaluateLineSegmentAtX(tempNonVertical,
|
||||
tempVertical.getXValue());
|
||||
|
||||
if ((y != HydroConstants.MISSING_VALUE)
|
||||
&& isBetweenInclusive(y, tempVertical.getMin().y,
|
||||
|
@ -517,8 +487,7 @@ public class LineSegmentUtil {
|
|||
|
||||
if (segment.isVertical()) {
|
||||
y = segment.getMin().y;
|
||||
} else if (isBetweenInclusive(x, segment.getMin().x, segment
|
||||
.getMax().x)) {
|
||||
} else if (isBetweenInclusive(x, segment.getMin().x, segment.getMax().x)) {
|
||||
y = (segment.getSlope() * x) + segment.getBase();
|
||||
} else {
|
||||
y = HydroConstants.MISSING_VALUE;
|
||||
|
|
Loading…
Add table
Reference in a new issue