Issue #1578 Changes for non-blocking CaveHydroSWTDialog, singleton TimeseriesDlg and removal of TimeSeriesconfigAction.

Change-Id: Ie249af9dcb2b84db686bca5c0936c2157d40c507

Former-commit-id: dc965dc82a [formerly eaa3834f6b [formerly 413491362e25a08b7e43f86987cc059f794a674b]]
Former-commit-id: eaa3834f6b
Former-commit-id: a558cbc03a
This commit is contained in:
Roger Ferrel 2013-02-05 11:58:48 -06:00
parent 02b0b90b16
commit 2bf24f97ee
11 changed files with 3564 additions and 3526 deletions

View file

@ -20,13 +20,14 @@
package com.raytheon.viz.hydro;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.viz.hydrocommon.HydroDisplayManager;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
* TODO Add Description
* An abstract dialog with common elements, LID, TS and PE for Hydro dialogs.
*
* <pre>
*
@ -34,6 +35,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 24, 2008 mpduff Initial creation
* Feb 05, 2013 1578 rferrel Made dialog non-blocking.
*
*
* </pre>
@ -46,42 +48,41 @@ public abstract class CaveHydroSWTDialog extends CaveSWTDialog {
/**
* Currently selected lid.
*/
protected String currentLid = null;
;
protected String currentLid = null;;
/**
* Currently selected TS.
* Currently selected type source.
*/
protected String currentTs = null;
protected String currentPe = null;
protected String currentTs = null;
/**
* Constructor.
* Currently selected physical element.
*/
protected String currentPe = null;
/**
* Non-blocking Constructor.
*
* @param parentShell
*/
protected CaveHydroSWTDialog(Shell parentShell) {
super(parentShell);
this(parentShell, CAVE.NONE);
}
/**
* Constructor.
* Construct to specify cave style and make it non-blocking.
*
* @param parentShell
* @param style
*/
protected CaveHydroSWTDialog(Shell parentShell, int style) {
super(parentShell, style);
* @param caveStyle
*/
protected CaveHydroSWTDialog(Shell parentShell, int caveStyle) {
super(parentShell, SWT.DIALOG_TRIM, caveStyle | CAVE.DO_NOT_BLOCK);
}
protected CaveHydroSWTDialog(Shell parentShell, int style, int caveStyle) {
super(parentShell, style, caveStyle);
}
/**
* Get the currently selected lid. If no lid selected display error message
* pop up.
* Determine if there is a currently selected LID.
*
* @return the current lid or null if nothing selected
* @return true if LID selected otherwise false
*/
protected boolean isCurrentLidSelected() {
HydroDisplayManager displayManager = HydroDisplayManager.getInstance();
@ -104,13 +105,23 @@ public abstract class CaveHydroSWTDialog extends CaveSWTDialog {
*/
protected String getCurrentLid() {
return currentLid;
}
}
/**
* The currently selected type source.
*
* @return TS
*/
protected String getTs() {
return currentTs;
}
}
/**
* The currently selected physical element.
*
* @return PE
*/
protected String getPe() {
return currentPe;
}
}
}

View file

@ -83,6 +83,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* first, is not existing, check for datalimits table as defaults.
* Both not existing, set as MISSING
* Dec 07, 2012 1353 rferrel Make dialog non-blocking.
* Feb 05, 2013 1578 rferrel Changes for non-blocking singleton TimeSeriesDlg.
*
* </pre>
*
@ -1045,8 +1046,10 @@ public class AlertAlarmValuesDlg extends CaveSWTDialog implements
tabularBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
TimeSeriesDlg tsd = new TimeSeriesDlg(shell, selectedLid);
tsd.open();
shell.setCursor(shell.getDisplay().getSystemCursor(
SWT.CURSOR_WAIT));
TimeSeriesDlg.getInstance().updateAndOpen(selectedLid, false);
shell.setCursor(null);
}
});
@ -1057,8 +1060,10 @@ public class AlertAlarmValuesDlg extends CaveSWTDialog implements
graphBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
TimeSeriesDlg tsd = new TimeSeriesDlg(shell, selectedLid);
tsd.open();
shell.setCursor(shell.getDisplay().getSystemCursor(
SWT.CURSOR_WAIT));
TimeSeriesDlg.getInstance().updateAndOpen(selectedLid, true);
shell.setCursor(null);
}
});

View file

@ -76,6 +76,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 29 NOV 2007 373 lvenable Initial creation
* 05 Feb 2013 1578 rferrel Changes for non-blocking singleton TimeSeriesDlg.
*
* </pre>
*
@ -84,7 +85,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
*
*/
public class TabularDisplayDlg extends CaveSWTDialog {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(TabularDisplayDlg.class);
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(TabularDisplayDlg.class);
/**
* Font used by the list control.
@ -253,8 +255,7 @@ public class TabularDisplayDlg extends CaveSWTDialog {
@Override
public void widgetSelected(SelectionEvent event) {
GageData gageData = getSelection();
TimeSeriesDlg tsd = new TimeSeriesDlg(shell, gageData, true);
tsd.open();
TimeSeriesDlg.getInstance().updateAndOpen(gageData, true);
}
});
@ -285,8 +286,7 @@ public class TabularDisplayDlg extends CaveSWTDialog {
@Override
public void widgetSelected(SelectionEvent event) {
GageData gageData = getSelection();
TimeSeriesDlg tsd = new TimeSeriesDlg(shell, gageData, false);
tsd.open();
TimeSeriesDlg.getInstance().updateAndOpen(gageData, false);
}
});
@ -748,7 +748,7 @@ public class TabularDisplayDlg extends CaveSWTDialog {
} catch (IOException e) {
e.printStackTrace();
statusHandler.handle(Priority.PROBLEM, "saveTable()"
+ " Error saving the tabluar data to file");
+ " Error saving the tabluar data to file");
}
}
}

View file

@ -58,6 +58,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 29 NOV 2007 373 lvenable Initial creation
* 09 sep 2010 5399 lbousaidi changed constructor for both
* openTabularTimeSeries and openGraphTimeSeries
* 05 Feb 2013 1578 rferrel Changes for non-blocking singleton TimeSeriesDlg.
*
* </pre>
*
@ -570,9 +571,10 @@ public class QuestionableBadDataDlg extends CaveSWTDialog {
QuestionableData currData = getCurrentlySelectedData();
if (currData != null) {
TimeSeriesDlg tsd = new TimeSeriesDlg(shell, currData.getLid(),
currData.getPe(), currData.getTs() , true);
tsd.open();
shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
TimeSeriesDlg.getInstance().updateAndOpen(currData.getLid(),
currData.getPe(), currData.getTs(), true);
shell.setCursor(null);
}
}
@ -580,9 +582,10 @@ public class QuestionableBadDataDlg extends CaveSWTDialog {
QuestionableData currData = getCurrentlySelectedData();
if (currData != null) {
TimeSeriesDlg tsd = new TimeSeriesDlg(shell, currData.getLid(),
currData.getPe(), currData.getTs() , false);
tsd.open();
shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
TimeSeriesDlg.getInstance().updateAndOpen(currData.getLid(),
currData.getPe(), currData.getTs(), false);
shell.setCursor(null);
}
}

View file

@ -125,6 +125,7 @@ import com.vividsolutions.jts.index.strtree.STRtree;
*
* May 16, 2011 9356 djingtao When timeseries is disposed, launch a new timesereis after double click
* or right click to select TimeSeries
* Feb 05, 2013 1578 rferrel Changes for non-blocking singleton TimeSeriesDlg.
*
* </pre>
*
@ -348,15 +349,15 @@ public class MultiPointResource extends
double shiftWidthValue = getShiftWidth(gage);
if (existing != null) {
PixelExtent pe = getPixelExtent(existing, getShiftWidth(existing),
getShiftHeight(existing));
PixelExtent pe = getPixelExtent(existing,
getShiftWidth(existing), getShiftHeight(existing));
Envelope oldEnv = descriptor.pixelToWorld(pe);
strTree.remove(oldEnv, existing);
}
/* Create a small envelope around the point */
PixelExtent pe = getPixelExtent(gage, getShiftWidth(gage),
getShiftHeight(gage));
getShiftHeight(gage));
Envelope newEnv = descriptor.pixelToWorld(pe);
strTree.insert(newEnv, gage);
@ -862,13 +863,13 @@ public class MultiPointResource extends
Envelope env = new Envelope(coord.asLatLon());
List<?> elements = strTree.query(env);
if (elements.size() > 0) {
StringBuffer sb = new StringBuffer();
boolean first = true;
StringBuffer sb = new StringBuffer();
boolean first = true;
Iterator<?> iter = elements.iterator();
while (iter.hasNext()) {
GageData gage = (GageData) iter.next();
if (!first) {
sb.append("\n");
sb.append("\n");
}
sb.append("GAGE: " + gage.getName() + " VALUE: "
+ gage.getGageValue());
@ -1271,15 +1272,9 @@ public class MultiPointResource extends
List<?> elements = strTree.query(env);
GageData closestGage = getNearestPoint(coord, elements);
if (closestGage != null) {
if ((ts == null) || !ts.isOpen()) {
Shell shell = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getShell();
ts = new TimeSeriesDlg(shell, closestGage, true);
ts.open();
} else {
ts.updateSelection(closestGage, true);
}
getTs();
ts.open();
ts.updateSelection(closestGage, true);
} else {
showMessage();
}
@ -1486,6 +1481,7 @@ public class MultiPointResource extends
* @return the ts
*/
public TimeSeriesDlg getTs() {
ts = TimeSeriesDlg.getInstance();
return ts;
}
@ -1549,15 +1545,9 @@ public class MultiPointResource extends
/* element 0 = Coordinate, 1 = inspectString */
GageData gage = (GageData) iter.next();
Shell shell = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getShell();
if ((ts == null) || !ts.isOpen()) {
ts = new TimeSeriesDlg(shell, gage, false);
ts.open();
} else {
ts.updateSelection(gage, false);
}
getTs();
ts.open();
ts.updateSelection(gage, false);
try {
interrogate(latLon);
} catch (VizException e) {

View file

@ -69,6 +69,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* 12/21/2008 mduff Implement single and double clicks.
* 01/10/2008 1802 askripsk Finished single and double clicks.
* 07/03/2010 5906 mduff Fixed the list to match the data.
* 02/05/2013 1578 rferrel Changes for non-blocking singleton TimeSeriesDlg.
*
* </pre>
*
@ -195,9 +196,12 @@ public class StationListDlg extends CaveSWTDialog implements MapUpdateListener,
String[] parts = selection.trim().split("\\s+");
GageData data = dataMap.get(parts[0]);
if (data != null) {
shell.setCursor(getDisplay().getSystemCursor(
SWT.CURSOR_WAIT));
HydroDisplayManager.getInstance().setCurrentData(data);
TimeSeriesDlg tsd = new TimeSeriesDlg(shell, data.getLid());
tsd.open();
TimeSeriesDlg.getInstance().updateAndOpen(data.getLid(),
false);
shell.setCursor(null);
}
}
@ -293,13 +297,13 @@ public class StationListDlg extends CaveSWTDialog implements MapUpdateListener,
String format = "%5s %s [%3.2f %3.2f]";
dataList.removeAll();
dataMap.clear();
// populate the dataMap
for (int i = 0; i < gageDataList.size(); i++) {
GageData data = gageDataList.get(i);
dataMap.put(data.getLid(), data);
}
// Populate the list widget
Iterator<GageData> iter = dataMap.values().iterator();
while (iter.hasNext()) {
@ -328,7 +332,7 @@ public class StationListDlg extends CaveSWTDialog implements MapUpdateListener,
if (dataList.getSelectionIndex() == -1) {
return;
}
String selection = dataList.getItem(dataList.getSelectionIndex());
String[] parts = selection.trim().split("\\s+");
if (dataMap != null) {
@ -382,7 +386,7 @@ public class StationListDlg extends CaveSWTDialog implements MapUpdateListener,
VizApp.runSync(new Runnable() {
@Override
public void run() {
public void run() {
dataList.removeAll();
populateStationList();
}

View file

@ -25,12 +25,6 @@ package com.raytheon.viz.hydro.timeseries;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.viz.hydro.resource.MultiPointResource;
import com.raytheon.viz.hydrocommon.HydroDisplayManager;
/**
* Action for unimplemented features. To be used temporarily until final
@ -43,6 +37,7 @@ import com.raytheon.viz.hydrocommon.HydroDisplayManager;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 6/27/06 lvenable Initial Creation.
* 02/05/2013 1578 rferrel Changes for non-blocking singleton TimeSeriesDlg.
*
* </pre>
*
@ -50,23 +45,11 @@ import com.raytheon.viz.hydrocommon.HydroDisplayManager;
*
*/
public class TimeSeriesAction extends AbstractHandler {
private TimeSeriesDlg dlg = null;
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractVizResource<?,?> rsc = HydroDisplayManager.getInstance().getDisplayedResource();
if (rsc instanceof MultiPointResource) {
dlg = ((MultiPointResource) rsc).getTs();
}
if ((dlg != null) && (dlg.isDisposed() == false)) {
dlg.setFocus();
} else {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
dlg = new TimeSeriesDlg(shell);
dlg.open();
}
return null;
}
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
TimeSeriesDlg.getInstance().open();
return null;
}
}

View file

@ -62,6 +62,7 @@ import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.PathManagerFactory;
@ -117,7 +118,8 @@ import com.raytheon.viz.hydrocommon.util.StnClassSyncUtil;
* 08 Aug 2012 657 mpduff Fix error when selecting a TS while no selection has been made
* in the Station List.
* 27 Sep 2012 15302 wkwock TimeSeries start mode should depends on token timeseries_mode
* despite start up in CAVE or standalone.
* despite start up in CAVE or standalone.
* 05 Feb 2013 1578 rferrel Dialog made non-blocking and a singleton.
* </pre>
*
* @author lvenable
@ -175,8 +177,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
private static final String COLOR = "color";
// private static final String[] TS_LIST = { "RG", "RP", "RZ", "FF", "FX",
// "FZ" };
private static TimeSeriesDlg instance;
private final String[] TS_ORDER = { "R", "F", "P", "M", "C" };
@ -444,7 +445,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
/** Holds the Group Information */
private GroupInfo groupInfo;
/** Holds the last graphed GroupInfo object */
private GroupInfo prevGroupInfo;
@ -466,10 +467,6 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
private GageData gageData = null;
private Cursor waitCursor = null;
private Cursor arrowCursor = null;
/**
* Auto open the graph or tabular display. True opens graph, false opens
* tabular display.
@ -485,112 +482,48 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
* standalone mode - outside of CAVE.
*/
private boolean standaloneMode = false;
/**
* Mode ComboBox previous selection.
*/
private int prevModeIdx;
private String startMode;
/**
* When not in stand alone mode this allows only a single instance of the
* dialog.
*
* @return instance
*/
public final static TimeSeriesDlg getInstance() {
// Independent shell must be recreated after closing.
if (instance == null || !instance.isOpen()) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
instance = new TimeSeriesDlg(shell);
}
return instance;
}
/**
* Constructor.
*
* @param parent
* Parent shell.
*/
public TimeSeriesDlg(Shell parent) {
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK | CAVE.INDEPENDENT_SHELL);
private TimeSeriesDlg(Shell parent) {
super(parent, CAVE.INDEPENDENT_SHELL);
setText("Time Series Control");
displayManager = HydroDisplayManager.getInstance();
if (displayManager.getCurrentLid() != null) {
currentLid = displayManager.getCurrentLid();
}
waitCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT);
arrowCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_ARROW);
}
/**
* Constructor.
*
* @param parent
* Parent shell.
* @param lid
* Preselected Lid to display upon opening the dialog
*/
public TimeSeriesDlg(Shell parent, String lid) {
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK | CAVE.INDEPENDENT_SHELL);
setText("Time Series");
currentLid = lid;
waitCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT);
arrowCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_ARROW);
}
/**
* Constructor.
*
* @param parent
* Parent shell.
* @param lid
* Preselected Lid to display upon opening the dialog
*/
public TimeSeriesDlg(Shell parent, String lid, String PE, String TS,
boolean displayGraph) {
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK | CAVE.INDEPENDENT_SHELL);
setText("Time Series");
currentLid = lid;
currentTs = TS;
currentPe = PE;
this.displayGraph = displayGraph;
openTimeSeriesDisplays = true;
waitCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT);
arrowCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_ARROW);
}
/**
* Constructor.
*
* @param parent
* Parent shell.
* @param lid
* Preselected Lid to display upon opening the dialog
*/
public TimeSeriesDlg(Shell parent, String lid, boolean displayGraph) {
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK | CAVE.INDEPENDENT_SHELL);
setText("Time Series");
currentLid = lid;
this.displayGraph = displayGraph;
openTimeSeriesDisplays = true;
waitCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT);
arrowCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_ARROW);
}
/**
* Constructor.
*
* @param parent
* Parent shell.
* @param lid
* Preselected Lid to display upon opening the dialog
*/
public TimeSeriesDlg(Shell parent, GageData gageData, boolean displayGraph) {
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK | CAVE.INDEPENDENT_SHELL);
setText("Time Series");
currentLid = gageData.getLid();
this.displayGraph = displayGraph;
openTimeSeriesDisplays = true;
this.gageData = gageData;
waitCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT);
arrowCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_ARROW);
}
/**
* Constructor.
* Constructor for stand alone dialog.
*
* @param parent
* the Parent shell.
@ -599,33 +532,99 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
* the user-specified file with group configuration information.
*/
public TimeSeriesDlg(Shell parent, File groupConfigFile) {
super(parent, SWT.DIALOG_TRIM, CAVE.INDEPENDENT_SHELL);
setText("Time Series");
this(parent);
this.standaloneMode = true;
// Ensure That The Group Configuration File Exists.
if (!groupConfigFile.exists()) {
// if it does not, check localization for the file
// if it does not, check localization for the file
IPathManager pm = PathManagerFactory.getPathManager();
groupConfigFile = pm.getStaticFile(HydroConstants.GROUP_DEFINITION);
if (!groupConfigFile.exists()) {
statusHandler.handle(Priority.PROBLEM,
"Unable to locate group configuration file - "
+ groupConfigFile.getAbsolutePath());
this.groupConfigFilePath = null;
if (groupConfigFile == null || !groupConfigFile.exists()) {
String name = HydroConstants.GROUP_DEFINITION;
if (name.startsWith("/")) {
name = name.substring(1);
}
statusHandler.handle(Priority.PROBLEM,
"Unable to locate group configuration file - " + name);
this.groupConfigFilePath = null;
} else {
this.groupConfigFilePath = groupConfigFile.getAbsolutePath();
statusHandler.handle(Priority.PROBLEM, "Using standard AWIPS 2 group_definition.cfg file. "
+ "Unable to locate specified group configuration file.");
this.groupConfigFilePath = groupConfigFile.getAbsolutePath();
statusHandler
.handle(Priority.PROBLEM,
"Using standard AWIPS 2 group_definition.cfg file. "
+ "Unable to locate specified group configuration file.");
}
} else {
this.groupConfigFilePath = groupConfigFile.getAbsolutePath();
}
waitCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT);
arrowCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_ARROW);
}
/**
* Used by the updateAndOpen methods to proper update the dialogs.
*/
private void updateOpen() {
if (!isOpen()) {
open();
} else {
try {
populateStationList();
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
setCurrentData();
opened();
bringToTop();
}
}
/**
* Update dialog and make sure it is open.
*
* @param lid
*/
public void updateAndOpen(String lid, boolean displayGraph) {
this.currentLid = lid;
this.displayGraph = displayGraph;
openTimeSeriesDisplays = true;
updateOpen();
}
/**
* Update dialog and make sure it is open.
*
* @param lid
*/
public void updateAndOpen(String lid, String PE, String TS,
boolean dispalyGraph) {
this.currentLid = lid;
this.currentPe = PE;
this.currentTs = TS;
this.displayGraph = dispalyGraph;
openTimeSeriesDisplays = true;
updateOpen();
}
/**
* Update dialog and make sure it is open.
*
* @param lid
*/
public void updateAndOpen(GageData gageData, boolean displayGraph) {
currentLid = gageData.getLid();
this.displayGraph = displayGraph;
openTimeSeriesDisplays = true;
this.gageData = gageData;
updateOpen();
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
*/
@Override
protected Layout constructShellLayout() {
// Create the main layout for the shell.
@ -635,28 +634,30 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
return mainLayout;
}
/**
* Allow others to give focus to the dialog.
*/
public void setFocus() {
shell.setFocus();
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
*/
@Override
protected void disposed() {
if (font.isDisposed() == false) {
font.dispose();
}
if (waitCursor.isDisposed() == false) {
waitCursor.dispose();
}
if (arrowCursor.isDisposed() == false) {
arrowCursor.dispose();
}
}
public void disposeDialogTS() {
if (!shell.isDisposed())
shell.dispose();
font.dispose();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
@Override
protected void initializeComponents(Shell shell) {
setReturnValue(false);
@ -668,6 +669,11 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
setCurrentData();
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#opened()
*/
@Override
protected void opened() {
if (openTimeSeriesDisplays) {
@ -677,7 +683,8 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
openTimeSeriesDisplays = false;
}
AbstractVizResource<?,?> rsc = HydroDisplayManager.getInstance().getDisplayedResource();
AbstractVizResource<?, ?> rsc = HydroDisplayManager.getInstance()
.getDisplayedResource();
if (rsc instanceof MultiPointResource) {
((MultiPointResource) rsc).setTs(this);
}
@ -726,7 +733,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
} catch (VizException e) {
statusHandler.error("Failed to populate station list", e);
}
if (startMode.equals("GROUP") && (displayGraph == false)) {
modeCbo.select(0);
stackLayout.topControl = groupGroup;
@ -1136,13 +1143,14 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
idRdo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
shell.setCursor(waitCursor);
setCursorBusy(true);
try {
populateStationList();
checkBottomButtons();
} catch (VizException e) {
statusHandler.error("Failed to populate station list", e);
}
shell.setCursor(arrowCursor);
setCursorBusy(false);
}
});
@ -1164,7 +1172,8 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
String line = topDataList.getItem(topDataList
.getSelectionIndex());
String selectedLid = line.substring(0, line.indexOf(" "));
populateBottomList(selectedLid, tsOrderCbo.getSelectionIndex());
populateBottomList(selectedLid,
tsOrderCbo.getSelectionIndex());
}
}
});
@ -1180,17 +1189,32 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
nameRdo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
shell.setCursor(waitCursor);
setCursorBusy(true);
try {
populateStationList();
checkBottomButtons();
} catch (VizException e) {
statusHandler.error("Failed to populate station list", e);
}
shell.setCursor(arrowCursor);
setCursorBusy(false);
}
});
}
/**
* Clear or set the shell's cursor to the current wait cursor.
*
* @param state
* - true set to busy cursor
*/
private void setCursorBusy(boolean state) {
Cursor waitCursor = null;
if (state) {
waitCursor = getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
}
shell.setCursor(waitCursor);
}
/**
* Create the top list control.
*/
@ -1212,6 +1236,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
lidList.get(topDataList.getSelectionIndex()),
tsOrderCbo.getSelectionIndex());
}
checkBottomButtons();
}
});
}
@ -1318,7 +1343,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
closeBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
shell.dispose();
close();
}
});
}
@ -1372,7 +1397,11 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
endDayBtn.setText(String.valueOf(endCal.get(Calendar.DAY_OF_MONTH)));
endHourBtn.setText(String.valueOf(endCal.get(Calendar.HOUR_OF_DAY)));
}
/**
* Update the time button values based on beginCal and endCal current
* values.
*/
private void updateTimeButtons() {
beginYearBtn.setText(String.valueOf(beginCal.get(Calendar.YEAR)));
beginMonthBtn.setText(String.valueOf(beginCal.get(Calendar.MONTH) + 1));
@ -1457,6 +1486,16 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
}
}
/**
* Update the enable status of the bottom buttons.
*/
private void checkBottomButtons() {
boolean enabled = topDataList.getSelectionIndex() >= 0;
graphButton.setEnabled(enabled);
tableButton.setEnabled(enabled);
bothButton.setEnabled(enabled);
}
/**
* Populate the details list
*/
@ -1586,7 +1625,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
File file = pm.getStaticFile(HydroConstants.GROUP_DEFINITION);
if (file != null) {
groupConfigFilePath = file.getAbsolutePath();
groupConfigFilePath = file.getAbsolutePath();
}
this.readGroupList();
}
@ -1600,7 +1639,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
groupDataList.removeAll();
if (this.groupConfigFilePath != null) {
this.readGroupList();
}
}
@ -1624,7 +1663,8 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
}
in.close();
} catch (IOException e) {
statusHandler.error("Failed to read group definition configuration.", e);
statusHandler.error(
"Failed to read group definition configuration.", e);
}
}
@ -1831,7 +1871,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
return result;
}
/**
* Action called when the both button is pressed.
*/
@ -1854,9 +1894,9 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
* @param line
*/
private void processGroupData(String line) {
Boolean showpp_flag = false;
Boolean showpp_flag = false;
// Remove any leading whitespace
// Remove any leading whitespace
line = line.replaceAll("^\\s+", "");
if (line.startsWith(GROUP)) {
@ -1865,8 +1905,8 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
groupList.add(groupInfo);
}
String[] parts = line.split(":");
if (parts[0].equals(GROUP)) {
if (parts[0].equals(GROUP)) {
String[] pairs = parts[1].split(",");
for (String s : pairs) {
String[] values = s.split("=", 2);
@ -1886,7 +1926,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
groupInfo.setGridLines(false);
}
} else if (values[0].equalsIgnoreCase(TRACEMODE)) {
groupInfo.setTraceMode(values[1]);
groupInfo.setTraceMode(values[1]);
} else if (values[0].equalsIgnoreCase(PASTHOURS)) {
groupInfo.setPastHours(Integer.parseInt(values[1]));
} else if (values[0].equalsIgnoreCase(FUTUREHOURS)) {
@ -1905,7 +1945,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
}
} else if (parts[0].equals(GRAPH)) {
graphData = new GraphData();
String[] pairs = parts[1].split(",");
for (String s : pairs) {
String[] values = s.split("=", 2);
@ -1929,10 +1969,10 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
} else if (values[0].equalsIgnoreCase(DERIVEPP)) {
graphData.setDerivepp(values[1]);
} else if (values[0].equalsIgnoreCase(SHOWPP)) {
if (values[1].equalsIgnoreCase("T")) {
showpp_flag = true;
} else {
showpp_flag = false;
if (values[1].equalsIgnoreCase("T")) {
showpp_flag = true;
} else {
showpp_flag = false;
}
} else if (values[0].equalsIgnoreCase(LATESTFCSTONLY)) {
if (values[1].equalsIgnoreCase("T")) {
@ -1962,26 +2002,27 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
} else if (values[0].equalsIgnoreCase(HydroConstants.PC)) {
td.setPc(values[1]);
if (showpp_flag == true)
graphData.setShowpp(true);
graphData.setShowpp(true);
else
graphData.setShowpp(false);
graphData.setShowpp(false);
} else if (values[0].equalsIgnoreCase(COLOR)) {
td.setColorName(values[1]);
}
}
}
graphData.addTrace(td);
graphData.addTrace(td);
graphData.setBeginDate(beginDate);
graphData.setEndDate(endDate);
} else {
statusHandler.warn("Error in Group Definition Config file: " + line);
}
// select the first item in the list
statusHandler
.warn("Error in Group Definition Config file: " + line);
}
// select the first item in the list
if (groupDataList.getItemCount() > 0) {
groupDataList.select(0);
groupDataList.select(0);
}
}
@ -2004,7 +2045,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
tabInfoList.clear();
if ((tabularDlg != null) && tabularDlg.isOpen()) {
tabularDlg.disposeTabularTS();
tabularDlg.close();
}
tabularDlg = new TabularTimeSeriesDlg(shell, beginCal.getTime(),
@ -2122,7 +2163,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
String s = bottomDataList.getItem(indices[0]);
String[] s2 = s.split("\\s+");
firstLidData.setPe(s2[0]);
firstLidData.setDur(TimeSeriesUtil.convertDurNameToValue(s));
ArrayList<TraceData> dataList = new ArrayList<TraceData>();
@ -2135,8 +2176,9 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
String selection = bottomDataList.getItem(indices[i]);
String[] pieces2 = selection.split("\\s+");
LIDData lidData = new LIDData();
String durValue = TimeSeriesUtil.convertDurNameToValue(selection);
String durValue = TimeSeriesUtil
.convertDurNameToValue(selection);
lidData.setDur(durValue);
lidData.setPe(pieces2[0]);
@ -2146,11 +2188,11 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
td.setPe(pieces2[0]);
td.setTs(pieces2[1]);
td.setExtremum(pieces2[2]);
if (pieces2[3].contains("=")) {
td.setDur("0");
} else {
td.setDur(durValue);
td.setDur(durValue);
}
dataList.add(td);
@ -2246,24 +2288,25 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
.getSelectionIndex());
if (prevGroupInfo == null || !prevGroupInfo.equals(groupInfo)) {
int pastHours = groupInfo.getPastHours();
int futureHours = groupInfo.getFutureHours();
beginCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
beginCal.add(Calendar.HOUR_OF_DAY, pastHours * -1);
endCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
endCal.add(Calendar.HOUR_OF_DAY, futureHours);
beginDate = beginCal.getTime();
endDate = endCal.getTime();
updateTimeButtons();
groupInfo.setPastHours(pastHours);
groupInfo.setFutureHours(futureHours);
int pastHours = groupInfo.getPastHours();
int futureHours = groupInfo.getFutureHours();
beginCal = Calendar
.getInstance(TimeZone.getTimeZone("GMT"));
beginCal.add(Calendar.HOUR_OF_DAY, pastHours * -1);
endCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
endCal.add(Calendar.HOUR_OF_DAY, futureHours);
beginDate = beginCal.getTime();
endDate = endCal.getTime();
updateTimeButtons();
groupInfo.setPastHours(pastHours);
groupInfo.setFutureHours(futureHours);
}
timeSeriesDisplayDlg.setGroupInfo(groupInfo);
prevGroupInfo = groupInfo;
}
timeSeriesDisplayDlg.setBeginDate(beginDate);
@ -2274,7 +2317,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
} else {
timeSeriesDisplayDlg.createNewGraph();
}
graphButton.setEnabled(true);
}
}
@ -2385,96 +2428,98 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
LinkedHashMap<String, ArrayList<SiteInfo>> dataMap,
boolean tsSelected) {
if (dataMap.size() > 0) {
final String OTHER = "OTHER";
final String OTHER = "OTHER";
Set<String> peSet = dataMap.keySet();
Iterator<String> iter = peSet.iterator();
Map<String, ArrayList<SiteInfo>> tsMap = new HashMap<String, ArrayList<SiteInfo>>();
for (String ts: TS_ORDER) {
tsMap.put(ts, new ArrayList<SiteInfo>());
for (String ts : TS_ORDER) {
tsMap.put(ts, new ArrayList<SiteInfo>());
}
tsMap.put(OTHER, new ArrayList<SiteInfo>());
ArrayList<SiteInfo> list = null;
String selectedTs = tsOrderCbo.getItem(tsOrderCbo
String selectedTs = tsOrderCbo.getItem(tsOrderCbo
.getSelectionIndex());
while (iter.hasNext()) {
String pe = iter.next();
list = dataMap.get(pe);
for (String ts: TS_ORDER) {
tsMap.get(ts).clear();
for (String ts : TS_ORDER) {
tsMap.get(ts).clear();
}
tsMap.get(OTHER).clear();
OUTER: for (SiteInfo si: list) {
for (String ts: TS_ORDER) {
if (si.getTs().startsWith(ts)) {
tsMap.get(ts).add(si);
continue OUTER;
}
}
tsMap.get(OTHER).add(si);
OUTER: for (SiteInfo si : list) {
for (String ts : TS_ORDER) {
if (si.getTs().startsWith(ts)) {
tsMap.get(ts).add(si);
continue OUTER;
}
}
tsMap.get(OTHER).add(si);
}
if (tsSelected) {
ArrayList<SiteInfo> siList = tsMap.get(selectedTs.substring(0,1));
ArrayList<SiteInfo> numList = new ArrayList<SiteInfo>();
for (SiteInfo si: siList) {
// Add the selected TS
if (si.getTs().equals(selectedTs)) {
// Check for TS values with a digit, those go after the TS
// values not containing digits
if (si.getTs().matches("\\D*\\d+\\D*")) {
numList.add(si);
} else {
bottomDataList.add(formatDataLine(si));
siteInfoList.add(si);
}
}
}
for (SiteInfo si: numList) {
bottomDataList.add(formatDataLine(si));
siteInfoList.add(si);
}
}
ArrayList<SiteInfo> numList = new ArrayList<SiteInfo>();
for (String ts: TS_ORDER) {
ArrayList<SiteInfo> siList = tsMap.get(ts);
for (SiteInfo si: siList) {
if (!siteInfoList.contains(si)) {
ArrayList<SiteInfo> siList = tsMap.get(selectedTs
.substring(0, 1));
ArrayList<SiteInfo> numList = new ArrayList<SiteInfo>();
for (SiteInfo si : siList) {
// Add the selected TS
if (si.getTs().equals(selectedTs)) {
// Check for TS values with a digit, those go after
// the TS
// values not containing digits
if (si.getTs().matches("\\D*\\d+\\D*")) {
numList.add(si);
} else {
bottomDataList.add(formatDataLine(si));
siteInfoList.add(si);
}
}
}
for (SiteInfo si: numList) {
}
}
for (SiteInfo si : numList) {
bottomDataList.add(formatDataLine(si));
siteInfoList.add(si);
}
}
ArrayList<SiteInfo> numList = new ArrayList<SiteInfo>();
for (String ts : TS_ORDER) {
ArrayList<SiteInfo> siList = tsMap.get(ts);
for (SiteInfo si : siList) {
if (!siteInfoList.contains(si)) {
if (si.getTs().matches("\\D*\\d+\\D*")) {
numList.add(si);
} else {
bottomDataList.add(formatDataLine(si));
siteInfoList.add(si);
}
}
}
for (SiteInfo si : numList) {
bottomDataList.add(formatDataLine(si));
siteInfoList.add(si);
}
numList.clear();
}
numList.clear();
ArrayList<SiteInfo> siList = tsMap.get(OTHER);
for (SiteInfo si: siList) {
ArrayList<SiteInfo> siList = tsMap.get(OTHER);
for (SiteInfo si : siList) {
if (si.getTs().matches("\\D*\\d+\\D*")) {
numList.add(si);
} else {
bottomDataList.add(formatDataLine(si));
siteInfoList.add(si);
}
}
for (SiteInfo si: numList) {
}
for (SiteInfo si : numList) {
bottomDataList.add(formatDataLine(si));
siteInfoList.add(si);
}
@ -2483,6 +2528,12 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
}
}
/**
* Update the dialog prepare for open.
*
* @param gageData
* @param displayGraph
*/
public void updateSelection(GageData gageData, boolean displayGraph) {
currentLid = gageData.getLid();
this.displayGraph = displayGraph;
@ -2497,12 +2548,10 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
}
setCurrentData();
opened();
// topDataList.select(topDataList.getSelectionIndex());
// topDataList.showSelection();
}
/**
* Build a Bottom Data List entry.
* Build a Bottom Data List entry. opened *
*
* @param si
* The SiteInfo object
@ -2540,4 +2589,15 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
public void enableBothButton() {
this.bothButton.setEnabled(true);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
*/
@Override
protected void preOpened() {
super.preOpened();
checkBottomButtons();
}
}

View file

@ -1,65 +0,0 @@
/**
*
*/
package com.raytheon.viz.hydro.timeseries;
import java.io.File;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
/**
* Action for Time Series Configuration Plug-in
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 24, 2011 7797 bkowal Initial creation.
*
* </pre>
*
* @author bkowal
*
*/
public class TimeSeriesconfigAction extends AbstractHandler {
private TimeSeriesDlg timeSeriesDialog;
private static final String ENV_WHFS_CONFIG_DIR = "whfs_config_dir";
private static final String GROUP_DEFINITION_FILE_NAME = "group_definition.cfg";
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
if (this.timeSeriesDialog == null || this.timeSeriesDialog.isDisposed()) {
this.timeSeriesDialog = new TimeSeriesDlg(shell,
locateGroupDefinitionFile());
this.timeSeriesDialog.open();
if (this.timeSeriesDialog != null && this.timeSeriesDialog.isOpen()) {
this.timeSeriesDialog.disposeDialogTS();
}
this.timeSeriesDialog = null;
} else {
this.timeSeriesDialog.setFocus();
}
return null;
}
protected static File locateGroupDefinitionFile() {
String configDir = System
.getenv(TimeSeriesconfigAction.ENV_WHFS_CONFIG_DIR);
if (!configDir.endsWith("/")) {
configDir = configDir + "/";
}
File file = new File(configDir
+ TimeSeriesconfigAction.GROUP_DEFINITION_FILE_NAME);
return file;
}
}

View file

@ -19,13 +19,15 @@
**/
package com.raytheon.viz.hydro.timeseries;
import java.io.File;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.viz.ui.personalities.awips.AbstractCAVEComponent;
import com.raytheon.viz.ui.personalities.awips.AbstractCAVEDialogComponent;
/**
* TODO Add Description
* Class to create a stand alone Time Series Dialog.
*
* <pre>
*
@ -34,6 +36,7 @@ import com.raytheon.viz.ui.personalities.awips.AbstractCAVEComponent;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 28, 2011 mschenke Initial creation
* Feb 05, 2013 1578 rferrel Changes for non-blocking singleton TimeSeriesDlg.
*
* </pre>
*
@ -41,7 +44,11 @@ import com.raytheon.viz.ui.personalities.awips.AbstractCAVEComponent;
* @version 1.0
*/
public class TimeSeriesconfigComponent extends AbstractCAVEComponent {
public class TimeSeriesconfigComponent extends AbstractCAVEDialogComponent {
private static final String ENV_WHFS_CONFIG_DIR = "whfs_config_dir";
private static final String GROUP_DEFINITION_FILE_NAME = "group_definition.cfg";
/*
* (non-Javadoc)
@ -54,11 +61,9 @@ public class TimeSeriesconfigComponent extends AbstractCAVEComponent {
protected void startInternal(String componentName) throws Exception {
TimeSeriesDlg timeSeriesDialog = new TimeSeriesDlg(new Shell(
Display.getCurrent()),
TimeSeriesconfigAction.locateGroupDefinitionFile());
TimeSeriesconfigComponent.locateGroupDefinitionFile());
timeSeriesDialog.open();
if (timeSeriesDialog != null && timeSeriesDialog.isOpen()) {
timeSeriesDialog.disposeDialogTS();
}
blockUntilClosed(timeSeriesDialog);
}
/*
@ -73,4 +78,20 @@ public class TimeSeriesconfigComponent extends AbstractCAVEComponent {
return ALERT_VIZ;
}
protected static File locateGroupDefinitionFile() {
String configDir = System
.getenv(TimeSeriesconfigComponent.ENV_WHFS_CONFIG_DIR);
if (configDir == null) {
configDir = "";
}
if (!configDir.endsWith("/")) {
configDir = configDir + "/";
}
File file = new File(configDir
+ TimeSeriesconfigComponent.GROUP_DEFINITION_FILE_NAME);
return file;
}
}