mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-22 04:05:39 +00:00
Merge remote-tracking branch
'origin/GP-4983-dragonmacher-script-table-columns' (Closes #6918)
This commit is contained in:
commit
0c9e060b17
@ -216,20 +216,7 @@ public class GhidraScriptComponentProvider extends ComponentProviderAdapter {
|
||||
|
||||
scriptTable.setAccessibleNamePrefix("Scripts");
|
||||
|
||||
TableColumnModel columnModel = scriptTable.getColumnModel();
|
||||
// Set default column sizes
|
||||
for (int i = 0; i < columnModel.getColumnCount(); i++) {
|
||||
TableColumn column = columnModel.getColumn(i);
|
||||
String name = (String) column.getHeaderValue();
|
||||
switch (name) {
|
||||
case GhidraScriptTableModel.SCRIPT_ACTION_COLUMN_NAME:
|
||||
initializeUnresizableColumn(column, 50);
|
||||
break;
|
||||
case GhidraScriptTableModel.SCRIPT_STATUS_COLUMN_NAME:
|
||||
initializeUnresizableColumn(column, 50);
|
||||
break;
|
||||
}
|
||||
}
|
||||
updateColumnSizes();
|
||||
|
||||
JScrollPane scriptTableScroll = new JScrollPane(scriptTable);
|
||||
buildFilter();
|
||||
@ -255,6 +242,48 @@ public class GhidraScriptComponentProvider extends ComponentProviderAdapter {
|
||||
component.add(dataDescriptionSplit, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
private void updateColumnSizes() {
|
||||
|
||||
//
|
||||
// Table column resize behavior is tough to control. When setting the column size here, we
|
||||
// use the max width to keep the columns from being resizable. The effect of this is that
|
||||
// the table will layout the columns by giving all extra space to the resizable columns.
|
||||
// Any columns not marked resizable will be the exact requested size. This allows us to
|
||||
// force small columns to take up the minimum amount of space. The downside of locking the
|
||||
// columns is that users cannot change the size. So, we will set the size for the initial
|
||||
// layout to get the size we desire, and then we will set the size again to make the columns
|
||||
// resizable after the layout has taken place.
|
||||
//
|
||||
forceSmallColumns(true);
|
||||
|
||||
// call again after the sizes have been updated from the previous call
|
||||
forceSmallColumns(false);
|
||||
}
|
||||
|
||||
private void forceSmallColumns(boolean lock) {
|
||||
int width = 50;
|
||||
TableColumnModel columnModel = scriptTable.getColumnModel();
|
||||
for (int i = 0; i < columnModel.getColumnCount(); i++) {
|
||||
TableColumn column = columnModel.getColumn(i);
|
||||
String name = (String) column.getHeaderValue();
|
||||
switch (name) {
|
||||
|
||||
case GhidraScriptTableModel.SCRIPT_ACTION_COLUMN_NAME:
|
||||
setColumnWidth(column, width, !lock);
|
||||
break;
|
||||
case GhidraScriptTableModel.SCRIPT_STATUS_COLUMN_NAME:
|
||||
setColumnWidth(column, width, !lock);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setColumnWidth(TableColumn column, int width, boolean resizable) {
|
||||
column.setPreferredWidth(width);
|
||||
column.setMinWidth(width);
|
||||
column.setMaxWidth(resizable ? Integer.MAX_VALUE : width);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore state for bundles, user actions, and filter.
|
||||
*
|
||||
@ -968,13 +997,6 @@ public class GhidraScriptComponentProvider extends ComponentProviderAdapter {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void initializeUnresizableColumn(TableColumn column, int width) {
|
||||
column.setPreferredWidth(width);
|
||||
column.setMinWidth(width);
|
||||
column.setMaxWidth(width);
|
||||
column.setResizable(false);
|
||||
}
|
||||
|
||||
private void updateTitle() {
|
||||
StringBuilder buffy = new StringBuilder();
|
||||
int currentRowCount = tableFilterPanel.getRowCount();
|
||||
|
Loading…
Reference in New Issue
Block a user