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:
parent
6920500847
commit
cb11d18aaf
@ -89,7 +89,12 @@ public class FlightConfigurableTableModel<T extends FlightConfigurableComponent>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getColumnIndex(FlightConfigurableComponent comp) {
|
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
|
@Override
|
||||||
|
@ -83,14 +83,14 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel<Recovery
|
|||||||
final RocketComponent source = cce.getSource();
|
final RocketComponent source = cce.getSource();
|
||||||
if(source instanceof FlightConfigurableComponent) {
|
if(source instanceof FlightConfigurableComponent) {
|
||||||
final int index = recoveryTableModel.getColumnIndex((FlightConfigurableComponent) source);
|
final int index = recoveryTableModel.getColumnIndex((FlightConfigurableComponent) source);
|
||||||
|
if (index >= 0) {
|
||||||
recoveryTable.getColumnModel().getColumn(index).setHeaderValue(source.getName());
|
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
|
// you would think this would be enough by itself, but it requires an nudge from the above lines to
|
||||||
// actually update.
|
// actually update.
|
||||||
recoveryTable.getTableHeader().resizeAndRepaint();
|
recoveryTable.getTableHeader().resizeAndRepaint();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// recoveryTable.setColumnModel(recoveryTableModel);
|
|
||||||
recoveryTable.setDefaultRenderer(Object.class, new RecoveryTableCellRenderer());
|
recoveryTable.setDefaultRenderer(Object.class, new RecoveryTableCellRenderer());
|
||||||
|
|
||||||
return recoveryTable;
|
return recoveryTable;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user