Merge "Issue #2088 Changes for non-blocking DataSourcesDlg, ImpactStatementDlg and LowWaterStatementDlg." into development
Former-commit-id:e78b2c6cfc
[formerly ba0218361df0703fa7600f0f32459aa2fd846d62] Former-commit-id:c1371b2429
This commit is contained in:
commit
aae2be3488
7 changed files with 548 additions and 152 deletions
|
@ -20,6 +20,9 @@
|
|||
|
||||
package com.raytheon.viz.hydro.datasources;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
@ -28,6 +31,7 @@ import org.eclipse.ui.PlatformUI;
|
|||
|
||||
import com.raytheon.viz.hydrocommon.HydroDisplayManager;
|
||||
import com.raytheon.viz.hydrocommon.datasources.DataSourcesDlg;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
* Action for Data Sources Dialog.
|
||||
|
@ -42,6 +46,7 @@ import com.raytheon.viz.hydrocommon.datasources.DataSourcesDlg;
|
|||
* 10/6/2008 1555 grichard Support data sources.
|
||||
* 12/16/2008 1782 grichard Refreshed Data Sources.
|
||||
* 1/11/2008 1802 askripsk HydroBase implementation.
|
||||
* 07/15/2013 2088 rferrel Changes for non-blocking DataSourceDlg.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -49,6 +54,7 @@ import com.raytheon.viz.hydrocommon.datasources.DataSourcesDlg;
|
|||
*
|
||||
*/
|
||||
public class DataSourcesAction extends AbstractHandler {
|
||||
private final Map<String, DataSourcesDlg> dataSourcesDlgMap = new HashMap<String, DataSourcesDlg>();
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
@ -58,16 +64,34 @@ public class DataSourcesAction extends AbstractHandler {
|
|||
HydroDisplayManager manager = HydroDisplayManager.getInstance();
|
||||
if (manager.isCurrentLidSelected(shell)) {
|
||||
String lid = manager.getCurrentLid();
|
||||
String name = manager.getCurrentData().getName();
|
||||
DataSourcesDlg dataSourcesDlg = dataSourcesDlgMap.get(lid);
|
||||
|
||||
String displayString = " - "
|
||||
+ lid
|
||||
+ ((name != null && name.compareTo("") != 0) ? " - " + name
|
||||
: "");
|
||||
if (dataSourcesDlg == null || dataSourcesDlg.isDisposed()) {
|
||||
String name = manager.getCurrentData().getName();
|
||||
|
||||
DataSourcesDlg dataSourcesDlg = new DataSourcesDlg(shell,
|
||||
displayString, lid, false);
|
||||
dataSourcesDlg.open();
|
||||
StringBuilder displayString = new StringBuilder(" - ");
|
||||
displayString.append(lid);
|
||||
if (name != null && name.length() > 0) {
|
||||
displayString.append(" - ").append(name);
|
||||
}
|
||||
|
||||
dataSourcesDlg = new DataSourcesDlg(shell,
|
||||
displayString.toString(), lid, false);
|
||||
dataSourcesDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof String) {
|
||||
String lid = returnValue.toString();
|
||||
dataSourcesDlgMap.remove(lid);
|
||||
}
|
||||
}
|
||||
});
|
||||
dataSourcesDlg.open();
|
||||
dataSourcesDlgMap.put(lid, dataSourcesDlg);
|
||||
} else {
|
||||
dataSourcesDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
|
||||
package com.raytheon.viz.hydro.impactstatement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
@ -28,6 +31,7 @@ import org.eclipse.ui.PlatformUI;
|
|||
|
||||
import com.raytheon.viz.hydrocommon.HydroDisplayManager;
|
||||
import com.raytheon.viz.hydrocommon.impactstatement.ImpactStatementDlg;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
* Action for Impact Statement Dialog.
|
||||
|
@ -40,6 +44,7 @@ import com.raytheon.viz.hydrocommon.impactstatement.ImpactStatementDlg;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 6/27/08 lvenable Initial creation.
|
||||
* 10/20/2008 1617 grichard Support impact statement.
|
||||
* 07/15/2013 2088 rferrel Changes for non-blocking ImpactStatementDlg.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,6 +52,18 @@ import com.raytheon.viz.hydrocommon.impactstatement.ImpactStatementDlg;
|
|||
*
|
||||
*/
|
||||
public class ImpactStatementAction extends AbstractHandler {
|
||||
/**
|
||||
* Allow one instance per station.
|
||||
*/
|
||||
Map<String, ImpactStatementDlg> impactStatmentDlgMap = new HashMap<String, ImpactStatementDlg>();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
|
||||
* .ExecutionEvent)
|
||||
*/
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
|
@ -55,16 +72,36 @@ public class ImpactStatementAction extends AbstractHandler {
|
|||
HydroDisplayManager manager = HydroDisplayManager.getInstance();
|
||||
if (manager.isCurrentLidSelected(shell)) {
|
||||
String lid = manager.getCurrentLid();
|
||||
String name = manager.getCurrentData().getName();
|
||||
ImpactStatementDlg impactStatmentDlg = impactStatmentDlgMap
|
||||
.get(lid);
|
||||
|
||||
String displayString = " - "
|
||||
+ lid
|
||||
+ ((name != null && name.compareTo("") != 0) ? " - " + name
|
||||
: "");
|
||||
if (impactStatmentDlg == null || impactStatmentDlg.isDisposed()) {
|
||||
String name = manager.getCurrentData().getName();
|
||||
|
||||
ImpactStatementDlg impactStatmentDlg = new ImpactStatementDlg(
|
||||
shell, displayString, lid, false);
|
||||
impactStatmentDlg.open();
|
||||
StringBuilder displayString = new StringBuilder(" - ");
|
||||
displayString.append(lid);
|
||||
|
||||
if (name != null && name.length() > 0) {
|
||||
displayString.append(" - ").append(name);
|
||||
}
|
||||
|
||||
impactStatmentDlg = new ImpactStatementDlg(shell,
|
||||
displayString.toString(), lid, false);
|
||||
impactStatmentDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof String) {
|
||||
String lid = returnValue.toString();
|
||||
impactStatmentDlgMap.remove(lid);
|
||||
}
|
||||
}
|
||||
});
|
||||
impactStatmentDlg.open();
|
||||
impactStatmentDlgMap.put(lid, impactStatmentDlg);
|
||||
} else {
|
||||
impactStatmentDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
*/
|
||||
package com.raytheon.viz.hydro.lowwaterstatement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
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.lowwaterstatment.LowWaterStatementDlg;
|
||||
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||
|
||||
/**
|
||||
* Action for unimplemented features. To be used temporarily until final
|
||||
|
@ -42,6 +46,7 @@ import com.raytheon.viz.hydrocommon.lowwaterstatment.LowWaterStatementDlg;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 6/27/06 lvenable Initial Creation.
|
||||
* 07/15/2013 2088 rferrel Changes for non-blocking LowWaterStatementDlg.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -49,6 +54,8 @@ import com.raytheon.viz.hydrocommon.lowwaterstatment.LowWaterStatementDlg;
|
|||
*
|
||||
*/
|
||||
public class LowWaterStatementAction extends AbstractHandler {
|
||||
private Map<String, LowWaterStatementDlg> lowWaterStmntDlgMap = new HashMap<String, LowWaterStatementDlg>();
|
||||
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
|
@ -56,16 +63,35 @@ public class LowWaterStatementAction extends AbstractHandler {
|
|||
HydroDisplayManager manager = HydroDisplayManager.getInstance();
|
||||
if (manager.isCurrentLidSelected(shell)) {
|
||||
String lid = manager.getCurrentLid();
|
||||
String name = manager.getCurrentData().getName();
|
||||
LowWaterStatementDlg lowWaterStmntDlg = lowWaterStmntDlgMap
|
||||
.get(lid);
|
||||
|
||||
String displayString = " - "
|
||||
+ lid
|
||||
+ ((name != null && name.compareTo("") != 0) ? " - " + name
|
||||
: "");
|
||||
if (lowWaterStmntDlg == null || lowWaterStmntDlg.isDisposed()) {
|
||||
String name = manager.getCurrentData().getName();
|
||||
StringBuilder displayString = new StringBuilder(" - ");
|
||||
displayString.append(lid);
|
||||
|
||||
LowWaterStatementDlg lowWaterDlg = new LowWaterStatementDlg(shell,
|
||||
displayString, false, lid);
|
||||
lowWaterDlg.open();
|
||||
if (name != null && name.length() > 0) {
|
||||
displayString.append(" - ").append(name);
|
||||
}
|
||||
|
||||
lowWaterStmntDlg = new LowWaterStatementDlg(shell,
|
||||
displayString.toString(), false, lid);
|
||||
lowWaterStmntDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof String) {
|
||||
String lid = returnValue.toString();
|
||||
lowWaterStmntDlgMap.remove(lid);
|
||||
}
|
||||
}
|
||||
});
|
||||
lowWaterStmntDlg.open();
|
||||
lowWaterStmntDlgMap.put(lid, lowWaterStmntDlg);
|
||||
} else {
|
||||
lowWaterStmntDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -162,6 +162,9 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|||
* Make dialog non-blocking.
|
||||
* Changes for non-blocking ContactsDlg.
|
||||
* Changes for non-blocking CrestHistoryDlg.
|
||||
* Changes for non-blocking DataSourcesDlg.
|
||||
* Changes for non-blocking ImpactStatementDlg.
|
||||
* Changes for non-blocking LowWaterStatementDlg.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -330,10 +333,25 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
|||
private final Map<String, ContactsDlg> contactsDlgMap = new HashMap<String, ContactsDlg>();
|
||||
|
||||
/**
|
||||
* Allow on instance per station.
|
||||
* Allow one instance per station.
|
||||
*/
|
||||
private final Map<String, CrestHistoryDlg> crestHistDlgMap = new HashMap<String, CrestHistoryDlg>();
|
||||
|
||||
/**
|
||||
* Allow one instance per station.
|
||||
*/
|
||||
private final Map<String, DataSourcesDlg> dataSourcesDlgMap = new HashMap<String, DataSourcesDlg>();
|
||||
|
||||
/**
|
||||
* Allow one instance per station.
|
||||
*/
|
||||
private final Map<String, ImpactStatementDlg> impactStatementDlgMap = new HashMap<String, ImpactStatementDlg>();
|
||||
|
||||
/**
|
||||
* Allow one instance per station.
|
||||
*/
|
||||
private final Map<String, LowWaterStatementDlg> lowWaterStmntDlgMap = new HashMap<String, LowWaterStatementDlg>();
|
||||
|
||||
/**
|
||||
* Flood category menu item.
|
||||
*/
|
||||
|
@ -741,14 +759,37 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
|||
dataSourcesMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
DataSourcesDlg dataSourcesDlg = new DataSourcesDlg(shell,
|
||||
getStationAndName(),
|
||||
getSelectedLocation().getStation(), true);
|
||||
dataSourcesDlg.open();
|
||||
handleDataSouceDlg();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Display data source dialog for selected station.
|
||||
*/
|
||||
private void handleDataSouceDlg() {
|
||||
String lid = getSelectedLocation().getStation();
|
||||
DataSourcesDlg dataSourcesDlg = dataSourcesDlgMap.get(lid);
|
||||
if (dataSourcesDlg == null || dataSourcesDlg.isDisposed()) {
|
||||
dataSourcesDlg = new DataSourcesDlg(shell, getStationAndName(),
|
||||
lid, true);
|
||||
dataSourcesDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof String) {
|
||||
String lid = returnValue.toString();
|
||||
dataSourcesDlgMap.remove(lid);
|
||||
}
|
||||
}
|
||||
});
|
||||
dataSourcesDlg.open();
|
||||
dataSourcesDlgMap.put(lid, dataSourcesDlg);
|
||||
} else {
|
||||
dataSourcesDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the River Gage menu.
|
||||
*
|
||||
|
@ -837,14 +878,11 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
|||
// Impact Statement menu item
|
||||
impactStatementMI = new MenuItem(riverGageMenu, SWT.NONE);
|
||||
impactStatementMI.setText("&Impact Statement...\tCtrl+I");
|
||||
impactStatementMI.setAccelerator(SWT.CTRL + 'T');
|
||||
impactStatementMI.setAccelerator(SWT.CTRL + 'I');
|
||||
impactStatementMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
ImpactStatementDlg impactStatementDlg = new ImpactStatementDlg(
|
||||
shell, getStationAndName(), getSelectedLocation()
|
||||
.getStation(), true);
|
||||
impactStatementDlg.open();
|
||||
handleImpactStatementDlg();
|
||||
}
|
||||
});
|
||||
riverGageMenuItems.add(impactStatementMI);
|
||||
|
@ -856,10 +894,7 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
|||
lowWaterStatementMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
LowWaterStatementDlg lowWaterStmntDlg = new LowWaterStatementDlg(
|
||||
shell, getStationAndName(), true, getSelectedLocation()
|
||||
.getStation());
|
||||
lowWaterStmntDlg.open();
|
||||
handleLowWaterStatementDlg();
|
||||
}
|
||||
});
|
||||
riverGageMenuItems.add(lowWaterStatementMI);
|
||||
|
@ -1129,6 +1164,34 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
|||
riverGageMenuItems.add(referencesMI);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bring of Impact Statement Dialog for the selected station.
|
||||
*/
|
||||
private void handleImpactStatementDlg() {
|
||||
String lid = getSelectedLocation().getStation();
|
||||
ImpactStatementDlg impactStatementDlg = impactStatementDlgMap.get(lid);
|
||||
|
||||
if (impactStatementDlg == null || impactStatementDlg.isDisposed()) {
|
||||
impactStatementDlg = new ImpactStatementDlg(shell,
|
||||
getStationAndName(), getSelectedLocation().getStation(),
|
||||
true);
|
||||
impactStatementDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof String) {
|
||||
String lid = returnValue.toString();
|
||||
impactStatementDlgMap.remove(lid);
|
||||
}
|
||||
}
|
||||
});
|
||||
impactStatementDlg.open();
|
||||
impactStatementDlgMap.put(lid, impactStatementDlg);
|
||||
} else {
|
||||
impactStatementDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Crest History dialog for the station.
|
||||
*/
|
||||
|
@ -1969,6 +2032,33 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the Low Water Statement dialog for the selected station.
|
||||
*/
|
||||
private void handleLowWaterStatementDlg() {
|
||||
String lid = getSelectedLocation().getStation();
|
||||
LowWaterStatementDlg lowWaterStmntDlg = lowWaterStmntDlgMap.get(lid);
|
||||
|
||||
if (lowWaterStmntDlg == null || lowWaterStmntDlg.isDisposed()) {
|
||||
lowWaterStmntDlg = new LowWaterStatementDlg(shell,
|
||||
getStationAndName(), true, lid);
|
||||
lowWaterStmntDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof String) {
|
||||
String lid = returnValue.toString();
|
||||
lowWaterStmntDlgMap.remove(lid);
|
||||
}
|
||||
}
|
||||
});
|
||||
lowWaterStmntDlg.open();
|
||||
lowWaterStmntDlgMap.put(lid, lowWaterStmntDlg);
|
||||
} else {
|
||||
lowWaterStmntDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upon site selection test to see if a the site is a river site. If so then
|
||||
* enable the river menu items.
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import java.lang.reflect.Method;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
|
@ -48,6 +47,10 @@ import org.eclipse.swt.widgets.Text;
|
|||
|
||||
import com.raytheon.uf.common.dataquery.db.QueryResult;
|
||||
import com.raytheon.uf.common.dataquery.db.QueryResultRow;
|
||||
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.common.time.SimulatedTime;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.hydrocommon.data.DcpData;
|
||||
import com.raytheon.viz.hydrocommon.data.HydroDBData;
|
||||
|
@ -69,6 +72,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* 10/6/2008 1555 grichard Support data sources.
|
||||
* 12/16/2008 1782 grichard Refreshed Data Sources.
|
||||
* 1/11/2008 1802 askripsk Comlete HydroBase implementation.
|
||||
* 07/15/2013 2088 rferrel Make dialog non-blocking
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -76,6 +80,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class DataSourcesDlg extends CaveSWTDialog {
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(DataSourcesDlg.class);
|
||||
|
||||
/**
|
||||
* Control font.
|
||||
|
@ -366,15 +372,21 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
*/
|
||||
public DataSourcesDlg(Shell parent, String titleInfo, String lid,
|
||||
boolean fullControls) {
|
||||
super(parent);
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||
setText("Data Sources" + titleInfo);
|
||||
|
||||
this.lid = lid;
|
||||
this.fullControls = fullControls;
|
||||
|
||||
isoDate.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
setReturnValue(lid);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||
*/
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
GridLayout mainLayout = new GridLayout(1, false);
|
||||
|
@ -383,11 +395,23 @@ public class DataSourcesDlg 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) {
|
||||
controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
|
||||
|
@ -1014,7 +1038,7 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
closeBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1060,7 +1084,8 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
loadList("type", "telmtype", telemetryList);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Unable to load static data: ", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1125,6 +1150,9 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
updateDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load DCP data from the manager.
|
||||
*/
|
||||
private void getDCPData() {
|
||||
DcpData seedData = new DcpData();
|
||||
seedData.setLid(lid);
|
||||
|
@ -1140,12 +1168,16 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
dcpData = null;
|
||||
}
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler
|
||||
.handle(Priority.ERROR, "Unable to load DCP data: ", e);
|
||||
}
|
||||
|
||||
updateDCPDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load observation data from the manager.
|
||||
*/
|
||||
private void getObsData() {
|
||||
ObserverData seedData = new ObserverData();
|
||||
seedData.setLid(lid);
|
||||
|
@ -1161,12 +1193,16 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
obsData = null;
|
||||
}
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Unable to load Observation data: ", e);
|
||||
}
|
||||
|
||||
updateObsDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Telemetry data from the manager.
|
||||
*/
|
||||
private void getTelemData() {
|
||||
TelemData seedData = new TelemData();
|
||||
seedData.setLid(lid);
|
||||
|
@ -1182,7 +1218,8 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
telemData = null;
|
||||
}
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Unable to load Telemetry data: ", e);
|
||||
}
|
||||
|
||||
updateTelemDisplay();
|
||||
|
@ -1210,6 +1247,9 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This handles updating the DCP display.
|
||||
*/
|
||||
private void updateDCPDisplay() {
|
||||
clearDCPInformation();
|
||||
|
||||
|
@ -1233,6 +1273,9 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Observation display.
|
||||
*/
|
||||
private void updateObsDisplay() {
|
||||
clearObsInformation();
|
||||
|
||||
|
@ -1304,6 +1347,9 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Telemetry display.
|
||||
*/
|
||||
private void updateTelemDisplay() {
|
||||
clearTelemInformation();
|
||||
|
||||
|
@ -1328,7 +1374,10 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
|
||||
// --------------------------------------------
|
||||
// Save
|
||||
// --------------------------------------------
|
||||
// --------------------------------------------\
|
||||
/**
|
||||
* Save DCP, Obs and Telemetry records.
|
||||
*/
|
||||
private void saveRecord() {
|
||||
if (typeCbo.getSelectionIndex() == 0) {
|
||||
saveDCPRecord();
|
||||
|
@ -1339,6 +1388,9 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the DCP Record.
|
||||
*/
|
||||
private void saveDCPRecord() {
|
||||
DcpData newData = new DcpData();
|
||||
|
||||
|
@ -1364,11 +1416,12 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
mb.setText("Unable to Save");
|
||||
mb.setMessage("An error occurred while trying to save");
|
||||
mb.open();
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the observation record.
|
||||
*/
|
||||
private void saveObsRecord() {
|
||||
ObserverData newData = new ObserverData();
|
||||
|
||||
|
@ -1391,8 +1444,6 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
mb.setMessage("Please enter a Service Date in the form: YYYY-MM-DD");
|
||||
mb.open();
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -1441,11 +1492,12 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
mb.setText("Unable to Save");
|
||||
mb.setMessage("An error occurred while trying to save");
|
||||
mb.open();
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the Telemetry record.
|
||||
*/
|
||||
private void saveTelemRecord() {
|
||||
TelemData newData = new TelemData();
|
||||
|
||||
|
@ -1481,14 +1533,15 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
mb.setText("Unable to Save");
|
||||
mb.setMessage("An error occurred while trying to save");
|
||||
mb.open();
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------
|
||||
// Delete
|
||||
// --------------------------------------------
|
||||
/**
|
||||
* Delete the DCP, OBS and Telemetry records.
|
||||
*/
|
||||
private void deleteRecord() {
|
||||
if (typeCbo.getSelectionIndex() == 0) {
|
||||
deleteDataSourceRecord(dcpData);
|
||||
|
@ -1508,6 +1561,11 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm and delete the record.
|
||||
*
|
||||
* @param currData
|
||||
*/
|
||||
private <T extends HydroDBData> void deleteDataSourceRecord(T currData) {
|
||||
if (currData != null) {
|
||||
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK
|
||||
|
@ -1528,8 +1586,6 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
mb.setText("Unable to Delete");
|
||||
mb.setMessage("An error occurred while trying to delete");
|
||||
mb.open();
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1538,6 +1594,11 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
// --------------------------------------------
|
||||
// Update display
|
||||
// --------------------------------------------
|
||||
/**
|
||||
* Update the enable state of the delete button.
|
||||
*
|
||||
* @param currState
|
||||
*/
|
||||
private void updateDialogState(DialogStates currState) {
|
||||
if (fullControls == true) {
|
||||
switch (currState) {
|
||||
|
@ -1558,7 +1619,6 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
/**
|
||||
* Clears the dialog of information
|
||||
*/
|
||||
|
||||
private void clearDCPInformation() {
|
||||
goesIdTF.setText("");
|
||||
reportingTimeTF.setText("");
|
||||
|
@ -1573,6 +1633,9 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
randomReportChk.setSelection(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the fields of the OBS record.
|
||||
*/
|
||||
private void clearObsInformation() {
|
||||
// Name
|
||||
firstNameTF.setText("");
|
||||
|
@ -1624,6 +1687,9 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
recipList.select(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the Telemetry fields.
|
||||
*/
|
||||
private void clearTelemInformation() {
|
||||
telemetryList.select(0);
|
||||
telemOwnerList.select(0);
|
||||
|
@ -1686,6 +1752,12 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the dataList selection or empty string when non selection.
|
||||
*
|
||||
* @param dataList
|
||||
* @return
|
||||
*/
|
||||
private String getSelectedValue(Combo dataList) {
|
||||
String rval = "";
|
||||
|
||||
|
@ -1696,12 +1768,16 @@ public class DataSourcesDlg extends CaveSWTDialog {
|
|||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if DOS time should be updated to current simulated time or the
|
||||
* date in the database.
|
||||
*/
|
||||
private void updateDosDate() {
|
||||
// If the Checkbox is checked, set the Date to the
|
||||
// current date
|
||||
// current simulated time.
|
||||
// Else load the date from the database
|
||||
Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime();
|
||||
if (dosChk.getSelection()) {
|
||||
Date now = SimulatedTime.getSystemTime().getTime();
|
||||
dosTF.setText(isoDate.format(now));
|
||||
} else if (obsData != null) {
|
||||
dosTF.setText((obsData.getDateOfService() != null) ? isoDate
|
||||
|
|
|
@ -28,6 +28,10 @@ import java.util.Calendar;
|
|||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
|
@ -59,6 +63,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.FloodStatementData;
|
||||
import com.raytheon.viz.hydrocommon.data.LocationData;
|
||||
|
@ -76,6 +83,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* Sep 5, 2008 lvenable Initial creation.
|
||||
* 10/20/2008 1617 grichard Support impact statement.
|
||||
* Jan 5, 2008 1802 askripsk Complete HydroBase version.
|
||||
* Jul 15, 2013 2088 rferrrel Make dialog non-blocking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -83,6 +91,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class ImpactStatementDlg extends CaveSWTDialog {
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ImpactStatementDlg.class);
|
||||
|
||||
/** The rising element of the impact statement */
|
||||
public static final String RISING = "RISING";
|
||||
|
@ -205,24 +215,64 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
*/
|
||||
private Printer printer;
|
||||
|
||||
/**
|
||||
* Line Height for printer.
|
||||
*/
|
||||
private int lineHeight = 0;
|
||||
|
||||
/**
|
||||
* Tab width for printer.
|
||||
*/
|
||||
private int tabWidth = 0;
|
||||
|
||||
/**
|
||||
* Left Margin for printer.
|
||||
*/
|
||||
private int leftMargin;
|
||||
|
||||
/**
|
||||
* Right margin for printer.
|
||||
*/
|
||||
private int rightMargin;
|
||||
|
||||
/**
|
||||
* Top margin for printer.
|
||||
*/
|
||||
private int topMargin;
|
||||
|
||||
/**
|
||||
* Bottom margin for printer.
|
||||
*/
|
||||
private int bottomMargin;
|
||||
|
||||
private int x, y;
|
||||
/**
|
||||
* Current horizontal location for printer.
|
||||
*/
|
||||
private int x;
|
||||
|
||||
private int index, end;
|
||||
/**
|
||||
* Current vertical location for printer.
|
||||
*/
|
||||
private int y;
|
||||
|
||||
private StringBuffer wordBuffer;
|
||||
/**
|
||||
* Current location in the text to print.
|
||||
*/
|
||||
private int index;
|
||||
|
||||
/**
|
||||
* end of the text to print.
|
||||
*/
|
||||
private int end;
|
||||
|
||||
/**
|
||||
* User to print one line of text.
|
||||
*/
|
||||
private final StringBuilder wordBuffer = new StringBuilder();
|
||||
|
||||
/**
|
||||
* Use to draw the text for printer.
|
||||
*/
|
||||
private GC gc;
|
||||
|
||||
/**
|
||||
|
@ -251,13 +301,19 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
*/
|
||||
public ImpactStatementDlg(Shell parent, String titleInfo, String lid,
|
||||
boolean fullControl) {
|
||||
super(parent);
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||
setText("Impact Statement" + titleInfo);
|
||||
|
||||
this.fullControl = fullControl;
|
||||
this.lid = lid;
|
||||
setReturnValue(lid);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||
*/
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
// Create the main layout for the shell.
|
||||
|
@ -269,14 +325,25 @@ public class ImpactStatementDlg 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);
|
||||
controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
|
||||
|
||||
// Initialize all of the controls and layouts
|
||||
|
@ -505,7 +572,7 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if (saveRecord()) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -530,7 +597,7 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
cancelBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -655,6 +722,9 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain Data and populate the dialog.
|
||||
*/
|
||||
private void getDialogData() {
|
||||
FloodStatementData seedData = new FloodStatementData();
|
||||
seedData.setLid(lid);
|
||||
|
@ -662,12 +732,16 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
try {
|
||||
statementData = HydroDBDataManager.getInstance().getData(seedData);
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Unable to load dialog data: ", e);
|
||||
}
|
||||
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update display with current statement data.
|
||||
*/
|
||||
private void updateDisplay() {
|
||||
dataList.removeAll();
|
||||
|
||||
|
@ -684,6 +758,12 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format display string for flood statement data.
|
||||
*
|
||||
* @param currStatement
|
||||
* @return formatedString
|
||||
*/
|
||||
private String getStatementDisplayString(FloodStatementData currStatement) {
|
||||
String fmtStr = "%8S %13S %25S %11S %29S";
|
||||
|
||||
|
@ -693,6 +773,9 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
(currStatement.getRiseFall().equals("R")) ? RISING : FALLING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the informtion fields in the GUI.
|
||||
*/
|
||||
private void clearInformation() {
|
||||
// Set Start to 01/01 and End to 12/31
|
||||
beginMonthCbo.select(0);
|
||||
|
@ -707,12 +790,18 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
fallingRdo.setSelection(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare fo new record.
|
||||
*/
|
||||
private void newRecord() {
|
||||
// Clear Form
|
||||
clearInformation();
|
||||
updateDialogState(DialogStates.NEW_RECORD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the selected data list record.
|
||||
*/
|
||||
private void deleteRecord() {
|
||||
int selectedIndex = dataList.getSelectionIndex();
|
||||
|
||||
|
@ -737,8 +826,6 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
mb.setText("Unable to Delete");
|
||||
mb.setMessage("An error occurred while trying to delete the record.");
|
||||
mb.open();
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -749,6 +836,11 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save record
|
||||
*
|
||||
* @return true when record save is successful
|
||||
*/
|
||||
private boolean saveRecord() {
|
||||
boolean successful = false;
|
||||
|
||||
|
@ -814,14 +906,17 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
mb.setText("Unable to Save");
|
||||
mb.setMessage("An error occurred while trying to save.");
|
||||
mb.open();
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return successful;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the enable state of buttons base on current state.
|
||||
*
|
||||
* @param currState
|
||||
*/
|
||||
private void updateDialogState(DialogStates currState) {
|
||||
switch (currState) {
|
||||
case NEW_RECORD:
|
||||
|
@ -853,6 +948,9 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sent the impact statement record to the printer.
|
||||
*/
|
||||
private void printRecords() {
|
||||
final String text = createSaveFileText();
|
||||
|
||||
|
@ -870,17 +968,22 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
* Do the printing in a background thread so that spooling does not
|
||||
* freeze the UI.
|
||||
*/
|
||||
Thread printingThread = new Thread("PrintTable") {
|
||||
Job job = new Job("PrintTable") {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
print(printer, text);
|
||||
printer.dispose();
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
printingThread.start();
|
||||
job.schedule();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Impact Statement data to a file.
|
||||
*/
|
||||
private void saveToFile() {
|
||||
String text;
|
||||
try {
|
||||
|
@ -895,8 +998,8 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
out.write(text);
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
// TODO Log error here
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Unable to save text to file: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -905,7 +1008,7 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
* @throws VizException
|
||||
*/
|
||||
private String createSaveFileText() {
|
||||
StringBuffer outputStr = new StringBuffer();
|
||||
StringBuilder outputStr = new StringBuilder();
|
||||
|
||||
outputStr.append("FLOOD IMPACT STATEMENT LISTING FOR\n");
|
||||
|
||||
|
@ -920,7 +1023,8 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
try {
|
||||
locData = HydroDBDataManager.getInstance().getData(seedData);
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler
|
||||
.handle(Priority.ERROR, "Unable to get text data: ", e);
|
||||
}
|
||||
|
||||
if ((locData != null) && (locData.size() > 0)) {
|
||||
|
@ -991,7 +1095,7 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
* @return
|
||||
*/
|
||||
private String wrapStatement(String statement) {
|
||||
StringBuffer formattedStatement = new StringBuffer();
|
||||
StringBuilder formattedStatement = new StringBuilder();
|
||||
|
||||
String[] words = statement.split(" ");
|
||||
int lineWidth = 0;
|
||||
|
@ -1005,7 +1109,7 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
}
|
||||
|
||||
// Append current word
|
||||
formattedStatement.append(currWord + " ");
|
||||
formattedStatement.append(currWord).append(" ");
|
||||
|
||||
// Set the Current line width
|
||||
lineWidth += currWord.length() + 1;
|
||||
|
@ -1027,29 +1131,18 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
Rectangle clientArea = printer.getClientArea();
|
||||
Rectangle trim = printer.computeTrim(0, 0, 0, 0);
|
||||
Point dpi = printer.getDPI();
|
||||
leftMargin = dpi.x + trim.x; // one inch from left side of paper
|
||||
rightMargin = clientArea.width - dpi.x + trim.x + trim.width; // one
|
||||
// inch
|
||||
// from
|
||||
// right
|
||||
// side
|
||||
// of
|
||||
// paper
|
||||
topMargin = dpi.y + trim.y; // one inch from top edge of paper
|
||||
bottomMargin = clientArea.height - dpi.y + trim.y + trim.height; // one
|
||||
// inch
|
||||
// from
|
||||
// bottom
|
||||
// edge
|
||||
// of
|
||||
// paper
|
||||
// one inch from left side of paper
|
||||
leftMargin = dpi.x + trim.x;
|
||||
// one inch from right side of paper
|
||||
rightMargin = clientArea.width - dpi.x + trim.x + trim.width;
|
||||
// one inch from top edge of paper
|
||||
topMargin = dpi.y + trim.y;
|
||||
// one inch from bottom edge of paper
|
||||
bottomMargin = clientArea.height - dpi.y + trim.y + trim.height;
|
||||
|
||||
/* Create a buffer for computing tab width. */
|
||||
int tabSize = 4; // is tab width a user setting in your UI?
|
||||
StringBuffer tabBuffer = new StringBuffer(tabSize);
|
||||
for (int i = 0; i < tabSize; i++)
|
||||
tabBuffer.append(' ');
|
||||
String tabs = tabBuffer.toString();
|
||||
// Create a buffer for computing tab width.
|
||||
// Tab size four spaces.
|
||||
String tabs = " ";
|
||||
|
||||
/*
|
||||
* Create printer GC, and create and set the printer font &
|
||||
|
@ -1090,7 +1183,7 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
*/
|
||||
private void printText(String text) {
|
||||
printer.startPage();
|
||||
wordBuffer = new StringBuffer();
|
||||
wordBuffer.setLength(0);
|
||||
x = leftMargin;
|
||||
y = topMargin;
|
||||
index = 0;
|
||||
|
@ -1137,7 +1230,7 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
}
|
||||
gc.drawString(word, x, y, false);
|
||||
x += wordWidth;
|
||||
wordBuffer = new StringBuffer();
|
||||
wordBuffer.setLength(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1178,7 +1271,8 @@ public class ImpactStatementDlg extends CaveSWTDialog {
|
|||
mb.open();
|
||||
}
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Unable to check if FK constraints met: ", e);
|
||||
}
|
||||
|
||||
return rval;
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.viz.hydrocommon.lowwaterstatment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
|
@ -40,6 +38,9 @@ import org.eclipse.swt.widgets.MessageBox;
|
|||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
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.HydroConstants;
|
||||
import com.raytheon.viz.hydrocommon.data.LowWaterStatementData;
|
||||
|
@ -54,6 +55,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 5, 2008 lvenable Initial creation
|
||||
* Jul 15, 2012 2088 rferrel Make dialog non-blocking
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -61,6 +63,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class LowWaterStatementDlg extends CaveSWTDialog {
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(LowWaterStatementDlg.class);
|
||||
|
||||
/**
|
||||
* Control font.
|
||||
|
@ -135,7 +139,7 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
/**
|
||||
* Low water statement Data for the current location
|
||||
*/
|
||||
private ArrayList<LowWaterStatementData> lwStatements;
|
||||
private java.util.List<LowWaterStatementData> lwStatements;
|
||||
|
||||
/**
|
||||
* Flag indicating if all the controls should be displayed.
|
||||
|
@ -144,15 +148,26 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
|
||||
private enum DialogStates {
|
||||
HYDRO_VIEW, NEW, STATEMENTS_AVAILABLE, STATEMENTS_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* text from the remark text box
|
||||
*/
|
||||
private String currentCriteriaText=null;
|
||||
private String currentSourceText=null;
|
||||
private String currentStatementText=null;
|
||||
|
||||
private String currentCriteriaText = null;
|
||||
|
||||
/**
|
||||
* Text for current source
|
||||
*/
|
||||
private String currentSourceText = null;
|
||||
|
||||
/**
|
||||
* Text for current statement.
|
||||
*/
|
||||
private String currentStatementText = null;
|
||||
|
||||
/**
|
||||
* Current button state used to enable buttons.
|
||||
*/
|
||||
private DialogStates buttonState;
|
||||
|
||||
/**
|
||||
|
@ -167,22 +182,33 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
*/
|
||||
public LowWaterStatementDlg(Shell parent, String titleInfo,
|
||||
boolean fullControls, String lid) {
|
||||
super(parent);
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||
setText("Low Water Statement " + titleInfo);
|
||||
|
||||
this.lid = lid;
|
||||
this.fullControls = fullControls;
|
||||
setReturnValue(lid);
|
||||
}
|
||||
|
||||
/*
|
||||
* (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);
|
||||
|
||||
controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
|
||||
|
||||
// Initialize all of the controls and layouts
|
||||
|
@ -287,16 +313,15 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
gd.horizontalSpan = 7;
|
||||
criteriaTF = new Text(infoGroup, SWT.BORDER | SWT.MULTI);
|
||||
criteriaTF.setLayoutData(gd);
|
||||
currentCriteriaText=criteriaTF.getText();
|
||||
currentCriteriaText = criteriaTF.getText();
|
||||
ModifyListener listenerC = new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
if (criteriaTF.getText().length()>255){
|
||||
criteriaTF.setText(currentCriteriaText);
|
||||
shell.getDisplay().beep();
|
||||
}
|
||||
else
|
||||
currentCriteriaText=criteriaTF.getText();
|
||||
}
|
||||
public void modifyText(ModifyEvent e) {
|
||||
if (criteriaTF.getText().length() > 255) {
|
||||
criteriaTF.setText(currentCriteriaText);
|
||||
shell.getDisplay().beep();
|
||||
} else
|
||||
currentCriteriaText = criteriaTF.getText();
|
||||
}
|
||||
};
|
||||
|
||||
criteriaTF.addModifyListener(listenerC);
|
||||
|
@ -311,16 +336,15 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
gd.horizontalSpan = 7;
|
||||
sourceTF = new Text(infoGroup, SWT.BORDER | SWT.MULTI);
|
||||
sourceTF.setLayoutData(gd);
|
||||
currentSourceText=sourceTF.getText();
|
||||
currentSourceText = sourceTF.getText();
|
||||
ModifyListener listenerS = new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
if (sourceTF.getText().length()>255){
|
||||
sourceTF.setText(currentSourceText);
|
||||
shell.getDisplay().beep();
|
||||
}
|
||||
else
|
||||
currentSourceText=sourceTF.getText();
|
||||
}
|
||||
public void modifyText(ModifyEvent e) {
|
||||
if (sourceTF.getText().length() > 255) {
|
||||
sourceTF.setText(currentSourceText);
|
||||
shell.getDisplay().beep();
|
||||
} else
|
||||
currentSourceText = sourceTF.getText();
|
||||
}
|
||||
};
|
||||
|
||||
sourceTF.addModifyListener(listenerS);
|
||||
|
@ -335,16 +359,15 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
gd.horizontalSpan = 7;
|
||||
statementTF = new Text(infoGroup, SWT.BORDER | SWT.MULTI);
|
||||
statementTF.setLayoutData(gd);
|
||||
currentStatementText=statementTF.getText();
|
||||
currentStatementText = statementTF.getText();
|
||||
ModifyListener listenerT = new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
if (statementTF.getText().length()>200){
|
||||
statementTF.setText(currentStatementText);
|
||||
shell.getDisplay().beep();
|
||||
}
|
||||
else
|
||||
currentStatementText=statementTF.getText();
|
||||
}
|
||||
public void modifyText(ModifyEvent e) {
|
||||
if (statementTF.getText().length() > 200) {
|
||||
statementTF.setText(currentStatementText);
|
||||
shell.getDisplay().beep();
|
||||
} else
|
||||
currentStatementText = statementTF.getText();
|
||||
}
|
||||
};
|
||||
|
||||
statementTF.addModifyListener(listenerT);
|
||||
|
@ -381,7 +404,7 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
okBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
saveRecord();
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -404,7 +427,7 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
closeBtn.setLayoutData(gd);
|
||||
closeBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -459,8 +482,8 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
lwStatements = LowWaterStatementDataManager.getInstance()
|
||||
.getLowWaterStatementData(lid);
|
||||
} catch (VizException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Unable to load Water Statement Data: ", e);
|
||||
}
|
||||
|
||||
// Check if any data was returned
|
||||
|
@ -473,6 +496,10 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
updateLowWaterStatementData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the data list with the entries from lwStatements and set the
|
||||
* enable state for the buttons.
|
||||
*/
|
||||
private void updateLowWaterStatementData() {
|
||||
// Clear current Stages
|
||||
dataList.removeAll();
|
||||
|
@ -491,10 +518,18 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
setButtonStates();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Information display with currently selected statement.
|
||||
*/
|
||||
private void getLowWaterStatementInformation() {
|
||||
updateInformationDisplay(getCurrentlySelectedStatement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the information Display with desired statement.
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
private void updateInformationDisplay(LowWaterStatementData data) {
|
||||
lowerLimitTF.setText(data.getLowerValueString());
|
||||
upperLimitTF.setText(data.getUpperValueString());
|
||||
|
@ -505,6 +540,11 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
statementTF.setText(data.getStatement());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently selected statement.
|
||||
*
|
||||
* @return currData
|
||||
*/
|
||||
private LowWaterStatementData getCurrentlySelectedStatement() {
|
||||
LowWaterStatementData currData = null;
|
||||
|
||||
|
@ -515,6 +555,9 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
return currData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the currently selected statement.
|
||||
*/
|
||||
private void deleteRecord() {
|
||||
LowWaterStatementData currData = getCurrentlySelectedStatement();
|
||||
|
||||
|
@ -525,8 +568,8 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
LowWaterStatementDataManager.getInstance().deleteRecord(
|
||||
currData);
|
||||
} catch (VizException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Unable to delete Water Statement Record: ", e);
|
||||
}
|
||||
|
||||
getLowWaterStatementData();
|
||||
|
@ -541,6 +584,9 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear information to prepare to entery new statement.
|
||||
*/
|
||||
private void newRecord() {
|
||||
clearInformation();
|
||||
|
||||
|
@ -548,6 +594,9 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
setButtonStates();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the statement's fields.
|
||||
*/
|
||||
private void clearInformation() {
|
||||
lowerLimitTF.setText("");
|
||||
upperLimitTF.setText("");
|
||||
|
@ -630,8 +679,8 @@ public class LowWaterStatementDlg extends CaveSWTDialog {
|
|||
LowWaterStatementDataManager.getInstance()
|
||||
.putLowWaterStatementData(dataToSave);
|
||||
} catch (VizException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"Unable to Save Water Statement Record: ", e);
|
||||
}
|
||||
|
||||
getLowWaterStatementData();
|
||||
|
|
Loading…
Add table
Reference in a new issue