First restore column visibility
Fixes the second column to start disappearing...
This commit is contained in:
parent
78dac7e498
commit
439b0a77c6
@ -60,7 +60,19 @@ public class TableUIPreferences {
|
||||
table.addColumn(col);
|
||||
}
|
||||
|
||||
// Restore column order
|
||||
// Get all columns from the table's column model and restore visibility
|
||||
if (table.getColumnModel() instanceof XTableColumnModel customModel) {
|
||||
Enumeration<TableColumn> columns = customModel.getAllColumns(); // Use getAllColumns to get all columns, including invisible ones
|
||||
while (columns.hasMoreElements()) {
|
||||
TableColumn column = columns.nextElement();
|
||||
String identifier = column.getIdentifier().toString();
|
||||
// Default to true if the preference is not found
|
||||
boolean isVisible = preferences.getBoolean(tableName + TABLE_COLUMN_VISIBILITY_PREFIX + identifier, true);
|
||||
customModel.setColumnVisible(column, isVisible);
|
||||
}
|
||||
}
|
||||
|
||||
// Now, restore column order
|
||||
for (int i = 0; i < table.getColumnCount(); i++) {
|
||||
TableColumn column = table.getColumnModel().getColumn(i);
|
||||
int storedOrder = preferences.getInt(tableName + TABLE_COLUMN_ORDER_PREFIX + column.getIdentifier(), i);
|
||||
@ -91,18 +103,5 @@ public class TableUIPreferences {
|
||||
int width = preferences.getInt(tableName + TABLE_COLUMN_WIDTH_PREFIX + column.getIdentifier(), defaultWidth);
|
||||
column.setPreferredWidth(width);
|
||||
}
|
||||
|
||||
// Get all columns from the table's column model
|
||||
if (table.getColumnModel() instanceof XTableColumnModel customModel) {
|
||||
Enumeration<TableColumn> columns = customModel.getAllColumns(); // Use getAllColumns to get all columns, including invisible ones
|
||||
|
||||
while (columns.hasMoreElements()) {
|
||||
TableColumn column = columns.nextElement();
|
||||
String identifier = column.getIdentifier().toString();
|
||||
// Default to true if the preference is not found
|
||||
boolean isVisible = preferences.getBoolean(tableName + TABLE_COLUMN_VISIBILITY_PREFIX + identifier, true);
|
||||
customModel.setColumnVisible(column, isVisible);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user