mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-22 04:05:39 +00:00
GP-4984 - Fixed row selection while using the filter; updated columns to
be resizable
This commit is contained in:
parent
224ffee47a
commit
f4b89fd26c
@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@ -122,10 +122,6 @@ class MemoryMapProvider extends ComponentProviderAdapter {
|
|||||||
arrangeTable();
|
arrangeTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryMapManager getMemoryMapManager() {
|
|
||||||
return memManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel buildMainPanel() {
|
private JPanel buildMainPanel() {
|
||||||
JPanel memPanel = new JPanel(new BorderLayout());
|
JPanel memPanel = new JPanel(new BorderLayout());
|
||||||
tableModel = new MemoryMapModel(this, null);
|
tableModel = new MemoryMapModel(this, null);
|
||||||
@ -153,16 +149,17 @@ class MemoryMapProvider extends ComponentProviderAdapter {
|
|||||||
column = table.getColumn(MemoryMapModel.LENGTH_COL);
|
column = table.getColumn(MemoryMapModel.LENGTH_COL);
|
||||||
column.setCellRenderer(monoRenderer);
|
column.setCellRenderer(monoRenderer);
|
||||||
|
|
||||||
|
GBooleanCellRenderer booleanRenderer = new GBooleanCellRenderer();
|
||||||
column = table.getColumn(MemoryMapModel.READ_COL);
|
column = table.getColumn(MemoryMapModel.READ_COL);
|
||||||
column.setCellRenderer(new GBooleanCellRenderer());
|
column.setCellRenderer(booleanRenderer);
|
||||||
column = table.getColumn(MemoryMapModel.WRITE_COL);
|
column = table.getColumn(MemoryMapModel.WRITE_COL);
|
||||||
column.setCellRenderer(new GBooleanCellRenderer());
|
column.setCellRenderer(booleanRenderer);
|
||||||
column = table.getColumn(MemoryMapModel.EXECUTE_COL);
|
column = table.getColumn(MemoryMapModel.EXECUTE_COL);
|
||||||
column.setCellRenderer(new GBooleanCellRenderer());
|
column.setCellRenderer(booleanRenderer);
|
||||||
column = table.getColumn(MemoryMapModel.VOLATILE_COL);
|
column = table.getColumn(MemoryMapModel.VOLATILE_COL);
|
||||||
column.setCellRenderer(new GBooleanCellRenderer());
|
column.setCellRenderer(booleanRenderer);
|
||||||
column = table.getColumn(MemoryMapModel.INIT_COL);
|
column = table.getColumn(MemoryMapModel.INIT_COL);
|
||||||
column.setCellRenderer(new GBooleanCellRenderer());
|
column.setCellRenderer(booleanRenderer);
|
||||||
|
|
||||||
table.setDefaultEditor(String.class,
|
table.setDefaultEditor(String.class,
|
||||||
new GTableTextCellEditor(new MaxLengthField(MAX_SIZE)));
|
new GTableTextCellEditor(new MaxLengthField(MAX_SIZE)));
|
||||||
@ -453,60 +450,65 @@ class MemoryMapProvider extends ComponentProviderAdapter {
|
|||||||
updateTitle();
|
updateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up the table so it looks well arranged.
|
|
||||||
*/
|
|
||||||
private void arrangeTable() {
|
private void arrangeTable() {
|
||||||
// memTable.setRowHeight(20);
|
//
|
||||||
TableColumn column;
|
// 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.
|
||||||
|
//
|
||||||
|
setColumnSizes(true);
|
||||||
|
|
||||||
column = table.getColumn(MemoryMapModel.READ_COL);
|
// call again after the sizes have been updated from the previous call
|
||||||
if (column != null) {
|
setColumnSizes(false);
|
||||||
column.setMaxWidth(25);
|
}
|
||||||
column.setMinWidth(25);
|
|
||||||
column.setResizable(false);
|
private void setColumnSizes(boolean lock) {
|
||||||
}
|
|
||||||
|
boolean resizable = !lock;
|
||||||
|
TableColumn column = table.getColumn(MemoryMapModel.READ_COL);
|
||||||
|
int width = 25;
|
||||||
|
int maxWidth = resizable ? Integer.MAX_VALUE : width;
|
||||||
|
column.setMaxWidth(maxWidth);
|
||||||
|
column.setMinWidth(width);
|
||||||
|
column.setResizable(resizable);
|
||||||
|
|
||||||
column = table.getColumn(MemoryMapModel.WRITE_COL);
|
column = table.getColumn(MemoryMapModel.WRITE_COL);
|
||||||
if (column != null) {
|
column.setMaxWidth(maxWidth);
|
||||||
column.setMaxWidth(25);
|
column.setMinWidth(width);
|
||||||
column.setMinWidth(25);
|
column.setResizable(resizable);
|
||||||
column.setResizable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
column = table.getColumn(MemoryMapModel.EXECUTE_COL);
|
column = table.getColumn(MemoryMapModel.EXECUTE_COL);
|
||||||
if (column != null) {
|
column.setMaxWidth(maxWidth);
|
||||||
column.setMaxWidth(25);
|
column.setMinWidth(width);
|
||||||
column.setMinWidth(25);
|
column.setResizable(resizable);
|
||||||
column.setResizable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
column = table.getColumn(MemoryMapModel.VOLATILE_COL);
|
column = table.getColumn(MemoryMapModel.VOLATILE_COL);
|
||||||
if (column != null) {
|
width = 65;
|
||||||
column.setMaxWidth(65);
|
maxWidth = resizable ? Integer.MAX_VALUE : width;
|
||||||
column.setMinWidth(65);
|
column.setMaxWidth(maxWidth);
|
||||||
column.setResizable(false);
|
column.setMinWidth(width);
|
||||||
}
|
column.setResizable(resizable);
|
||||||
|
|
||||||
column = table.getColumn(MemoryMapModel.ARTIFICIAL_COL);
|
column = table.getColumn(MemoryMapModel.ARTIFICIAL_COL);
|
||||||
if (column != null) {
|
column.setMaxWidth(maxWidth);
|
||||||
column.setMaxWidth(65);
|
column.setMinWidth(width);
|
||||||
column.setMinWidth(65);
|
column.setResizable(resizable);
|
||||||
column.setResizable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
column = table.getColumn(MemoryMapModel.BLOCK_TYPE_COL);
|
column = table.getColumn(MemoryMapModel.BLOCK_TYPE_COL);
|
||||||
if (column != null) {
|
width = 25;
|
||||||
column.setMinWidth(25);
|
maxWidth = resizable ? Integer.MAX_VALUE : width;
|
||||||
// column.setResizable(true);
|
column.setMinWidth(width);
|
||||||
}
|
|
||||||
|
|
||||||
column = table.getColumn(MemoryMapModel.INIT_COL);
|
column = table.getColumn(MemoryMapModel.INIT_COL);
|
||||||
if (column != null) {
|
column.setMaxWidth(maxWidth);
|
||||||
column.setMaxWidth(25);
|
column.setMinWidth(width);
|
||||||
column.setMinWidth(25);
|
column.setResizable(resizable);
|
||||||
column.setResizable(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -545,24 +547,26 @@ class MemoryMapProvider extends ComponentProviderAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void navigateToAddress() {
|
|
||||||
int viewRow = table.getSelectedRow();
|
|
||||||
int viewColumn = table.getSelectedColumn();
|
|
||||||
int modelColumn = table.convertColumnIndexToModel(viewColumn);
|
|
||||||
MemoryBlock block = tableModel.getBlockAt(viewRow);
|
|
||||||
if (block != null && (modelColumn == 1 || modelColumn == 2)) {
|
|
||||||
Address addr = (modelColumn == 1 ? block.getStart() : block.getEnd());
|
|
||||||
plugin.blockSelected(block, addr);
|
|
||||||
table.setRowSelectionInterval(viewRow, viewRow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private MemoryBlock getSelectedBlock() {
|
private MemoryBlock getSelectedBlock() {
|
||||||
int row = table.getSelectedRow();
|
int row = table.getSelectedRow();
|
||||||
if (row < 0) {
|
if (row < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return tableModel.getBlockAt(row);
|
int viewRow = table.getSelectedRow();
|
||||||
|
int modelRow = filterPanel.getModelRow(viewRow);
|
||||||
|
return tableModel.getBlockAt(modelRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void navigateToAddress() {
|
||||||
|
int viewRow = table.getSelectedRow();
|
||||||
|
int viewColumn = table.getSelectedColumn();
|
||||||
|
int modelColumn = table.convertColumnIndexToModel(viewColumn);
|
||||||
|
MemoryBlock block = getSelectedBlock();
|
||||||
|
if (block != null && (modelColumn == 1 || modelColumn == 2)) {
|
||||||
|
Address addr = (modelColumn == 1 ? block.getStart() : block.getEnd());
|
||||||
|
plugin.blockSelected(block, addr);
|
||||||
|
table.setRowSelectionInterval(viewRow, viewRow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renameOverlaySpace(ActionContext c) {
|
private void renameOverlaySpace(ActionContext c) {
|
||||||
|
Loading…
Reference in New Issue
Block a user