GP-6034 - Version Tracking - Fixed Function Comparison view not being

resizable
This commit is contained in:
dragonmacher
2025-09-30 16:11:56 -04:00
parent fc3debd7f7
commit 3b14dcf58b
6 changed files with 28 additions and 70 deletions

View File

@@ -97,6 +97,14 @@ public class FunctionComparisonPanel extends JPanel implements ChangeListener {
help.registerHelp(this, new HelpLocation(HELP_TOPIC, "Function Comparison")); help.registerHelp(this, new HelpLocation(HELP_TOPIC, "Function Comparison"));
} }
@Override
public Dimension getMinimumSize() {
// If we don't specify a minimum size, the some layouts will use the preferred size when
// calculating the minimum size. When this happens while this panel is inside of a split
// pane, the split pane can become un-resizable. By specify a value here, we prevent this.
return new Dimension(50, 50);
}
private void comparisonStateUpdated() { private void comparisonStateUpdated() {
readPanelState(); readPanelState();
readViewState(); readViewState();

View File

@@ -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.
@@ -15,7 +15,8 @@
*/ */
package ghidra.feature.vt.gui.provider.impliedmatches; package ghidra.feature.vt.gui.provider.impliedmatches;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -299,15 +300,8 @@ public class VTImpliedMatchesTableProvider extends ComponentProviderAdapter
TableColumn statusColumn = columnModel.getColumn(statusColumnIndex); TableColumn statusColumn = columnModel.getColumn(statusColumnIndex);
statusColumn.setCellRenderer(new MatchStatusRenderer()); statusColumn.setCellRenderer(new MatchStatusRenderer());
// override the default behavior so we see our columns in their preferred size // a reasonable starting size picked by trial-and-error
Dimension size = impliedMatchesTable.getPreferredScrollableViewportSize(); impliedMatchesTable.setPreferredScrollableViewportSize(new Dimension(1100, 600));
Dimension preferredSize = impliedMatchesTable.getPreferredSize();
// ...account for the scroll bar width
JScrollBar scrollBar = new JScrollBar(Adjustable.VERTICAL);
Dimension scrollBarSize = scrollBar.getMinimumSize();
size.width = preferredSize.width + scrollBarSize.width;
impliedMatchesTable.setPreferredScrollableViewportSize(size);
return impliedMatchTablePanel; return impliedMatchTablePanel;
} }

View File

@@ -320,16 +320,8 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter
TableColumn column = columnModel.getColumn(columnIndex); TableColumn column = columnModel.getColumn(columnIndex);
column.setCellEditor(new AddressInputDialog(controller)); column.setCellEditor(new AddressInputDialog(controller));
// override the default behavior so we see our columns in their preferred size // a reasonable starting size picked by trial-and-error
Dimension size = table.getPreferredScrollableViewportSize(); table.setPreferredScrollableViewportSize(new Dimension(1100, 600));
Dimension preferredSize = table.getPreferredSize();
// ...account for the scroll bar width
JScrollBar scrollBar = new JScrollBar(Adjustable.VERTICAL);
scrollBar.getAccessibleContext().setAccessibleName("Markup Item Table");
Dimension scrollBarSize = scrollBar.getMinimumSize();
size.width = preferredSize.width + scrollBarSize.width;
table.setPreferredScrollableViewportSize(size);
table.getAccessibleContext().setAccessibleName("Markup Item"); table.getAccessibleContext().setAccessibleName("Markup Item");
return table; return table;
} }

View File

@@ -373,15 +373,9 @@ public class VTMatchTableProvider extends ComponentProviderAdapter
TableColumn statusColumn = columnModel.getColumn(statusColumnIndex); TableColumn statusColumn = columnModel.getColumn(statusColumnIndex);
statusColumn.setCellRenderer(new MatchStatusRenderer()); statusColumn.setCellRenderer(new MatchStatusRenderer());
// override the default behavior so we see our columns in their preferred size // a reasonable starting size picked by trial-and-error
Dimension size = table.getPreferredScrollableViewportSize(); table.setPreferredScrollableViewportSize(new Dimension(1100, 600));
Dimension preferredSize = table.getPreferredSize();
// ...account for the scroll bar width
JScrollBar scrollBar = new JScrollBar(Adjustable.VERTICAL);
Dimension scrollBarSize = scrollBar.getMinimumSize();
size.width = preferredSize.width + scrollBarSize.width;
table.setPreferredScrollableViewportSize(size);
return table; return table;
} }

View File

@@ -257,15 +257,8 @@ public abstract class VTMatchOneToManyTableProvider extends ComponentProviderAda
TableColumn statusColumn = columnModel.getColumn(statusColumnIndex); TableColumn statusColumn = columnModel.getColumn(statusColumnIndex);
statusColumn.setCellRenderer(new MatchStatusRenderer()); statusColumn.setCellRenderer(new MatchStatusRenderer());
// override the default behavior so we see our columns in their preferred size // a reasonable starting size picked by trial-and-error
Dimension size = table.getPreferredScrollableViewportSize(); table.setPreferredScrollableViewportSize(new Dimension(1100, 600));
Dimension preferredSize = table.getPreferredSize();
// ...account for the scroll bar width
JScrollBar scrollBar = new JScrollBar(Adjustable.VERTICAL);
Dimension scrollBarSize = scrollBar.getMinimumSize();
size.width = preferredSize.width + scrollBarSize.width;
table.setPreferredScrollableViewportSize(size);
return table; return table;
} }

View File

@@ -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.
@@ -15,10 +15,11 @@
*/ */
package ghidra.feature.vt.gui.provider.relatedMatches; package ghidra.feature.vt.gui.provider.relatedMatches;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.*; import java.util.HashSet;
import java.util.List; import java.util.Set;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
@@ -62,7 +63,6 @@ public class VTRelatedMatchesTableProvider extends ComponentProviderAdapter {
setWindowGroup(VTPlugin.WINDOW_GROUP); setWindowGroup(VTPlugin.WINDOW_GROUP);
setIcon(ICON); setIcon(ICON);
createActions();
addToTool(); addToTool();
} }
@@ -109,44 +109,21 @@ public class VTRelatedMatchesTableProvider extends ComponentProviderAdapter {
ListSelectionModel selectionModel = table.getSelectionModel(); ListSelectionModel selectionModel = table.getSelectionModel();
selectionModel.addListSelectionListener(matchSelectionListener); selectionModel.addListSelectionListener(matchSelectionListener);
// override the default behavior so we see our columns in their preferred size // a reasonable starting size picked by trial-and-error
Dimension size = table.getPreferredScrollableViewportSize(); table.setPreferredScrollableViewportSize(new Dimension(1100, 600));
Dimension preferredSize = table.getPreferredSize();
// ...account for the scroll bar width
JScrollBar scrollBar = new JScrollBar(Adjustable.VERTICAL);
Dimension scrollBarSize = scrollBar.getMinimumSize();
size.width = preferredSize.width + scrollBarSize.width;
table.setPreferredScrollableViewportSize(size);
return table; return table;
} }
private void createActions() {
// addLocalAction( new AddMarkupItemAction( this ) );
// addLocalAction( new IgnoreMarkupItemAction( this ) );
}
private void notifyContextChanged() { private void notifyContextChanged() {
tool.contextChanged(this); tool.contextChanged(this);
} }
@Override @Override
public ActionContext getActionContext(MouseEvent event) { public ActionContext getActionContext(MouseEvent event) {
// List<VTRelatedMatch> selectedItems = getSelectedMatches();
// return new MarkupItemContext( this, selectedItems );
return null; return null;
} }
private List<VTRelatedMatch> getSelectedMatches() {
List<VTRelatedMatch> list = new ArrayList<VTRelatedMatch>();
int[] selectedRows = relatedMatchesTable.getSelectedRows();
for (int row : selectedRows) {
list.add(relatedMatchesTableModel.getRowObject(row));
}
return list;
}
public void refresh() { public void refresh() {
relatedMatchesTableModel.reload(); relatedMatchesTableModel.reload();
} }