Check to see if column index is valid

Check to see if column index returned from the FlightConfigurationTable
model is referencing a valid column before getting the column data.
Additionally, the FlightConfigurationTableModel was not adequately
accounting for the FCID table column when returning the column.

Fixes #677

Signed-off-by: Billy Olsen <billy.olsen@gmail.com>
This commit is contained in:
Billy Olsen 2020-06-09 20:36:23 -07:00
parent 6920500847
commit cb11d18aaf
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);
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;