Issue #2088 changes for non-blocking RatingCurveDlg, FindReplaceDlg and TextEditorDlg.
Change-Id: I8d651254e862a45c1dad33c0d4991b29f1611828 Former-commit-id:3eacead9bb
[formerlyd620283c3b
[formerly d71b87606a93f744984f45aec8887dbc0052bb4e]] Former-commit-id:d620283c3b
Former-commit-id:5884bb5692
This commit is contained in:
parent
d01a28d968
commit
659a8f37ed
9 changed files with 485 additions and 355 deletions
|
@ -42,6 +42,7 @@ import com.raytheon.viz.hydrocommon.texteditor.TextEditorDlg;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Feb 18, 2010 2635 mpduff Initial creation
|
* Feb 18, 2010 2635 mpduff Initial creation
|
||||||
|
* Jul 16, 2013 2088 rferrel Changes for non-blocking TextEditorDlg.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -53,16 +54,22 @@ public class EditLocationShiftAction extends AbstractHandler {
|
||||||
/** The Location Shift Config file */
|
/** The Location Shift Config file */
|
||||||
private static final String LOCATION_SHIFT_CONFIG = "hydro/config/pdc_loc_shift.txt";
|
private static final String LOCATION_SHIFT_CONFIG = "hydro/config/pdc_loc_shift.txt";
|
||||||
|
|
||||||
|
/** Allow single instance of editor. */
|
||||||
|
private TextEditorDlg textDlg;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||||
.getShell();
|
.getShell();
|
||||||
IPathManager pm = PathManagerFactory.getPathManager();
|
IPathManager pm = PathManagerFactory.getPathManager();
|
||||||
File file = pm.getStaticFile(LOCATION_SHIFT_CONFIG);
|
File file = pm.getStaticFile(LOCATION_SHIFT_CONFIG);
|
||||||
TextEditorDlg textDlg = null;
|
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
textDlg = new TextEditorDlg(shell, false, file);
|
if (textDlg == null || textDlg.isDisposed()) {
|
||||||
textDlg.open();
|
textDlg = new TextEditorDlg(shell, false, file);
|
||||||
|
textDlg.open();
|
||||||
|
} else {
|
||||||
|
textDlg.bringToTop();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
*/
|
*/
|
||||||
package com.raytheon.viz.hydro.ratingcurve;
|
package com.raytheon.viz.hydro.ratingcurve;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.core.commands.AbstractHandler;
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
@ -30,6 +33,7 @@ import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
import com.raytheon.viz.hydrocommon.HydroDisplayManager;
|
import com.raytheon.viz.hydrocommon.HydroDisplayManager;
|
||||||
import com.raytheon.viz.hydrocommon.ratingcurve.RatingCurveDlg;
|
import com.raytheon.viz.hydrocommon.ratingcurve.RatingCurveDlg;
|
||||||
|
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action for unimplemented features. To be used temporarily until final
|
* Action for unimplemented features. To be used temporarily until final
|
||||||
|
@ -43,6 +47,7 @@ import com.raytheon.viz.hydrocommon.ratingcurve.RatingCurveDlg;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 6/27/06 lvenable Initial Creation.
|
* 6/27/06 lvenable Initial Creation.
|
||||||
* 24 Nov 2008 1628 dhladky updated.
|
* 24 Nov 2008 1628 dhladky updated.
|
||||||
|
* 15 Jul 2013 2088 rferrel Changes for non-blocking RatingCurveDlg.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -50,6 +55,8 @@ import com.raytheon.viz.hydrocommon.ratingcurve.RatingCurveDlg;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RatingCurveAction extends AbstractHandler {
|
public class RatingCurveAction extends AbstractHandler {
|
||||||
|
private Map<String, RatingCurveDlg> ratingCurveDlgMap = new HashMap<String, RatingCurveDlg>();
|
||||||
|
|
||||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||||
.getShell();
|
.getShell();
|
||||||
|
@ -57,16 +64,33 @@ public class RatingCurveAction extends AbstractHandler {
|
||||||
HydroDisplayManager manager = HydroDisplayManager.getInstance();
|
HydroDisplayManager manager = HydroDisplayManager.getInstance();
|
||||||
if (manager.isCurrentLidSelected(shell)) {
|
if (manager.isCurrentLidSelected(shell)) {
|
||||||
String lid = manager.getCurrentLid();
|
String lid = manager.getCurrentLid();
|
||||||
String name = manager.getCurrentData().getName();
|
RatingCurveDlg ratingCurveDlg = ratingCurveDlgMap.get(lid);
|
||||||
|
|
||||||
String displayString = " - "
|
if (ratingCurveDlg == null || ratingCurveDlg.isDisposed()) {
|
||||||
+ lid
|
String name = manager.getCurrentData().getName();
|
||||||
+ ((name != null && name.compareTo("") != 0) ? " - " + name
|
StringBuilder displayString = new StringBuilder(" - ");
|
||||||
: "");
|
displayString.append(lid);
|
||||||
|
if (name != null && name.length() > 0) {
|
||||||
|
displayString.append(" - ").append(name);
|
||||||
|
}
|
||||||
|
|
||||||
RatingCurveDlg ratingCurveDlg = new RatingCurveDlg(shell, lid,
|
ratingCurveDlg = new RatingCurveDlg(shell, lid,
|
||||||
displayString, false);
|
displayString.toString(), false);
|
||||||
ratingCurveDlg.open();
|
ratingCurveDlg.setCloseCallback(new ICloseCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
if (returnValue instanceof String) {
|
||||||
|
String lid = returnValue.toString();
|
||||||
|
ratingCurveDlgMap.remove(lid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ratingCurveDlg.open();
|
||||||
|
ratingCurveDlgMap.put(lid, ratingCurveDlg);
|
||||||
|
} else {
|
||||||
|
ratingCurveDlg.bringToTop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -128,6 +128,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
* Code clean up for non-blocking dialog.
|
* Code clean up for non-blocking dialog.
|
||||||
* Feb 27,2013 1790 rferrel Bug fix for non-blocking dialogs.
|
* Feb 27,2013 1790 rferrel Bug fix for non-blocking dialogs.
|
||||||
* Jun 07, 2013 1981 mpduff Set user's id on the OUPRequest as it is now protected.
|
* Jun 07, 2013 1981 mpduff Set user's id on the OUPRequest as it is now protected.
|
||||||
|
* Jul 16, 2013 2088 rferrel Changes for non-blocking TextEditorDlg.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -997,7 +998,6 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
tabularShefEncode();
|
tabularShefEncode();
|
||||||
// notYetImplemented();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3012,7 +3012,8 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
|
||||||
}
|
}
|
||||||
out.close();
|
out.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
statusHandler.handle(Priority.PROBLEM, "", e);
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
|
"Unable to create shef file: ", e);
|
||||||
showMessage(shell, SWT.ERROR | SWT.OK, "Unable to Save File",
|
showMessage(shell, SWT.ERROR | SWT.OK, "Unable to Save File",
|
||||||
"File: " + SHEF_FILE_NAME + "." + getPid()
|
"File: " + SHEF_FILE_NAME + "." + getPid()
|
||||||
+ "\nUser does NOT have write permission.");
|
+ "\nUser does NOT have write permission.");
|
||||||
|
@ -3026,8 +3027,12 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
|
||||||
if ((shefFileName != null) && (shefFileName.length() > 0)) {
|
if ((shefFileName != null) && (shefFileName.length() > 0)) {
|
||||||
File shefFile = new File(shefFileName);
|
File shefFile = new File(shefFileName);
|
||||||
if (shefFile.exists()) {
|
if (shefFile.exists()) {
|
||||||
editor = new TextEditorDlg(shell, false, shefFile);
|
if (editor == null || editor.isDisposed()) {
|
||||||
editor.open();
|
editor = new TextEditorDlg(shell, false, shefFile);
|
||||||
|
editor.open();
|
||||||
|
} else {
|
||||||
|
editor.bringToTop();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
showMessage(shell, SWT.OK, "Unable to Open File",
|
showMessage(shell, SWT.OK, "Unable to Open File",
|
||||||
"Unable to open file:\n" + SHEF_FILE_NAME + "."
|
"Unable to open file:\n" + SHEF_FILE_NAME + "."
|
||||||
|
|
|
@ -165,6 +165,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
* Changes for non-blocking DataSourcesDlg.
|
* Changes for non-blocking DataSourcesDlg.
|
||||||
* Changes for non-blocking ImpactStatementDlg.
|
* Changes for non-blocking ImpactStatementDlg.
|
||||||
* Changes for non-blocking LowWaterStatementDlg.
|
* Changes for non-blocking LowWaterStatementDlg.
|
||||||
|
* Changes for non-blocking RatingCurveDlg.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -352,6 +353,11 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
||||||
*/
|
*/
|
||||||
private final Map<String, LowWaterStatementDlg> lowWaterStmntDlgMap = new HashMap<String, LowWaterStatementDlg>();
|
private final Map<String, LowWaterStatementDlg> lowWaterStmntDlgMap = new HashMap<String, LowWaterStatementDlg>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow one instance per station.
|
||||||
|
*/
|
||||||
|
private final Map<String, RatingCurveDlg> ratingCurveDlgMap = new HashMap<String, RatingCurveDlg>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flood category menu item.
|
* Flood category menu item.
|
||||||
*/
|
*/
|
||||||
|
@ -938,10 +944,7 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
||||||
ratingCurveMI.addSelectionListener(new SelectionAdapter() {
|
ratingCurveMI.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
RatingCurveDlg ratingCurveDlg = new RatingCurveDlg(shell,
|
handleRatingCurveDlg();
|
||||||
getStationLid(), getStationAndName(), true);
|
|
||||||
ratingCurveDlg.open();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
riverGageMenuItems.add(ratingCurveMI);
|
riverGageMenuItems.add(ratingCurveMI);
|
||||||
|
@ -1218,6 +1221,33 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display Rating Curve Dialog for selected station.
|
||||||
|
*/
|
||||||
|
private void handleRatingCurveDlg() {
|
||||||
|
String lid = getStationLid();
|
||||||
|
RatingCurveDlg ratingCurveDlg = ratingCurveDlgMap.get(lid);
|
||||||
|
|
||||||
|
if (ratingCurveDlg == null || ratingCurveDlg.isDisposed()) {
|
||||||
|
ratingCurveDlg = new RatingCurveDlg(shell, lid,
|
||||||
|
getStationAndName(), true);
|
||||||
|
ratingCurveDlg.setCloseCallback(new ICloseCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
if (returnValue instanceof String) {
|
||||||
|
String lid = returnValue.toString();
|
||||||
|
ratingCurveDlgMap.remove(lid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ratingCurveDlg.open();
|
||||||
|
ratingCurveDlgMap.put(lid, ratingCurveDlg);
|
||||||
|
} else {
|
||||||
|
ratingCurveDlg.bringToTop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the Reservoir menu.
|
* Create the Reservoir menu.
|
||||||
*
|
*
|
||||||
|
|
|
@ -28,12 +28,13 @@ import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.graphics.Cursor;
|
|
||||||
import org.eclipse.swt.graphics.Font;
|
import org.eclipse.swt.graphics.Font;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
@ -62,6 +63,7 @@ import com.raytheon.viz.hydrocommon.HydroConstants.ArealTypeSelection;
|
||||||
import com.raytheon.viz.hydrocommon.texteditor.TextEditorDlg;
|
import com.raytheon.viz.hydrocommon.texteditor.TextEditorDlg;
|
||||||
import com.raytheon.viz.hydrocommon.whfslib.GeoUtil;
|
import com.raytheon.viz.hydrocommon.whfslib.GeoUtil;
|
||||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
|
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
import com.vividsolutions.jts.geom.Coordinate;
|
import com.vividsolutions.jts.geom.Coordinate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,6 +76,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
||||||
* 02 Sep 2008 lvenable Initial creation.
|
* 02 Sep 2008 lvenable Initial creation.
|
||||||
* 09 Sep 2009 2772 mpduff Implemented Dialog.
|
* 09 Sep 2009 2772 mpduff Implemented Dialog.
|
||||||
* 16 Apr 2013 1790 rferrel Made dialog non-blocking.
|
* 16 Apr 2013 1790 rferrel Made dialog non-blocking.
|
||||||
|
* 16 Jul 2013 2088 rferrel Changes for non-blocking TextEditorDlg.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -147,9 +150,8 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
||||||
/** Log file open flag */
|
/** Log file open flag */
|
||||||
private boolean logFileOpen = false;
|
private boolean logFileOpen = false;
|
||||||
|
|
||||||
private Cursor waitCursor = null;
|
/** Allow single instance of editor for a given file. */
|
||||||
|
private final Map<File, TextEditorDlg> textEditorDlgMap = new HashMap<File, TextEditorDlg>();
|
||||||
private Cursor arrowCursor = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -160,9 +162,6 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
||||||
public ArealDefinitionsDlg(Shell parent) {
|
public ArealDefinitionsDlg(Shell parent) {
|
||||||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||||
setText("Areal Definitions");
|
setText("Areal Definitions");
|
||||||
|
|
||||||
waitCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT);
|
|
||||||
arrowCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_ARROW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -335,8 +334,24 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
File f = getAreaFilename();
|
File f = getAreaFilename();
|
||||||
if (f != null) {
|
if (f != null) {
|
||||||
TextEditorDlg teDlg = new TextEditorDlg(shell, false, f);
|
TextEditorDlg teDlg = textEditorDlgMap.get(f);
|
||||||
teDlg.open();
|
if (teDlg == null || teDlg.isDisposed()) {
|
||||||
|
teDlg = new TextEditorDlg(shell, false, f);
|
||||||
|
teDlg.setCloseCallback(new ICloseCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
if (returnValue instanceof File) {
|
||||||
|
File f = (File) returnValue;
|
||||||
|
textEditorDlgMap.remove(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
teDlg.open();
|
||||||
|
textEditorDlgMap.put(f, teDlg);
|
||||||
|
} else {
|
||||||
|
teDlg.bringToTop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -444,14 +459,14 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleImport() {
|
private void handleImport() {
|
||||||
shell.setCursor(waitCursor);
|
shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
|
||||||
File importFile = getAreaFilename();
|
File importFile = getAreaFilename();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if the file was not accessible don't continue with the import
|
* if the file was not accessible don't continue with the import
|
||||||
*/
|
*/
|
||||||
if (importFile == null) {
|
if (importFile == null) {
|
||||||
shell.setCursor(arrowCursor);
|
shell.setCursor(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,7 +512,7 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.setCursor(arrowCursor);
|
shell.setCursor(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -563,8 +578,24 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
||||||
File f = getLogFilename();
|
File f = getLogFilename();
|
||||||
|
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
TextEditorDlg ted = new TextEditorDlg(shell, true, f);
|
TextEditorDlg ted = textEditorDlgMap.get(f);
|
||||||
ted.open();
|
if (ted == null || ted.isDisposed()) {
|
||||||
|
ted = new TextEditorDlg(shell, true, f);
|
||||||
|
ted.setCloseCallback(new ICloseCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
if (returnValue instanceof File) {
|
||||||
|
File f = (File) returnValue;
|
||||||
|
textEditorDlgMap.remove(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ted.open();
|
||||||
|
textEditorDlgMap.put(f, ted);
|
||||||
|
} else {
|
||||||
|
ted.bringToTop();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
||||||
mb.setText("File Not Found");
|
mb.setText("File Not Found");
|
||||||
|
@ -852,11 +883,9 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int numBlock = 0;
|
|
||||||
for (GeoAreaData data : geoDataList) {
|
for (GeoAreaData data : geoDataList) {
|
||||||
/* load the data into the database if good data */
|
/* load the data into the database if good data */
|
||||||
if (data.isSaveDataBlock()) {
|
if (data.isSaveDataBlock()) {
|
||||||
numBlock++;
|
|
||||||
try {
|
try {
|
||||||
int status = dman.putGeoArea(data);
|
int status = dman.putGeoArea(data);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
|
@ -926,11 +955,9 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
||||||
*/
|
*/
|
||||||
private ArrayList<Coordinate> getPointsFromArea(GeoAreaData data) {
|
private ArrayList<Coordinate> getPointsFromArea(GeoAreaData data) {
|
||||||
ArrayList<Coordinate> points = new ArrayList<Coordinate>();
|
ArrayList<Coordinate> points = new ArrayList<Coordinate>();
|
||||||
int pointCount = 0;
|
|
||||||
|
|
||||||
/* init the first point */
|
/* init the first point */
|
||||||
Coordinate coord = new Coordinate(data.getLon()[0], data.getLat()[0]);
|
Coordinate coord = new Coordinate(data.getLon()[0], data.getLat()[0]);
|
||||||
pointCount++;
|
|
||||||
points.add(coord);
|
points.add(coord);
|
||||||
double[] lat = data.getLat();
|
double[] lat = data.getLat();
|
||||||
double[] lon = data.getLon();
|
double[] lon = data.getLon();
|
||||||
|
@ -945,7 +972,6 @@ public class ArealDefinitionsDlg extends CaveSWTDialog {
|
||||||
if ((lat[i] != lat[i - 1]) || (lon[i] != lon[i - 1])) {
|
if ((lat[i] != lat[i - 1]) || (lon[i] != lon[i - 1])) {
|
||||||
coord = new Coordinate(lon[i], lat[i]);
|
coord = new Coordinate(lon[i], lat[i]);
|
||||||
points.add(coord);
|
points.add(coord);
|
||||||
pointCount++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.viz.hydrocommon.ratingcurve;
|
package com.raytheon.viz.hydrocommon.ratingcurve;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
import org.eclipse.swt.events.MouseEvent;
|
||||||
|
@ -43,6 +43,7 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Sep 8, 2008 lvenable Initial creation
|
* Sep 8, 2008 lvenable Initial creation
|
||||||
|
* Jul 15, 2013 2088 rferrel Code clean part of non-blocking dialogs.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -54,7 +55,7 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
* Parent composite.
|
* Parent composite.
|
||||||
*/
|
*/
|
||||||
private Composite parent;
|
private Composite parent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference back to parent dialog.
|
* Reference back to parent dialog.
|
||||||
*/
|
*/
|
||||||
|
@ -123,8 +124,8 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
/**
|
/**
|
||||||
* Minimum stage value in feet.
|
* Minimum stage value in feet.
|
||||||
*/
|
*/
|
||||||
private double minStageFeet = 0.0;
|
private double minStageFeet = 0.0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum flow KCFS value.
|
* Maximum flow KCFS value.
|
||||||
*/
|
*/
|
||||||
|
@ -134,10 +135,11 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
* Minimum flow KCFS value.
|
* Minimum flow KCFS value.
|
||||||
*/
|
*/
|
||||||
private double minFlowKcfs = 0.0;
|
private double minFlowKcfs = 0.0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Divisor for the flow value.
|
* Divisor for the flow value.
|
||||||
*/
|
*/
|
||||||
private double FLOW_DIVISOR = 10000.0;
|
private double FLOW_DIVISOR = 10000.0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flood value.
|
* Flood value.
|
||||||
|
@ -152,7 +154,7 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
/**
|
/**
|
||||||
* Array of curve data.
|
* Array of curve data.
|
||||||
*/
|
*/
|
||||||
private ArrayList<RatingCurveData> curveDataArray;
|
private List<RatingCurveData> curveDataArray;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of hashes on the vertical graph line.
|
* Number of hashes on the vertical graph line.
|
||||||
|
@ -163,9 +165,9 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
* Maximum stage feet label value.
|
* Maximum stage feet label value.
|
||||||
*/
|
*/
|
||||||
int maxStageFeetLabelVal = 0;
|
int maxStageFeetLabelVal = 0;
|
||||||
|
|
||||||
private double minStageFeetLabelVal = 0;
|
private double minStageFeetLabelVal = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of hashes on the horizontal graph line.
|
* Number of hashes on the horizontal graph line.
|
||||||
*/
|
*/
|
||||||
|
@ -210,7 +212,7 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
* Current Y location of mouse pointer.
|
* Current Y location of mouse pointer.
|
||||||
*/
|
*/
|
||||||
int currentY;
|
int currentY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift amount
|
* Shift amount
|
||||||
*/
|
*/
|
||||||
|
@ -229,7 +231,7 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
* Record value.
|
* Record value.
|
||||||
*/
|
*/
|
||||||
public RatingCurveCanvasComp(Composite parent, RatingCurveDlg parentDlg,
|
public RatingCurveCanvasComp(Composite parent, RatingCurveDlg parentDlg,
|
||||||
ArrayList<RatingCurveData> curveDataArray, double floodVal,
|
List<RatingCurveData> curveDataArray, double floodVal,
|
||||||
double recordDbl, double shiftAmount) {
|
double recordDbl, double shiftAmount) {
|
||||||
super(parent, SWT.DOUBLE_BUFFERED);
|
super(parent, SWT.DOUBLE_BUFFERED);
|
||||||
|
|
||||||
|
@ -252,7 +254,7 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
* @param floodVal
|
* @param floodVal
|
||||||
* @param recordDbl
|
* @param recordDbl
|
||||||
*/
|
*/
|
||||||
public void updateCurveData(ArrayList<RatingCurveData> curveDataArray,
|
public void updateCurveData(List<RatingCurveData> curveDataArray,
|
||||||
double floodVal, double recordDbl, double shiftAmount) {
|
double floodVal, double recordDbl, double shiftAmount) {
|
||||||
floodValDbl = floodVal;
|
floodValDbl = floodVal;
|
||||||
recordValDbl = recordDbl;
|
recordValDbl = recordDbl;
|
||||||
|
@ -330,7 +332,6 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
maxFlowKcfs = 0.0;
|
maxFlowKcfs = 0.0;
|
||||||
minStageFeet = 0.0;
|
minStageFeet = 0.0;
|
||||||
minFlowKcfs = 0.0;
|
minFlowKcfs = 0.0;
|
||||||
|
|
||||||
|
|
||||||
if (curveDataArray != null) {
|
if (curveDataArray != null) {
|
||||||
for (RatingCurveData curveData : curveDataArray) {
|
for (RatingCurveData curveData : curveDataArray) {
|
||||||
|
@ -341,11 +342,11 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
if (curveData.getDischarge() > maxFlowKcfs) {
|
if (curveData.getDischarge() > maxFlowKcfs) {
|
||||||
maxFlowKcfs = curveData.getDischarge();
|
maxFlowKcfs = curveData.getDischarge();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curveData.getStage() < minStageFeet) {
|
if (curveData.getStage() < minStageFeet) {
|
||||||
minStageFeet = curveData.getStage();
|
minStageFeet = curveData.getStage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curveData.getDischarge() < minFlowKcfs) {
|
if (curveData.getDischarge() < minFlowKcfs) {
|
||||||
minFlowKcfs = curveData.getDischarge();
|
minFlowKcfs = curveData.getDischarge();
|
||||||
}
|
}
|
||||||
|
@ -355,11 +356,11 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
if (maxStageFeet < floodValDbl) {
|
if (maxStageFeet < floodValDbl) {
|
||||||
maxStageFeet = floodValDbl;
|
maxStageFeet = floodValDbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxStageFeet < recordValDbl) {
|
if (maxStageFeet < recordValDbl) {
|
||||||
maxStageFeet = recordValDbl;
|
maxStageFeet = recordValDbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxFlowKcfs > 100000) {
|
if (maxFlowKcfs > 100000) {
|
||||||
FLOW_DIVISOR = 100000;
|
FLOW_DIVISOR = 100000;
|
||||||
} else if (maxFlowKcfs > 10000) {
|
} else if (maxFlowKcfs > 10000) {
|
||||||
|
@ -368,16 +369,18 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
FLOW_DIVISOR = 1000;
|
FLOW_DIVISOR = 1000;
|
||||||
}
|
}
|
||||||
maxFlowKcfs /= FLOW_DIVISOR;
|
maxFlowKcfs /= FLOW_DIVISOR;
|
||||||
|
|
||||||
if (minStageFeet >= 0) {
|
if (minStageFeet >= 0) {
|
||||||
minStageFeetLabelVal = 0;
|
minStageFeetLabelVal = 0;
|
||||||
} else {
|
} else {
|
||||||
minStageFeetLabelVal = Math.round((minStageFeet - 5) / 10) * 10;
|
minStageFeetLabelVal = Math.round((minStageFeet - 5) / 10) * 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vNumHashs = Math.round((((maxStageFeet - minStageFeetLabelVal) / 10) + 0.5d));
|
vNumHashs = Math
|
||||||
maxStageFeetLabelVal = (int) ((vNumHashs * 10) - Math.abs(minStageFeetLabelVal));
|
.round((((maxStageFeet - minStageFeetLabelVal) / 10) + 0.5d));
|
||||||
|
maxStageFeetLabelVal = (int) ((vNumHashs * 10) - Math
|
||||||
|
.abs(minStageFeetLabelVal));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -385,9 +388,10 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
* lines.
|
* lines.
|
||||||
*/
|
*/
|
||||||
private void calcPixelsPerIncrement() {
|
private void calcPixelsPerIncrement() {
|
||||||
vPixelsPerInc = VLINE_LENGTH / (maxStageFeetLabelVal - minStageFeetLabelVal);
|
vPixelsPerInc = VLINE_LENGTH
|
||||||
vPixelsPerIncBase10 = (VLINE_LENGTH/vNumHashs);
|
/ (maxStageFeetLabelVal - minStageFeetLabelVal);
|
||||||
|
vPixelsPerIncBase10 = (VLINE_LENGTH / vNumHashs);
|
||||||
|
|
||||||
hNumHashs = Math.round(((maxFlowKcfs - minFlowKcfs) + 0.5d));
|
hNumHashs = Math.round(((maxFlowKcfs - minFlowKcfs) + 0.5d));
|
||||||
maxKcfsLabelVal = (int) (hNumHashs * 10);
|
maxKcfsLabelVal = (int) (hNumHashs * 10);
|
||||||
hPixelsPerIncBase10 = HLINE_LENGTH / hNumHashs;
|
hPixelsPerIncBase10 = HLINE_LENGTH / hNumHashs;
|
||||||
|
@ -473,8 +477,9 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
yCoord);
|
yCoord);
|
||||||
|
|
||||||
// draw label
|
// draw label
|
||||||
gc.drawString(String.format("%5.1f", minStageFeetLabelVal + (x * 10)),
|
gc.drawString(
|
||||||
STAGE_FEET_HASH_LABEL_X, yCoord - fontHeightMid, true);
|
String.format("%5.1f", minStageFeetLabelVal + (x * 10)),
|
||||||
|
STAGE_FEET_HASH_LABEL_X, yCoord - fontHeightMid, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,7 +499,8 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
gc.drawLine(xCoord, HLINE_YCOORD, xCoord, HLINE_YCOORD
|
gc.drawLine(xCoord, HLINE_YCOORD, xCoord, HLINE_YCOORD
|
||||||
+ HASH_MARK);
|
+ HASH_MARK);
|
||||||
|
|
||||||
kcfsStr = String.format("%5.1f", (float) (x * FLOW_DIVISOR / 1000));
|
kcfsStr = String.format("%5.1f",
|
||||||
|
(float) (x * FLOW_DIVISOR / 1000));
|
||||||
gc.drawString(kcfsStr, xCoord
|
gc.drawString(kcfsStr, xCoord
|
||||||
- ((kcfsStr.length() * fontAveWidth) / 2)
|
- ((kcfsStr.length() * fontAveWidth) / 2)
|
||||||
- fontAveWidth, HLINE_YCOORD + HASH_MARK * 2, true);
|
- fontAveWidth, HLINE_YCOORD + HASH_MARK * 2, true);
|
||||||
|
@ -519,18 +525,13 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
.getDischarge() / FLOW_DIVISOR) * 10) * hPixelsPerInc)));
|
.getDischarge() / FLOW_DIVISOR) * 10) * hPixelsPerInc)));
|
||||||
|
|
||||||
int yCoord = 0;
|
int yCoord = 0;
|
||||||
// Math.round((i - 9) / 10) * 10
|
|
||||||
if (shiftAmount < 0) {
|
if (shiftAmount < 0) {
|
||||||
yCoord = (int) (HLINE_YCOORD - Math
|
yCoord = (int) (HLINE_YCOORD - Math.round(((curveData
|
||||||
.round(((curveData.getStage() - minStageFeetLabelVal) * vPixelsPerInc)));
|
.getStage() - minStageFeetLabelVal) * vPixelsPerInc)));
|
||||||
// yCoord = (int) (HLINE_YCOORD - Math
|
|
||||||
// .round(((curveData.getStage() - shiftAmount) * vPixelsPerInc)));
|
|
||||||
} else {
|
} else {
|
||||||
yCoord = (int) (HLINE_YCOORD - Math
|
yCoord = (int) (HLINE_YCOORD - Math.round(((curveData
|
||||||
.round(((curveData.getStage()) * vPixelsPerInc)));
|
.getStage()) * vPixelsPerInc)));
|
||||||
}
|
}
|
||||||
// int yCoord = (int) (HLINE_YCOORD - Math
|
|
||||||
// .round(((curveData.getStage() - shiftAmount) * vPixelsPerInc))); // TODO Add the shift back in
|
|
||||||
|
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
oldX = xCoord;
|
oldX = xCoord;
|
||||||
|
@ -538,9 +539,7 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
gc
|
gc.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_CYAN));
|
||||||
.setForeground(parent.getDisplay().getSystemColor(
|
|
||||||
SWT.COLOR_CYAN));
|
|
||||||
gc.drawLine(oldX, oldY, xCoord, yCoord);
|
gc.drawLine(oldX, oldY, xCoord, yCoord);
|
||||||
|
|
||||||
gc.setForeground(parent.getDisplay().getSystemColor(
|
gc.setForeground(parent.getDisplay().getSystemColor(
|
||||||
|
@ -548,8 +547,6 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
|
|
||||||
gc.drawOval(xCoord - circleWidth / 2, yCoord - circleHeight / 2,
|
gc.drawOval(xCoord - circleWidth / 2, yCoord - circleHeight / 2,
|
||||||
circleWidth, circleHeight);
|
circleWidth, circleHeight);
|
||||||
|
|
||||||
// Region r = new Region();
|
|
||||||
|
|
||||||
oldX = xCoord;
|
oldX = xCoord;
|
||||||
oldY = yCoord;
|
oldY = yCoord;
|
||||||
|
@ -557,10 +554,10 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw the cross hairs on the graph when the left
|
* Draw the cross hairs on the graph when the left mouse button is clicked.
|
||||||
* mouse button is clicked.
|
|
||||||
*
|
*
|
||||||
* @param gc The current GC
|
* @param gc
|
||||||
|
* The current GC
|
||||||
*/
|
*/
|
||||||
private void drawCrossHairs(GC gc) {
|
private void drawCrossHairs(GC gc) {
|
||||||
if ((currentX > VLINE_XCOORD)
|
if ((currentX > VLINE_XCOORD)
|
||||||
|
@ -599,21 +596,24 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the Stage and KCFS labels when moving
|
* Update the Stage and KCFS labels when moving mouse and left mouse button
|
||||||
* mouse and left mouse button is pressed.
|
* is pressed.
|
||||||
*/
|
*/
|
||||||
private void updateLabels() {
|
private void updateLabels() {
|
||||||
if ((currentX > VLINE_XCOORD)
|
if ((currentX > VLINE_XCOORD)
|
||||||
&& (currentX < VLINE_XCOORD + HLINE_LENGTH)
|
&& (currentX < VLINE_XCOORD + HLINE_LENGTH)
|
||||||
&& (currentY > HLINE_YCOORD - VLINE_LENGTH)
|
&& (currentY > HLINE_YCOORD - VLINE_LENGTH)
|
||||||
&& (currentY < HLINE_YCOORD)) {
|
&& (currentY < HLINE_YCOORD)) {
|
||||||
double q = (((currentX - VLINE_XCOORD)/(hPixelsPerInc * 100) * FLOW_DIVISOR))/100;
|
double q = (((currentX - VLINE_XCOORD) / (hPixelsPerInc * 100) * FLOW_DIVISOR)) / 100;
|
||||||
double stage = (((currentY - (minStageFeetLabelVal*vPixelsPerInc) - HLINE_YCOORD)/vPixelsPerInc * -1));
|
double stage = (((currentY - (minStageFeetLabelVal * vPixelsPerInc) - HLINE_YCOORD)
|
||||||
parentDlg.getStageDataLbl().setText(String.valueOf(String.format("%5.1f", stage)));
|
/ vPixelsPerInc * -1));
|
||||||
parentDlg.getKcfsDataLbl().setText(String.valueOf(String.format("%5.1f", q)));
|
parentDlg.getStageDataLbl().setText(
|
||||||
|
String.valueOf(String.format("%5.1f", stage)));
|
||||||
|
parentDlg.getKcfsDataLbl().setText(
|
||||||
|
String.valueOf(String.format("%5.1f", q)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleMouseDownEvent(MouseEvent e) {
|
private void handleMouseDownEvent(MouseEvent e) {
|
||||||
isMouseDown = true;
|
isMouseDown = true;
|
||||||
}
|
}
|
||||||
|
@ -622,7 +622,7 @@ public class RatingCurveCanvasComp extends Canvas {
|
||||||
isMouseDown = false;
|
isMouseDown = false;
|
||||||
redraw();
|
redraw();
|
||||||
parentDlg.getStageDataLbl().setText("");
|
parentDlg.getStageDataLbl().setText("");
|
||||||
parentDlg.getKcfsDataLbl().setText("");
|
parentDlg.getKcfsDataLbl().setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleMouseMoveEvent(MouseEvent e) {
|
private void handleMouseMoveEvent(MouseEvent e) {
|
||||||
|
|
|
@ -34,7 +34,6 @@ import java.util.Calendar;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
@ -53,11 +52,12 @@ import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
import com.raytheon.uf.common.ohd.AppsDefaults;
|
import com.raytheon.uf.common.ohd.AppsDefaults;
|
||||||
import com.raytheon.uf.viz.core.VizApp;
|
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.uf.viz.core.exception.VizException;
|
||||||
import com.raytheon.viz.hydrocommon.data.RiverDataPoint;
|
import com.raytheon.viz.hydrocommon.data.RiverDataPoint;
|
||||||
import com.raytheon.viz.hydrocommon.datamanager.RiverDataManager;
|
import com.raytheon.viz.hydrocommon.datamanager.RiverDataManager;
|
||||||
import com.raytheon.viz.ui.UiPlugin;
|
|
||||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,12 +76,15 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
* 26 Jul 2012 14711/963 mpduff Fix problems adding/removing shift points
|
* 26 Jul 2012 14711/963 mpduff Fix problems adding/removing shift points
|
||||||
* 22 Jan 2013 15682 lbousaidi fix openfile problem and changed the path to
|
* 22 Jan 2013 15682 lbousaidi fix openfile problem and changed the path to
|
||||||
* whfs_import_dir for "Import Curve" button.
|
* whfs_import_dir for "Import Curve" button.
|
||||||
|
* 15 Jul 2013 2088 rferrel Make dialog non-blocking.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author lvenable
|
* @author lvenable
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class RatingCurveDlg extends CaveSWTDialog {
|
public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
|
private final IUFStatusHandler statusHandler = UFStatus
|
||||||
|
.getHandler(RatingCurveDlg.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Control font.
|
* Control font.
|
||||||
|
@ -136,17 +139,17 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
/**
|
/**
|
||||||
* Array of rating curve data (no shift curve).
|
* Array of rating curve data (no shift curve).
|
||||||
*/
|
*/
|
||||||
private ArrayList<RatingCurveData> noShiftCurveArray;
|
private java.util.List<RatingCurveData> noShiftCurveArray;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of rating curve data (with shift curve).
|
* Array of rating curve data (with shift curve).
|
||||||
*/
|
*/
|
||||||
private ArrayList<RatingCurveData> shiftCurveArray;
|
private java.util.List<RatingCurveData> shiftCurveArray;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift Data if available
|
* Shift Data if available
|
||||||
*/
|
*/
|
||||||
private ArrayList<RatingCurveShiftData> shiftData;
|
private java.util.List<RatingCurveShiftData> shiftData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift curve data list control.
|
* Shift curve data list control.
|
||||||
|
@ -259,18 +262,24 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
private boolean newRatingCurve = false;
|
private boolean newRatingCurve = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rating curve points
|
* Rating curve remove points.
|
||||||
*/
|
*/
|
||||||
private ArrayList<RatingCurveData> removedPoints = null;
|
private java.util.List<RatingCurveData> removedPoints = null;
|
||||||
|
|
||||||
private ArrayList<RatingCurveData> addedPoints = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rating curve shift points
|
* Rating curve added points.
|
||||||
*/
|
*/
|
||||||
private ArrayList<RatingCurveShiftData> removedCurveShifts = null;
|
private java.util.List<RatingCurveData> addedPoints = null;
|
||||||
|
|
||||||
private ArrayList<RatingCurveShiftData> addedCurveShifts = null;
|
/**
|
||||||
|
* Rating curve remove shift points.
|
||||||
|
*/
|
||||||
|
private java.util.List<RatingCurveShiftData> removedCurveShifts = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rating curve added shift points.
|
||||||
|
*/
|
||||||
|
private java.util.List<RatingCurveShiftData> addedCurveShifts = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current selected shift curve
|
* The current selected shift curve
|
||||||
|
@ -294,7 +303,7 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
*/
|
*/
|
||||||
public RatingCurveDlg(Shell parent, String lid, String titleInfo,
|
public RatingCurveDlg(Shell parent, String lid, String titleInfo,
|
||||||
boolean fullControls) {
|
boolean fullControls) {
|
||||||
super(parent);
|
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||||
setText("Rating Curve" + titleInfo);
|
setText("Rating Curve" + titleInfo);
|
||||||
|
|
||||||
this.lid = lid;
|
this.lid = lid;
|
||||||
|
@ -312,8 +321,14 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
addedCurveShifts = new ArrayList<RatingCurveShiftData>();
|
addedCurveShifts = new ArrayList<RatingCurveShiftData>();
|
||||||
|
|
||||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
|
setReturnValue(lid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Layout constructShellLayout() {
|
protected Layout constructShellLayout() {
|
||||||
// Create the main layout for the shell.
|
// Create the main layout for the shell.
|
||||||
|
@ -323,15 +338,25 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
return mainLayout;
|
return mainLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void disposed() {
|
protected void disposed() {
|
||||||
controlFont.dispose();
|
controlFont.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||||
|
* .eclipse.swt.widgets.Shell)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void initializeComponents(Shell shell) {
|
protected void initializeComponents(Shell shell) {
|
||||||
setReturnValue(false);
|
|
||||||
|
|
||||||
controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
|
controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
|
||||||
|
|
||||||
// Initialize all of the controls and layouts
|
// Initialize all of the controls and layouts
|
||||||
|
@ -491,7 +516,7 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
shftRemoveBtn.addSelectionListener(new SelectionAdapter() {
|
shftRemoveBtn.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
removeShift();
|
removeShift();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -520,8 +545,9 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
curveImportBtn.addSelectionListener(new SelectionAdapter() {
|
curveImportBtn.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
final String tokenizedDir = "whfs_import_dir";
|
final String tokenizedDir = "whfs_import_dir";
|
||||||
String importRating= AppsDefaults.getInstance().getToken(tokenizedDir);
|
String importRating = AppsDefaults.getInstance().getToken(
|
||||||
|
tokenizedDir);
|
||||||
FileDialog fd = new FileDialog(shell, SWT.OPEN);
|
FileDialog fd = new FileDialog(shell, SWT.OPEN);
|
||||||
fd.setFilterPath(importRating);
|
fd.setFilterPath(importRating);
|
||||||
String[] filterExt = { "*." + extension };
|
String[] filterExt = { "*." + extension };
|
||||||
|
@ -529,10 +555,10 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
String filename = fd.open();
|
String filename = fd.open();
|
||||||
if (filename == null) {
|
if (filename == null) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
importCurveData(importRatingCurve(filename));
|
importCurveData(importRatingCurve(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -543,30 +569,32 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
curveClearAllBtn.addSelectionListener(new SelectionAdapter() {
|
curveClearAllBtn.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
MessageBox messageDialog = new MessageBox(shell, SWT.OK | SWT.CANCEL);
|
MessageBox messageDialog = new MessageBox(shell, SWT.OK
|
||||||
|
| SWT.CANCEL);
|
||||||
messageDialog.setText("Clear Confirmation");
|
messageDialog.setText("Clear Confirmation");
|
||||||
messageDialog.setMessage("This will clear the list for " + lid + ".");
|
messageDialog.setMessage("This will clear the list for " + lid
|
||||||
|
+ ".");
|
||||||
int response = messageDialog.open();
|
int response = messageDialog.open();
|
||||||
|
|
||||||
if (response == SWT.OK) {
|
if (response == SWT.OK) {
|
||||||
// get rid of every point
|
// get rid of every point
|
||||||
removedPoints = noShiftCurveArray;
|
removedPoints = noShiftCurveArray;
|
||||||
noShiftCurveArray.clear();
|
noShiftCurveArray.clear();
|
||||||
noShiftCurveDataList.removeAll();
|
noShiftCurveDataList.removeAll();
|
||||||
noShiftCurveDataList.redraw();
|
noShiftCurveDataList.redraw();
|
||||||
|
|
||||||
if (shiftCurveArray != null) {
|
if (shiftCurveArray != null) {
|
||||||
shiftCurveArray.clear();
|
shiftCurveArray.clear();
|
||||||
}
|
}
|
||||||
shiftCurveDataList.removeAll();
|
shiftCurveDataList.removeAll();
|
||||||
shiftCurveDataList.redraw();
|
shiftCurveDataList.redraw();
|
||||||
|
|
||||||
stageTF.setText("");
|
stageTF.setText("");
|
||||||
dischargeTF.setText("");
|
dischargeTF.setText("");
|
||||||
selectedRatingShift = null;
|
selectedRatingShift = null;
|
||||||
|
|
||||||
ratingCurveCanvas.updateCurveData(noShiftCurveArray, floodDbl,
|
ratingCurveCanvas.updateCurveData(noShiftCurveArray,
|
||||||
recordDbl, shiftAmount);
|
floodDbl, recordDbl, shiftAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -579,28 +607,28 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
if (noShiftCurveDataList.getSelectionIndex() != -1) {
|
if (noShiftCurveDataList.getSelectionIndex() != -1) {
|
||||||
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION
|
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION
|
||||||
| SWT.OK | SWT.CANCEL);
|
| SWT.OK | SWT.CANCEL);
|
||||||
mb.setText("Remove Base Rating Point Confirmation");
|
mb.setText("Remove Base Rating Point Confirmation");
|
||||||
mb.setMessage("This will remove the highlighted pair.");
|
mb.setMessage("This will remove the highlighted pair.");
|
||||||
int response = mb.open();
|
int response = mb.open();
|
||||||
|
|
||||||
if (response == SWT.OK) {
|
if (response == SWT.OK) {
|
||||||
// get rid of this point
|
// get rid of this point
|
||||||
int index = noShiftCurveDataList.getSelectionIndex();
|
int index = noShiftCurveDataList.getSelectionIndex();
|
||||||
removedPoints.add(noShiftCurveArray.remove(index));
|
removedPoints.add(noShiftCurveArray.remove(index));
|
||||||
remakeRatingCurveDataList();
|
remakeRatingCurveDataList();
|
||||||
|
|
||||||
stageTF.setText("");
|
stageTF.setText("");
|
||||||
dischargeTF.setText("");
|
dischargeTF.setText("");
|
||||||
|
|
||||||
if (getEditingShiftData() != null) {
|
if (getEditingShiftData() != null) {
|
||||||
generateShiftList(getEditingShiftData());
|
generateShiftList(getEditingShiftData());
|
||||||
}
|
}
|
||||||
|
|
||||||
ratingCurveCanvas.updateCurveData(noShiftCurveArray,
|
ratingCurveCanvas.updateCurveData(noShiftCurveArray,
|
||||||
floodDbl, recordDbl, shiftAmount);
|
floodDbl, recordDbl, shiftAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -616,7 +644,7 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
RatingCurveData rcd = new RatingCurveData(new Double(
|
RatingCurveData rcd = new RatingCurveData(new Double(
|
||||||
stageTF.getText().trim()), new Double(dischargeTF
|
stageTF.getText().trim()), new Double(dischargeTF
|
||||||
.getText().trim()));
|
.getText().trim()));
|
||||||
insertBaseCurvePoint(rcd);
|
insertBaseCurvePoint(rcd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -633,23 +661,28 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
shiftValueTF.setEditable(true);
|
shiftValueTF.setEditable(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void insertBaseCurvePoint(RatingCurveData rcd) {
|
|
||||||
if (!noShiftCurveArray.contains(rcd)) {
|
|
||||||
// Check for a matching stage value
|
|
||||||
RatingCurveData data = null;
|
|
||||||
for (RatingCurveData d: noShiftCurveArray) {
|
|
||||||
if (d.getStage() == rcd.getStage()) {
|
|
||||||
data = d;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data != null) {
|
|
||||||
noShiftCurveArray.remove(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
noShiftCurveArray.add(rcd);
|
/**
|
||||||
|
* Insert Rating Curve Data removing any old reference to and old rcd.
|
||||||
|
*
|
||||||
|
* @param rcd
|
||||||
|
*/
|
||||||
|
private void insertBaseCurvePoint(RatingCurveData rcd) {
|
||||||
|
if (!noShiftCurveArray.contains(rcd)) {
|
||||||
|
// Check for a matching stage value
|
||||||
|
RatingCurveData data = null;
|
||||||
|
for (RatingCurveData d : noShiftCurveArray) {
|
||||||
|
if (d.getStage() == rcd.getStage()) {
|
||||||
|
data = d;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data != null) {
|
||||||
|
noShiftCurveArray.remove(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
noShiftCurveArray.add(rcd);
|
||||||
if (!addedPoints.contains(rcd)) {
|
if (!addedPoints.contains(rcd)) {
|
||||||
addedPoints.add(rcd);
|
addedPoints.add(rcd);
|
||||||
} else {
|
} else {
|
||||||
|
@ -658,7 +691,7 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
remakeRatingCurveDataList();
|
remakeRatingCurveDataList();
|
||||||
|
|
||||||
if (getEditingShiftData() != null) {
|
if (getEditingShiftData() != null) {
|
||||||
if (getEditingShiftData().isActive()) {
|
if (getEditingShiftData().isActive()) {
|
||||||
int index = shiftDataList.getSelectionIndex();
|
int index = shiftDataList.getSelectionIndex();
|
||||||
|
@ -666,15 +699,14 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
ratingCurveCanvas.updateCurveData(shiftCurveArray,
|
ratingCurveCanvas.updateCurveData(shiftCurveArray,
|
||||||
floodDbl, recordDbl, shiftAmount);
|
floodDbl, recordDbl, shiftAmount);
|
||||||
} else {
|
} else {
|
||||||
ratingCurveCanvas.updateCurveData(
|
ratingCurveCanvas.updateCurveData(noShiftCurveArray,
|
||||||
noShiftCurveArray, floodDbl, recordDbl,
|
floodDbl, recordDbl, shiftAmount);
|
||||||
shiftAmount);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ratingCurveCanvas.updateCurveData(noShiftCurveArray,
|
ratingCurveCanvas.updateCurveData(noShiftCurveArray, floodDbl,
|
||||||
floodDbl, recordDbl, shiftAmount);
|
recordDbl, shiftAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -700,12 +732,13 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
shiftCurveDataList.setFont(controlFont);
|
shiftCurveDataList.setFont(controlFont);
|
||||||
shiftCurveDataList.setLayoutData(gd);
|
shiftCurveDataList.setLayoutData(gd);
|
||||||
shiftCurveDataList.deselectAll();
|
shiftCurveDataList.deselectAll();
|
||||||
shiftCurveDataList.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY));
|
shiftCurveDataList.setForeground(Display.getCurrent().getSystemColor(
|
||||||
|
SWT.COLOR_DARK_GRAY));
|
||||||
shiftCurveDataList.addSelectionListener(new SelectionAdapter() {
|
shiftCurveDataList.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
shiftCurveDataList.deselectAll();
|
shiftCurveDataList.deselectAll();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
|
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
|
||||||
|
@ -724,26 +757,25 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
RatingCurveData data = noShiftCurveArray
|
RatingCurveData data = noShiftCurveArray
|
||||||
.get(noShiftCurveDataList.getSelectionIndex());
|
.get(noShiftCurveDataList.getSelectionIndex());
|
||||||
stageTF.setText(String.format("%7.2f", data.getStage()));
|
stageTF.setText(String.format("%7.2f", data.getStage()));
|
||||||
dischargeTF
|
dischargeTF.setText(String.format("%7.1f", data.getDischarge()));
|
||||||
.setText(String.format("%7.1f", data.getDischarge()));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (noShiftCurveArray != null) {
|
if (noShiftCurveArray != null) {
|
||||||
// populate the list
|
// populate the list
|
||||||
RatingCurveShiftData currentShift = null;
|
RatingCurveShiftData currentShift = null;
|
||||||
if (shiftData != null && shiftData.size() > 0) {
|
if (shiftData != null && shiftData.size() > 0) {
|
||||||
if (shiftData.get(0).isActive()) {
|
if (shiftData.get(0).isActive()) {
|
||||||
currentShift = shiftData.get(0);
|
currentShift = shiftData.get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RatingCurveData curve : noShiftCurveArray) {
|
for (RatingCurveData curve : noShiftCurveArray) {
|
||||||
noShiftCurveDataList.add(curve.toString());
|
noShiftCurveDataList.add(curve.toString());
|
||||||
}
|
}
|
||||||
if (noShiftCurveDataList.getItemCount() > 0) {
|
if (noShiftCurveDataList.getItemCount() > 0) {
|
||||||
noShiftCurveDataList.select(0);
|
noShiftCurveDataList.select(0);
|
||||||
generateShiftList(currentShift);
|
generateShiftList(currentShift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -834,7 +866,7 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
save();
|
save();
|
||||||
shell.dispose();
|
close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -858,7 +890,7 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
closeBtn.addSelectionListener(new SelectionAdapter() {
|
closeBtn.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
shell.dispose();
|
close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -894,9 +926,9 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
if (shiftData != null) {
|
if (shiftData != null) {
|
||||||
for (RatingCurveShiftData rcsd : shiftData) {
|
for (RatingCurveShiftData rcsd : shiftData) {
|
||||||
String fmtStr = "%10S %10S %10S";
|
String fmtStr = "%10S %10S %10S";
|
||||||
String tmpStr = String.format(fmtStr, sdf.format(rcsd.getDate()
|
String tmpStr = String.format(fmtStr,
|
||||||
.getTime()), df.format(rcsd.getValue()), rcsd
|
sdf.format(rcsd.getDate().getTime()),
|
||||||
.isActive());
|
df.format(rcsd.getValue()), rcsd.isActive());
|
||||||
shiftDataList.add(tmpStr);
|
shiftDataList.add(tmpStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -907,11 +939,11 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
if (label != null) {
|
if (label != null) {
|
||||||
ratingLbl.setText(label);
|
ratingLbl.setText(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noShiftCurveArray.size() > 0) {
|
if (noShiftCurveArray.size() > 0) {
|
||||||
RatingCurveData rcd = noShiftCurveArray.get(0);
|
RatingCurveData rcd = noShiftCurveArray.get(0);
|
||||||
this.stageTF.setText(String.valueOf(rcd.getStage()));
|
this.stageTF.setText(String.valueOf(rcd.getStage()));
|
||||||
this.dischargeTF.setText(String.valueOf(rcd.getDischarge()));
|
this.dischargeTF.setText(String.valueOf(rcd.getDischarge()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -965,7 +997,8 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
recordDbl, shiftAmount);
|
recordDbl, shiftAmount);
|
||||||
newRatingCurve = true;
|
newRatingCurve = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
|
"Unable to import curve data: ", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return newRatingCurve;
|
return newRatingCurve;
|
||||||
|
@ -993,7 +1026,7 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
// redraw for the full effect
|
// redraw for the full effect
|
||||||
shiftCurveDataList.redraw();
|
shiftCurveDataList.redraw();
|
||||||
} else {
|
} else {
|
||||||
// make the rating curve with no shift data
|
// make the rating curve with no shift data
|
||||||
for (RatingCurveData curve : noShiftCurveArray) {
|
for (RatingCurveData curve : noShiftCurveArray) {
|
||||||
shiftCurveDataList.add(curve.toString());
|
shiftCurveDataList.add(curve.toString());
|
||||||
}
|
}
|
||||||
|
@ -1017,8 +1050,7 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION
|
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION
|
||||||
| SWT.OK | SWT.CANCEL);
|
| SWT.OK | SWT.CANCEL);
|
||||||
mb.setText("Directory Chosen!");
|
mb.setText("Directory Chosen!");
|
||||||
mb
|
mb.setMessage("Cannot open a directory, choose a rating curve. EX: 'NBD1.rating'");
|
||||||
.setMessage("Cannot open a directory, choose a rating curve. EX: 'NBD1.rating'");
|
|
||||||
mb.open();
|
mb.open();
|
||||||
}
|
}
|
||||||
// if they choose just the file to import
|
// if they choose just the file to import
|
||||||
|
@ -1027,17 +1059,15 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
try {
|
try {
|
||||||
curve = readFile(fileName);
|
curve = readFile(fileName);
|
||||||
} catch (VizException ve) {
|
} catch (VizException ve) {
|
||||||
VizApp.logAndAlert(Status.ERROR, ve,
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
"Error reading in file: " + fileName,
|
"Unable to import file \"" + fileName + "\": ",
|
||||||
"Error reading in file: " + fileName, UiPlugin
|
ve);
|
||||||
.getDefault(), UiPlugin.PLUGIN_ID);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION
|
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION
|
||||||
| SWT.OK | SWT.CANCEL);
|
| SWT.OK | SWT.CANCEL);
|
||||||
mb.setText("Invalid File format Chosen!");
|
mb.setText("Invalid File format Chosen!");
|
||||||
mb
|
mb.setMessage("Cannot open this file format, choose rating curve. EX: 'NBD1.rating'");
|
||||||
.setMessage("Cannot open this file format, choose rating curve. EX: 'NBD1.rating'");
|
|
||||||
mb.open();
|
mb.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1159,6 +1189,9 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update or insert curve data.
|
||||||
|
*/
|
||||||
private void updateInsert() {
|
private void updateInsert() {
|
||||||
try {
|
try {
|
||||||
if (verifyDate(shiftDateTF) && verifyDouble(shiftValueTF)) {
|
if (verifyDate(shiftDateTF) && verifyDouble(shiftValueTF)) {
|
||||||
|
@ -1167,74 +1200,81 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
.getInstance(TimeZone.getTimeZone("GMT"));
|
.getInstance(TimeZone.getTimeZone("GMT"));
|
||||||
cal.setTime(sdf.parse(shiftDateTF.getText()));
|
cal.setTime(sdf.parse(shiftDateTF.getText()));
|
||||||
RatingCurveShiftData rcsd = new RatingCurveShiftData(lid, cal,
|
RatingCurveShiftData rcsd = new RatingCurveShiftData(lid, cal,
|
||||||
new Double(shiftValueTF.getText()), shiftActiveChk
|
new Double(shiftValueTF.getText()),
|
||||||
.getSelection());
|
shiftActiveChk.getSelection());
|
||||||
|
|
||||||
if (shiftData.size() > 0 && shiftData.contains(rcsd)) {
|
if (shiftData.size() > 0 && shiftData.contains(rcsd)) {
|
||||||
for (RatingCurveShiftData sd: shiftData) {
|
for (RatingCurveShiftData sd : shiftData) {
|
||||||
if (rcsd.toString().equals(sd.toString())) {
|
if (rcsd.toString().equals(sd.toString())) {
|
||||||
sd.setActive(rcsd.isActive());
|
sd.setActive(rcsd.isActive());
|
||||||
sd.setDate(rcsd.getDate());
|
sd.setDate(rcsd.getDate());
|
||||||
sd.setLid(rcsd.getLid());
|
sd.setLid(rcsd.getLid());
|
||||||
sd.setValue(rcsd.getValue());
|
sd.setValue(rcsd.getValue());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
shiftData.add(rcsd);
|
shiftData.add(rcsd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!addedCurveShifts.contains(rcsd)) {
|
if (!addedCurveShifts.contains(rcsd)) {
|
||||||
addedCurveShifts.add(rcsd);
|
addedCurveShifts.add(rcsd);
|
||||||
} else {
|
} else {
|
||||||
addedCurveShifts.remove(rcsd);
|
addedCurveShifts.remove(rcsd);
|
||||||
addedCurveShifts.add(rcsd);
|
addedCurveShifts.add(rcsd);
|
||||||
}
|
}
|
||||||
|
|
||||||
shiftDataList.removeAll();
|
shiftDataList.removeAll();
|
||||||
Collections.sort(shiftData);
|
Collections.sort(shiftData);
|
||||||
|
|
||||||
for (RatingCurveShiftData sd: shiftData) {
|
for (RatingCurveShiftData sd : shiftData) {
|
||||||
shiftDataList.add(getShiftListString(sd));
|
shiftDataList.add(getShiftListString(sd));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the latest shift
|
// Display the latest shift
|
||||||
RatingCurveShiftData currentShift = shiftData.get(0);
|
RatingCurveShiftData currentShift = shiftData.get(0);
|
||||||
if (currentShift.isActive()) {
|
if (currentShift.isActive()) {
|
||||||
generateShiftList(currentShift);
|
generateShiftList(currentShift);
|
||||||
ratingCurveCanvas.updateCurveData(shiftCurveArray,
|
ratingCurveCanvas.updateCurveData(shiftCurveArray,
|
||||||
floodDbl, recordDbl, currentShift.getValue());
|
floodDbl, recordDbl, currentShift.getValue());
|
||||||
} else {
|
} else {
|
||||||
ratingCurveCanvas.updateCurveData(noShiftCurveArray,
|
ratingCurveCanvas.updateCurveData(noShiftCurveArray,
|
||||||
floodDbl, recordDbl, 0);
|
floodDbl, recordDbl, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shiftValueTF.setText("");
|
shiftValueTF.setText("");
|
||||||
shiftDateTF.setText("");
|
shiftDateTF.setText("");
|
||||||
shiftActiveChk.setSelection(false);
|
shiftActiveChk.setSelection(false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
|
"Unable to insert/update curve data: ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the selected entries from the shift data list.
|
||||||
|
*/
|
||||||
private void removeShift() {
|
private void removeShift() {
|
||||||
if (shiftDataList.getItemCount() > 0 && shiftDataList.getSelectionCount() > 0) {
|
if (shiftDataList.getItemCount() > 0
|
||||||
MessageBox messageDialog = new MessageBox(shell, SWT.OK | SWT.CANCEL);
|
&& shiftDataList.getSelectionCount() > 0) {
|
||||||
|
MessageBox messageDialog = new MessageBox(shell, SWT.OK
|
||||||
|
| SWT.CANCEL);
|
||||||
messageDialog.setText("Shift Remove Confirmation");
|
messageDialog.setText("Shift Remove Confirmation");
|
||||||
messageDialog.setMessage("This will remove the highlighted shift.");
|
messageDialog.setMessage("This will remove the highlighted shift.");
|
||||||
int response = messageDialog.open();
|
int response = messageDialog.open();
|
||||||
|
|
||||||
if (response == SWT.OK) {
|
if (response == SWT.OK) {
|
||||||
String selection = shiftDataList.getItem(shiftDataList.getSelectionIndex());
|
String selection = shiftDataList.getItem(shiftDataList
|
||||||
for (RatingCurveShiftData sd: shiftData) {
|
.getSelectionIndex());
|
||||||
if (getShiftListString(sd).equals(selection)) {
|
for (RatingCurveShiftData sd : shiftData) {
|
||||||
removedCurveShifts.add(sd);
|
if (getShiftListString(sd).equals(selection)) {
|
||||||
break;
|
removedCurveShifts.add(sd);
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
shiftData.removeAll(removedCurveShifts);
|
|
||||||
|
shiftData.removeAll(removedCurveShifts);
|
||||||
shiftDataList.removeAll();
|
shiftDataList.removeAll();
|
||||||
Collections.sort(shiftData);
|
Collections.sort(shiftData);
|
||||||
for (RatingCurveShiftData rcsd : shiftData) {
|
for (RatingCurveShiftData rcsd : shiftData) {
|
||||||
|
@ -1243,26 +1283,26 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
shiftDataList.redraw();
|
shiftDataList.redraw();
|
||||||
|
|
||||||
if (shiftData.size() > 0) {
|
if (shiftData.size() > 0) {
|
||||||
shiftAmount = shiftData.get(0).getValue();
|
shiftAmount = shiftData.get(0).getValue();
|
||||||
} else {
|
} else {
|
||||||
shiftAmount = 0;
|
shiftAmount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ratingCurveCanvas.updateCurveData(noShiftCurveArray, floodDbl,
|
||||||
|
recordDbl, shiftAmount);
|
||||||
|
|
||||||
|
if (shiftData.size() > 0) {
|
||||||
|
RatingCurveShiftData currentShift = shiftData.get(0);
|
||||||
|
if (currentShift.isActive()) {
|
||||||
|
generateShiftList(currentShift);
|
||||||
|
} else {
|
||||||
|
generateShiftList(null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
generateShiftList(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
ratingCurveCanvas.updateCurveData(noShiftCurveArray,
|
|
||||||
floodDbl, recordDbl, shiftAmount);
|
|
||||||
|
|
||||||
if (shiftData.size() > 0) {
|
|
||||||
RatingCurveShiftData currentShift = shiftData.get(0);
|
|
||||||
if (currentShift.isActive()) {
|
|
||||||
generateShiftList(currentShift);
|
|
||||||
} else {
|
|
||||||
generateShiftList(null);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
generateShiftList(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1307,8 +1347,9 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
private String getShiftListString(RatingCurveShiftData rcsd) {
|
private String getShiftListString(RatingCurveShiftData rcsd) {
|
||||||
|
|
||||||
String fmtStr = "%10S %10S %10S";
|
String fmtStr = "%10S %10S %10S";
|
||||||
String tmpStr = String.format(fmtStr, sdf.format(rcsd.getDate()
|
String tmpStr = String.format(fmtStr,
|
||||||
.getTime()), df.format(rcsd.getValue()), rcsd.isActive());
|
sdf.format(rcsd.getDate().getTime()),
|
||||||
|
df.format(rcsd.getValue()), rcsd.isActive());
|
||||||
|
|
||||||
return tmpStr;
|
return tmpStr;
|
||||||
}
|
}
|
||||||
|
@ -1326,34 +1367,35 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
* update the noShiftCurveDataList
|
* update the noShiftCurveDataList
|
||||||
*/
|
*/
|
||||||
private void remakeRatingCurveDataList() {
|
private void remakeRatingCurveDataList() {
|
||||||
Collections.sort(noShiftCurveArray);
|
Collections.sort(noShiftCurveArray);
|
||||||
int index = noShiftCurveDataList.getSelectionIndex();
|
int index = noShiftCurveDataList.getSelectionIndex();
|
||||||
noShiftCurveDataList.removeAll();
|
noShiftCurveDataList.removeAll();
|
||||||
shiftCurveDataList.removeAll();
|
shiftCurveDataList.removeAll();
|
||||||
for (RatingCurveData rcd : noShiftCurveArray) {
|
for (RatingCurveData rcd : noShiftCurveArray) {
|
||||||
noShiftCurveDataList.add(rcd.toString());
|
noShiftCurveDataList.add(rcd.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shiftData.size() > 0) {
|
if (shiftData.size() > 0) {
|
||||||
RatingCurveShiftData currentShift = shiftData.get(0);
|
RatingCurveShiftData currentShift = shiftData.get(0);
|
||||||
if (currentShift.isActive()) {
|
if (currentShift.isActive()) {
|
||||||
generateShiftList(currentShift);
|
generateShiftList(currentShift);
|
||||||
} else {
|
} else {
|
||||||
generateShiftList(null);
|
generateShiftList(null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
generateShiftList(null);
|
generateShiftList(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noShiftCurveDataList.getItemCount() > 0) {
|
if (noShiftCurveDataList.getItemCount() > 0) {
|
||||||
if (index >= noShiftCurveDataList.getItemCount()) {
|
if (index >= noShiftCurveDataList.getItemCount()) {
|
||||||
noShiftCurveDataList.select(noShiftCurveDataList.getItemCount() - 1);
|
noShiftCurveDataList
|
||||||
} else if (index >= 0 && index < noShiftCurveArray.size()) {
|
.select(noShiftCurveDataList.getItemCount() - 1);
|
||||||
noShiftCurveDataList.select(index);
|
} else if (index >= 0 && index < noShiftCurveArray.size()) {
|
||||||
} else {
|
noShiftCurveDataList.select(index);
|
||||||
noShiftCurveDataList.select(0);
|
} else {
|
||||||
}
|
noShiftCurveDataList.select(0);
|
||||||
noShiftCurveDataList.showSelection();
|
}
|
||||||
|
noShiftCurveDataList.showSelection();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1368,7 +1410,7 @@ public class RatingCurveDlg extends CaveSWTDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an intance of the Stage data label
|
* Get an instance of the Stage data label
|
||||||
*
|
*
|
||||||
* @return the label
|
* @return the label
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,6 +43,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 04 SEP 2008 lvenable Initial creation
|
* 04 SEP 2008 lvenable Initial creation
|
||||||
|
* 15 JUL 2013 2088 rferrel Make dialog non-blocking.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -90,12 +91,7 @@ public class FindReplaceDlg extends CaveSWTDialog {
|
||||||
/**
|
/**
|
||||||
* Text Editor buffer with everything upper-case.
|
* Text Editor buffer with everything upper-case.
|
||||||
*/
|
*/
|
||||||
private StringBuffer editorTextBufUpcase;
|
private final StringBuilder editorTextBufUpcase;
|
||||||
|
|
||||||
/**
|
|
||||||
* Number of characters.
|
|
||||||
*/
|
|
||||||
private int characterCount = -9999;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Found word index.
|
* Found word index.
|
||||||
|
@ -111,12 +107,19 @@ public class FindReplaceDlg extends CaveSWTDialog {
|
||||||
* Text editor containing the text to be searched.
|
* Text editor containing the text to be searched.
|
||||||
*/
|
*/
|
||||||
public FindReplaceDlg(Shell parent, StyledText textEditor) {
|
public FindReplaceDlg(Shell parent, StyledText textEditor) {
|
||||||
super(parent);
|
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||||
setText("Find and Replace");
|
setText("Find and Replace");
|
||||||
|
|
||||||
this.textEditor = textEditor;
|
this.textEditor = textEditor;
|
||||||
|
this.editorTextBufUpcase = new StringBuilder(textEditor.getText()
|
||||||
|
.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Layout constructShellLayout() {
|
protected Layout constructShellLayout() {
|
||||||
GridLayout mainLayout = new GridLayout(1, false);
|
GridLayout mainLayout = new GridLayout(1, false);
|
||||||
|
@ -125,6 +128,13 @@ public class FindReplaceDlg extends CaveSWTDialog {
|
||||||
return mainLayout;
|
return mainLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||||
|
* .eclipse.swt.widgets.Shell)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void initializeComponents(Shell shell) {
|
protected void initializeComponents(Shell shell) {
|
||||||
createSearchReplaceTextField();
|
createSearchReplaceTextField();
|
||||||
|
@ -232,7 +242,7 @@ public class FindReplaceDlg extends CaveSWTDialog {
|
||||||
closeBtn.addSelectionListener(new SelectionAdapter() {
|
closeBtn.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
shell.dispose();
|
close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -251,11 +261,8 @@ public class FindReplaceDlg extends CaveSWTDialog {
|
||||||
* Check if there has been updates to the text editor.
|
* Check if there has been updates to the text editor.
|
||||||
*/
|
*/
|
||||||
private void checkForUpdates() {
|
private void checkForUpdates() {
|
||||||
if (characterCount != textEditor.getText().length()) {
|
editorTextBufUpcase.setLength(0);
|
||||||
characterCount = textEditor.getText().length();
|
editorTextBufUpcase.append(textEditor.getText().toUpperCase());
|
||||||
editorTextBufUpcase = new StringBuffer(textEditor.getText()
|
|
||||||
.toUpperCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (caretPosition != textEditor.getCaretOffset()) {
|
if (caretPosition != textEditor.getCaretOffset()) {
|
||||||
caretPosition = textEditor.getCaretOffset();
|
caretPosition = textEditor.getCaretOffset();
|
||||||
|
@ -349,16 +356,8 @@ public class FindReplaceDlg extends CaveSWTDialog {
|
||||||
* "Replace by" text field
|
* "Replace by" text field
|
||||||
*/
|
*/
|
||||||
private void replaceAll() {
|
private void replaceAll() {
|
||||||
while (1 == 1) {
|
while (findWhatText()) {
|
||||||
if (findWhatText()) {
|
replaceText();
|
||||||
replaceText();
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bringToFront() {
|
|
||||||
shell.setActive();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Sep 9, 2008 lvenable Initial creation
|
* Sep 9, 2008 lvenable Initial creation
|
||||||
* Sep 18, 2009 2772 mpduff Fixed NullPointer when opening in Read only.
|
* Sep 18, 2009 2772 mpduff Fixed NullPointer when opening in Read only.
|
||||||
|
* Jul 15, 2013 2088 rferrel Changes for non-blocking FindReplaceDlg.
|
||||||
|
* Make dialog non-blocking.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -172,20 +174,6 @@ public class TextEditorDlg extends CaveSWTDialog {
|
||||||
*/
|
*/
|
||||||
private Image findReplaceImage;
|
private Image findReplaceImage;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* @param parent
|
|
||||||
* Parent shell.
|
|
||||||
* @param readOnly
|
|
||||||
* Read only flag.
|
|
||||||
* @param fileName
|
|
||||||
* File name in string format.
|
|
||||||
*/
|
|
||||||
public TextEditorDlg(Shell parent, boolean readOnly, String fileName) {
|
|
||||||
this(parent, readOnly, new File(fileName));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
@ -197,19 +185,27 @@ public class TextEditorDlg extends CaveSWTDialog {
|
||||||
* File to view/edit.
|
* File to view/edit.
|
||||||
*/
|
*/
|
||||||
public TextEditorDlg(Shell parent, boolean readOnly, File file) {
|
public TextEditorDlg(Shell parent, boolean readOnly, File file) {
|
||||||
super(parent, SWT.DIALOG_TRIM | SWT.RESIZE);
|
super(parent, SWT.DIALOG_TRIM | SWT.RESIZE, CAVE.DO_NOT_BLOCK);
|
||||||
if (textFile != null) {
|
|
||||||
if (readOnly == true) {
|
|
||||||
setText(textFile.getName() + " - (Read Only)");
|
|
||||||
} else {
|
|
||||||
setText(textFile.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
textFile = file;
|
textFile = file;
|
||||||
this.readOnly = readOnly;
|
this.readOnly = readOnly;
|
||||||
|
|
||||||
|
if (textFile != null) {
|
||||||
|
StringBuilder sb = new StringBuilder("Text Editor - ");
|
||||||
|
sb.append(textFile.getName());
|
||||||
|
if (readOnly == true) {
|
||||||
|
sb.append(" (Read Only)");
|
||||||
|
}
|
||||||
|
setText(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
setReturnValue(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Layout constructShellLayout() {
|
protected Layout constructShellLayout() {
|
||||||
// Create the main layout for the shell.
|
// Create the main layout for the shell.
|
||||||
|
@ -220,6 +216,11 @@ public class TextEditorDlg extends CaveSWTDialog {
|
||||||
return mainLayout;
|
return mainLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void disposed() {
|
protected void disposed() {
|
||||||
controlFont.dispose();
|
controlFont.dispose();
|
||||||
|
@ -233,9 +234,15 @@ public class TextEditorDlg extends CaveSWTDialog {
|
||||||
redoImage.dispose();
|
redoImage.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||||
|
* .eclipse.swt.widgets.Shell)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void initializeComponents(Shell shell) {
|
protected void initializeComponents(Shell shell) {
|
||||||
setReturnValue(false);
|
|
||||||
controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
|
controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
|
||||||
|
|
||||||
undoRedoArray = new ArrayList<String>();
|
undoRedoArray = new ArrayList<String>();
|
||||||
|
@ -252,6 +259,11 @@ public class TextEditorDlg extends CaveSWTDialog {
|
||||||
textST.setFocus();
|
textST.setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#shouldOpen()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldOpen() {
|
protected boolean shouldOpen() {
|
||||||
// Verify file name
|
// Verify file name
|
||||||
|
@ -261,12 +273,10 @@ public class TextEditorDlg extends CaveSWTDialog {
|
||||||
mb.setMessage("The following file does not exist:\n"
|
mb.setMessage("The following file does not exist:\n"
|
||||||
+ textFile.getAbsolutePath());
|
+ textFile.getAbsolutePath());
|
||||||
mb.open();
|
mb.open();
|
||||||
setReturnValue(false);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (readFile() == false) {
|
if (readFile() == false) {
|
||||||
setReturnValue(false);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -281,7 +291,6 @@ public class TextEditorDlg extends CaveSWTDialog {
|
||||||
createFileMenu(menuBar);
|
createFileMenu(menuBar);
|
||||||
createEditMenu(menuBar);
|
createEditMenu(menuBar);
|
||||||
createOptionsMenu(menuBar);
|
createOptionsMenu(menuBar);
|
||||||
// createHelpMenu(menuBar);
|
|
||||||
|
|
||||||
shell.setMenuBar(menuBar);
|
shell.setMenuBar(menuBar);
|
||||||
}
|
}
|
||||||
|
@ -338,7 +347,7 @@ public class TextEditorDlg extends CaveSWTDialog {
|
||||||
exitMI.addSelectionListener(new SelectionAdapter() {
|
exitMI.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
shell.dispose();
|
close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -652,8 +661,6 @@ public class TextEditorDlg extends CaveSWTDialog {
|
||||||
br.close();
|
br.close();
|
||||||
fr.close();
|
fr.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
|
||||||
|
|
||||||
MessageBox mb = new MessageBox(getParent(), SWT.ICON_ERROR | SWT.OK);
|
MessageBox mb = new MessageBox(getParent(), SWT.ICON_ERROR | SWT.OK);
|
||||||
mb.setText("File Error");
|
mb.setText("File Error");
|
||||||
mb.setMessage("An error occurred reading the file:\n"
|
mb.setMessage("An error occurred reading the file:\n"
|
||||||
|
@ -736,15 +743,14 @@ public class TextEditorDlg extends CaveSWTDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DIsplay the find and replace dialog.
|
* Display the find and replace dialog.
|
||||||
*/
|
*/
|
||||||
private void findReplaceText() {
|
private void findReplaceText() {
|
||||||
if (findReplaceDlg == null) {
|
if (findReplaceDlg == null || findReplaceDlg.isDisposed()) {
|
||||||
findReplaceDlg = new FindReplaceDlg(shell, textST);
|
findReplaceDlg = new FindReplaceDlg(shell, textST);
|
||||||
findReplaceDlg.open();
|
findReplaceDlg.open();
|
||||||
findReplaceDlg = null;
|
|
||||||
} else {
|
} else {
|
||||||
findReplaceDlg.bringToFront();
|
findReplaceDlg.bringToTop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,27 +760,18 @@ public class TextEditorDlg extends CaveSWTDialog {
|
||||||
private void saveFile() {
|
private void saveFile() {
|
||||||
FileWriter fw;
|
FileWriter fw;
|
||||||
|
|
||||||
// IPathManager pm = PathManagerFactory.getPathManager();
|
|
||||||
// LocalizationContext lc =
|
|
||||||
// pm.getContext(LocalizationType.COMMON_STATIC,
|
|
||||||
// LocalizationLevel.SITE);
|
|
||||||
// LocalizationFile newTextFile = pm.getLocalizationFile(lc,
|
|
||||||
// "hydro/" + textFile.getName());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// fw = new FileWriter(newTextFile.getFile(), false);
|
|
||||||
fw = new FileWriter(textFile, false);
|
fw = new FileWriter(textFile, false);
|
||||||
|
|
||||||
fw.write(textST.getText());
|
fw.write(textST.getText());
|
||||||
fw.flush();
|
fw.flush();
|
||||||
fw.close();
|
fw.close();
|
||||||
// newTextFile.save();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
MessageBox mb = new MessageBox(getParent(), SWT.ICON_ERROR | SWT.OK);
|
||||||
// } catch (LocalizationCommunicationException e) {
|
mb.setText("File Error");
|
||||||
// e.printStackTrace();
|
mb.setMessage("Unable to save file:\n" + textFile.getAbsolutePath()
|
||||||
// } catch (LocalizationOpFailedException e) {
|
+ "\n" + e.getMessage());
|
||||||
// e.printStackTrace();
|
mb.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue