VLab Issue #6996 MPE DR 17209 Draw polygon fails on Substitution when field is blank.; fixes #6996

Former-commit-id: 8b07d138544c4519c4eab52be7b4d6163b8d88ed
This commit is contained in:
Chip Gobs 2015-03-17 16:28:29 -04:00
parent d09efd7da7
commit 33a5c2021b

View file

@ -65,7 +65,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Feb 2, 2014 16201 snaples Added saved data flag support * Feb 2, 2014 16201 snaples Added saved data flag support
* Apr 28, 2014 16707 snaples Added code to save and set location of dialog box when moved. * Apr 28, 2014 16707 snaples Added code to save and set location of dialog box when moved.
* Jan 12, 2015 16993 snaples Restored code for Substitute Field Combo box. * Jan 12, 2015 16993 snaples Restored code for Substitute Field Combo box.
* * Feb 26, 2015 17209 cgobs Ensured that there is an initial selection of Substitution field, prevents empty selection.
* *
* </pre> * </pre>
* *
@ -387,16 +387,22 @@ public class DrawPolygonDlg extends CaveSWTDialog {
// spaceLabel.setText("***** "); // spaceLabel.setText("***** ");
int selectedFieldIndex = 0; int selectedFieldIndex = 0;
boolean found = false;
//find the index of the selected field //find the index of the selected field
for (selectedFieldIndex = 0; selectedFieldIndex < displayFieldDataArray.length; selectedFieldIndex++) for (selectedFieldIndex = 0; selectedFieldIndex < displayFieldDataArray.length; selectedFieldIndex++)
{ {
if (displayFieldDataArray[selectedFieldIndex] == subType) if (displayFieldDataArray[selectedFieldIndex] == subType)
{ {
found = true;
break; break;
} }
} }
if (!found)
{
selectedFieldIndex = 0;
}
//create and initialize the display field type name array //create and initialize the display field type name array
displayTypeNameArray = new String[displayFieldDataArray.length]; displayTypeNameArray = new String[displayFieldDataArray.length];
@ -411,27 +417,42 @@ public class DrawPolygonDlg extends CaveSWTDialog {
fieldTypeCombo.setTextLimit(35); fieldTypeCombo.setTextLimit(35);
fieldTypeCombo.setLayoutData(gd); fieldTypeCombo.setLayoutData(gd);
fieldTypeCombo.setItems(displayTypeNameArray); fieldTypeCombo.setItems(displayTypeNameArray);
fieldTypeCombo.select(selectedFieldIndex); // fieldTypeCombo.select(selectedFieldIndex);
fieldTypeCombo.addSelectionListener(new SelectionAdapter() { fieldTypeCombo.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
String selectedFieldString = fieldTypeCombo.getText();
setSubstitutionField();
// String selectedFieldString = fieldTypeCombo.getText();
// System.out.println("DrawPolygon.createFieldCombo(): selectedFieldString = " + // System.out.println("DrawPolygon.createFieldCombo(): selectedFieldString = " +
// selectedFieldString); // selectedFieldString);
subType = DisplayFieldData.fromDisplayNameString(selectedFieldString); // subType = DisplayFieldData.fromDisplayNameString(selectedFieldString);
// if (subType != null) // if (subType != null)
// { // {
// System.out.println("DrawPolygon.createFieldCombo(): subType = " + // System.out.println("DrawPolygon.createFieldCombo(): subType = " +
// subType.toString()); // subType.toString());
// } // }
} }
}); });
//select the substitution field
fieldTypeCombo.select(selectedFieldIndex);
setSubstitutionField();
} }
private void setSubstitutionField()
{
String selectedFieldString = fieldTypeCombo.getText();
subType = DisplayFieldData.fromDisplayNameString(selectedFieldString);
}
/** /**