diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/gagedisplay/GageLegend.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/gagedisplay/GageLegend.java index 3aa4dac7ca..4ab4009381 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/gagedisplay/GageLegend.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/gagedisplay/GageLegend.java @@ -42,6 +42,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jul 3, 2008 mpduff Initial creation + * Apr 18,2013 1790 rferrel Minor code clean up. * * * @@ -75,7 +76,7 @@ public class GageLegend extends CaveSWTDialog { GridData gd = new GridData(150, 350); GridLayout layout = new GridLayout(1, false); - Browser browser; + Browser browser = null; try { browser = new Browser(shell, SWT.NONE); } catch (SWTError e) { @@ -83,7 +84,7 @@ public class GageLegend extends CaveSWTDialog { .getDefault() .getLog() .log(new Status(Status.ERROR, CorePlugin.PLUGIN_NAME, - "Could not instantiate Browser", e)); + "Could not instantiate Browser ", e)); return; } browser.setLayout(layout); @@ -130,7 +131,7 @@ public class GageLegend extends CaveSWTDialog { sb.append(" Missing Data"); sb.append(""); sb.append(" Missing Stage Data"); - sb.append(""); + sb.append(""); return sb.toString(); } diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AddModifyLocationDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AddModifyLocationDlg.java index a6b732a46e..9faabe5335 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AddModifyLocationDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AddModifyLocationDlg.java @@ -82,6 +82,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * 16 Apr 2013 1790 rferrel Make dialog non-blocking. * Changes for non-blocking CoopAgencyOfficeDlg. * Changes for non-blocking CopyNewLocationDlg. + * Changes for non-blocking CountyStateDlg. * * * @@ -99,10 +100,15 @@ public class AddModifyLocationDlg extends CaveSWTDialog implements private CoopAgencyOfficeDlg coopAgencyOfficeDlg; /** - * Allow ojne Copy New dialog. + * Allow one Copy New dialog. */ private CopyNewLocationDlg copyDlg; + /** + * Allow one County/State dialog. + */ + private CountyStateDlg countyStateDlg; + /** * Font used for controls. */ @@ -1867,10 +1873,15 @@ public class AddModifyLocationDlg extends CaveSWTDialog implements } private void openCountyStateDlg() { - CountyStateDlg countyStateDlg = new CountyStateDlg(shell); - countyStateDlg.addListener(this); + if (countyStateDlg == null || countyStateDlg.isDisposed()) { + countyStateDlg = new CountyStateDlg(shell); + countyStateDlg.addListener(this); + countyStateDlg.open(); + } else { + countyStateDlg.bringToTop(); + } - // Open the county/state dlg + // Set the selection county/state dlg if (!countyStateTF.getText().equals("")) { // Set selection in dialog to current location's settings CountiesData currCountyState = new CountiesData(); @@ -1880,12 +1891,8 @@ public class AddModifyLocationDlg extends CaveSWTDialog implements currCountyState.setState(countyState[1].trim()); // Tell county/state dialog what to select - countyStateDlg.open(currCountyState); - } else { - countyStateDlg.open(); + countyStateDlg.setSelection(currCountyState); } - - countyStateDlg.removeListener(this); } @Override diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CountyStateDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CountyStateDlg.java index 0f134d5468..aec22c8b0e 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CountyStateDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CountyStateDlg.java @@ -29,7 +29,6 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.List; @@ -50,6 +49,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * ------------ ---------- ----------- -------------------------- * 02 Sep 2008 lvenable Initial creation. * Dec 5, 2008 1744 askripsk Connect to DB + * Apr 18,2013 1790 rferrel Made dialog non-blocking. * * * @@ -124,28 +124,6 @@ public class CountyStateDlg extends CaveSWTDialog { getDialogData(); } - /** - * Open method used to display the dialog. - * - * @return True/False. - */ - public Object open(CountiesData selectedData) { - open(); - - setSelection(selectedData); - - Display display = getDisplay(); - - // Manually block here - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) { - display.sleep(); - } - } - - return getReturnValue(); - } - /** * Create the county and state controls. */ @@ -225,10 +203,10 @@ public class CountyStateDlg extends CaveSWTDialog { * @return List label text. */ private String getCountyStateListLabelText() { - String format = "%S %S"; - - String labelStr = String.format(format, "County", "State"); - + CountiesData rval = new CountiesData(); + rval.setCounty("COUNTY"); + rval.setState("STATE"); + String labelStr = formatCountState(rval); return labelStr; } @@ -254,11 +232,21 @@ public class CountyStateDlg extends CaveSWTDialog { countyStateList.removeAll(); for (CountiesData currCounty : countiesData) { - countyStateList.add(String.format("%-20s %-2s", currCounty - .getCounty(), currCounty.getState())); + countyStateList.add(formatCountState(currCounty)); } } + /** + * Formated county/state data for list view. + * + * @param countiesData + * @return formatedString + */ + private String formatCountState(CountiesData countiesData) { + return String.format("%-36s %-2s", countiesData.getCounty(), + countiesData.getState()); + } + /** * Gets the currently selected county/state data * @@ -318,28 +306,15 @@ public class CountyStateDlg extends CaveSWTDialog { if (selectedData == null) { return; } - String currRow; - String currCounty; - String currState; - String[] countyState; + + String selectedString = formatCountState(selectedData); // Clear selection countyStateList.deselectAll(); // Find the county/state and select it for (int i = 0; i < countyStateList.getItemCount(); i++) { - currRow = countyStateList.getItem(i); - - // Split on whitespace - countyState = currRow.split("\\s+"); - - // Save the county and state - currCounty = countyState[0]; - currState = countyState[1]; - - // compare - if (selectedData.getCounty().equalsIgnoreCase(currCounty) - && selectedData.getState().equalsIgnoreCase(currState)) { + if (selectedString.equalsIgnoreCase(countyStateList.getItem(i))) { countyStateList.setSelection(i); break; } diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/NwrTransmitterDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/NwrTransmitterDlg.java index e1124356fa..9c6f8acd88 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/NwrTransmitterDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/NwrTransmitterDlg.java @@ -58,6 +58,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * ------------ ---------- ----------- -------------------------- * Sep 5, 2008 lvenable Initial creation * Jan 9, 2008 1802 askripsk Connect to DB. + * Apr 17,2013 1790 rferrel Changes for non-blocking CountyStateDlg. * * * @@ -67,6 +68,11 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; public class NwrTransmitterDlg extends CaveSWTDialog implements ICountyStateListener { + /** + * Allow one Count/State dialog. + */ + private CountyStateDlg countyStateDlg; + /** * Control font. */ @@ -640,8 +646,8 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements // update the display with the data if (availableCounties.size() > 0) { for (CountiesData currCounty : availableCounties) { - cntyAvailList.add(String.format(cntFormat, currCounty - .getCounty(), currCounty.getState())); + cntyAvailList.add(String.format(cntFormat, + currCounty.getCounty(), currCounty.getState())); } updateDialogState(DialogState.COUNTIES_AVAILABLE); @@ -687,8 +693,8 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements HydroDataUtils.getLatLonDisplayString(currTx .getLatitude()), HydroDataUtils .getLatLonDisplayString(currTx.getLongitude()), - HydroDataUtils.getDisplayString("%s", "%7.3f", currTx - .getTransmitFrequency()), HydroDataUtils + HydroDataUtils.getDisplayString("%s", "%7.3f", + currTx.getTransmitFrequency()), HydroDataUtils .getDisplayString(currTx.getTransmitPower()), currTx.getTransmitProductCode(), currTx .getTransmitCountyNumber(), currTx @@ -820,8 +826,7 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements } catch (VizException e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Save"); - mb - .setMessage("An error occurred while trying to save the City"); + mb.setMessage("An error occurred while trying to save the City"); mb.open(); e.printStackTrace(); @@ -854,8 +859,7 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements } catch (VizException e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Save"); - mb - .setMessage("An error occurred while trying to save the County"); + mb.setMessage("An error occurred while trying to save the County"); mb.open(); e.printStackTrace(); @@ -879,8 +883,8 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements | SWT.CANCEL); mb.setText("Delete Confirmation"); mb.setMessage(String.format( - "Do you wish to delete Transmitter %s?", currData - .getCallSign())); + "Do you wish to delete Transmitter %s?", + currData.getCallSign())); int result = mb.open(); @@ -890,12 +894,10 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements if (selectedCounties.size() > 0) { mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Delete"); - mb - .setMessage(String - .format( - "Can not delete NWR Transmitter %s.\n" - + "There is at least one county associated with it.", - currData.getCallSign())); + mb.setMessage(String + .format("Can not delete NWR Transmitter %s.\n" + + "There is at least one county associated with it.", + currData.getCallSign())); mb.open(); } else { try { @@ -906,8 +908,7 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements } catch (VizException e) { mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Delete"); - mb - .setMessage("An error occurred while trying to delete the City"); + mb.setMessage("An error occurred while trying to delete the City"); mb.open(); e.printStackTrace(); @@ -948,8 +949,7 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements } catch (VizException e) { mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Delete"); - mb - .setMessage("An error occurred while trying to delete the City"); + mb.setMessage("An error occurred while trying to delete the City"); mb.open(); e.printStackTrace(); @@ -1026,8 +1026,8 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements if (selectedCounties.size() > 0) { for (CountyTransmitData currCounty : selectedCounties) { - cntyCovList.add(String.format("%-20s %-2s", currCounty - .getCounty(), currCounty.getState())); + cntyCovList.add(String.format("%-20s %-2s", + currCounty.getCounty(), currCounty.getState())); } updateDialogState(DialogState.COUNTIES_SELECTED); @@ -1126,10 +1126,15 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements * Opens the County/State selection dialog */ private void openCountyStateDlg() { - CountyStateDlg countyStateDlg = new CountyStateDlg(shell); - countyStateDlg.addListener(this); + if (countyStateDlg == null || countyStateDlg.isDisposed()) { + countyStateDlg = new CountyStateDlg(shell); + countyStateDlg.addListener(this); + countyStateDlg.open(); + } else { + countyStateDlg.bringToTop(); + } - // Open the county/state dlg + // Set the selection county/state dlg if (!countyStateTF.getText().equals("")) { // Set selection in dialog to current location's settings CountiesData currCountyState = new CountiesData(); @@ -1139,12 +1144,8 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements currCountyState.setState(countyState[1].trim()); // Tell county/state dialog what to select - countyStateDlg.open(currCountyState); - } else { - countyStateDlg.open(); + countyStateDlg.setSelection(currCountyState); } - - countyStateDlg.removeListener(this); } @Override