Merge pull request #678 from wolsen/issue/677

Check to see if column index is valid
This commit is contained in:
Daniel Williams 2020-06-12 19:15:01 -04:00 committed by GitHub
commit c26dd8cb61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -89,7 +89,12 @@ public class FlightConfigurableTableModel<T extends FlightConfigurableComponent>
}
public int getColumnIndex(FlightConfigurableComponent comp) {
return components.indexOf(comp);
int index = components.indexOf(comp);
if (index >= 0) {
// Increment the index to account for the fcid column.
index += 1;
}
return index;
}
@Override

View File

@ -83,14 +83,14 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel<Recovery
final RocketComponent source = cce.getSource();
if(source instanceof FlightConfigurableComponent) {
final int index = recoveryTableModel.getColumnIndex((FlightConfigurableComponent) source);
recoveryTable.getColumnModel().getColumn(index).setHeaderValue(source.getName());
if (index >= 0) {
recoveryTable.getColumnModel().getColumn(index).setHeaderValue(source.getName());
}
// you would think this would be enough by itself, but it requires an nudge from the above lines to
// actually update.
recoveryTable.getTableHeader().resizeAndRepaint();
}
});
// recoveryTable.setColumnModel(recoveryTableModel);
recoveryTable.setDefaultRenderer(Object.class, new RecoveryTableCellRenderer());
return recoveryTable;