Merge remote-tracking branch 'origin/Ghidra_12.0'

This commit is contained in:
Ryan Kurtz
2025-10-01 05:02:02 -04:00
11 changed files with 55 additions and 114 deletions

View File

@@ -97,6 +97,14 @@ public class FunctionComparisonPanel extends JPanel implements ChangeListener {
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() {
readPanelState();
readViewState();

View File

@@ -37,7 +37,7 @@ public class FgToggleSatelliteAction extends ToggleDockingAction {
setPopupMenuData(new MenuData(new String[] { "Display Satellite" }));
setHelpLocation(new HelpLocation("FunctionGraphPlugin", "Satellite_View"));
setHelpLocation(new HelpLocation("VisualGraph", "Satellite_View"));
}
@Override

View File

@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,7 +15,8 @@
*/
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.List;
@@ -299,15 +300,8 @@ public class VTImpliedMatchesTableProvider extends ComponentProviderAdapter
TableColumn statusColumn = columnModel.getColumn(statusColumnIndex);
statusColumn.setCellRenderer(new MatchStatusRenderer());
// override the default behavior so we see our columns in their preferred size
Dimension size = impliedMatchesTable.getPreferredScrollableViewportSize();
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);
// a reasonable starting size picked by trial-and-error
impliedMatchesTable.setPreferredScrollableViewportSize(new Dimension(1100, 600));
return impliedMatchTablePanel;
}

View File

@@ -320,16 +320,8 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter
TableColumn column = columnModel.getColumn(columnIndex);
column.setCellEditor(new AddressInputDialog(controller));
// override the default behavior so we see our columns in their preferred size
Dimension size = table.getPreferredScrollableViewportSize();
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);
// a reasonable starting size picked by trial-and-error
table.setPreferredScrollableViewportSize(new Dimension(1100, 600));
table.getAccessibleContext().setAccessibleName("Markup Item");
return table;
}

View File

@@ -373,15 +373,9 @@ public class VTMatchTableProvider extends ComponentProviderAdapter
TableColumn statusColumn = columnModel.getColumn(statusColumnIndex);
statusColumn.setCellRenderer(new MatchStatusRenderer());
// override the default behavior so we see our columns in their preferred size
Dimension size = table.getPreferredScrollableViewportSize();
Dimension preferredSize = table.getPreferredSize();
// a reasonable starting size picked by trial-and-error
table.setPreferredScrollableViewportSize(new Dimension(1100, 600));
// ...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;
}

View File

@@ -257,15 +257,8 @@ public abstract class VTMatchOneToManyTableProvider extends ComponentProviderAda
TableColumn statusColumn = columnModel.getColumn(statusColumnIndex);
statusColumn.setCellRenderer(new MatchStatusRenderer());
// override the default behavior so we see our columns in their preferred size
Dimension size = table.getPreferredScrollableViewportSize();
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);
// a reasonable starting size picked by trial-and-error
table.setPreferredScrollableViewportSize(new Dimension(1100, 600));
return table;
}

View File

@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,10 +15,11 @@
*/
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.util.*;
import java.util.List;
import java.util.HashSet;
import java.util.Set;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
@@ -62,7 +63,6 @@ public class VTRelatedMatchesTableProvider extends ComponentProviderAdapter {
setWindowGroup(VTPlugin.WINDOW_GROUP);
setIcon(ICON);
createActions();
addToTool();
}
@@ -109,44 +109,21 @@ public class VTRelatedMatchesTableProvider extends ComponentProviderAdapter {
ListSelectionModel selectionModel = table.getSelectionModel();
selectionModel.addListSelectionListener(matchSelectionListener);
// override the default behavior so we see our columns in their preferred size
Dimension size = table.getPreferredScrollableViewportSize();
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);
// a reasonable starting size picked by trial-and-error
table.setPreferredScrollableViewportSize(new Dimension(1100, 600));
return table;
}
private void createActions() {
// addLocalAction( new AddMarkupItemAction( this ) );
// addLocalAction( new IgnoreMarkupItemAction( this ) );
}
private void notifyContextChanged() {
tool.contextChanged(this);
}
@Override
public ActionContext getActionContext(MouseEvent event) {
// List<VTRelatedMatch> selectedItems = getSelectedMatches();
// return new MarkupItemContext( this, selectedItems );
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() {
relatedMatchesTableModel.reload();
}

View File

@@ -44,7 +44,7 @@ public class ProjectRepoConnectAction extends FrontendProjectTreeAction {
this.plugin = plugin;
setPopupMenuData(
new MenuData(new String[] { "Connect Shared Repository" }, CONNECT_ICON, group));
setHelpLocation(new HelpLocation("VersionControl", "Connect_Shared_Repository"));
setHelpLocation(new HelpLocation("VersionControl", "ConnectToServer"));
}
@Override

View File

@@ -425,7 +425,6 @@ class PluginManager {
private void unregisterPlugin(Plugin plugin) {
if (pluginList.remove(plugin)) {
plugin.cleanup();
tool.getOptionsManager().deregisterOwner(plugin);
}
}

View File

@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,7 +28,6 @@ import docking.options.editor.OptionsDialog;
import docking.tool.ToolConstants;
import docking.tool.util.DockingToolConstants;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.Plugin;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.dialog.KeyBindingsPanel;
import ghidra.util.HelpLocation;
@@ -111,9 +110,7 @@ public class OptionsManager implements OptionsService, OptionsChangeListener {
public ToolOptions[] getOptions() {
ToolOptions[] opt = new ToolOptions[optionsMap.size()];
int idx = 0;
Iterator<String> iter = optionsMap.keySet().iterator();
while (iter.hasNext()) {
String key = iter.next();
for (String key : optionsMap.keySet()) {
opt[idx] = optionsMap.get(key);
++idx;
}
@@ -121,24 +118,6 @@ public class OptionsManager implements OptionsService, OptionsChangeListener {
return opt;
}
/**
* Deregister the owner from the options; if options are empty, then
* remove the options from the map.
* @param ownerPlugin the owner plugin
*/
public void deregisterOwner(Plugin ownerPlugin) {
List<String> deleteList = new ArrayList<>();
Iterator<String> iter = optionsMap.keySet().iterator();
while (iter.hasNext()) {
String key = iter.next();
ToolOptions opt = optionsMap.get(key);
if (opt.getOptionNames().isEmpty()) {
deleteList.add(opt.getName());
}
}
removeUnusedOptions(deleteList);
}
/**
* Write this object out; first remove any unused options so they
* do not hang around.
@@ -146,9 +125,7 @@ public class OptionsManager implements OptionsService, OptionsChangeListener {
*/
public Element getConfigState() {
Element root = new Element("OPTIONS");
Iterator<String> iter = optionsMap.keySet().iterator();
while (iter.hasNext()) {
String key = iter.next();
for (String key : optionsMap.keySet()) {
ToolOptions opt = optionsMap.get(key);
if (hasNonDefaultValues(opt)) {
root.addContent(opt.getXmlRoot(false));
@@ -170,9 +147,7 @@ public class OptionsManager implements OptionsService, OptionsChangeListener {
public void removeUnusedOptions() {
// 1st clean up any unused options before saving...
List<String> deleteList = new ArrayList<>();
Iterator<String> iter = optionsMap.keySet().iterator();
while (iter.hasNext()) {
String key = iter.next();
for (String key : optionsMap.keySet()) {
ToolOptions opt = optionsMap.get(key);
opt.removeUnusedOptions();
if (opt.getOptionNames().isEmpty()) {
@@ -239,9 +214,9 @@ public class OptionsManager implements OptionsService, OptionsChangeListener {
}
keyBindingOptions.registerOptionsEditor(() -> new KeyBindingOptionsEditor());
OptionsDialog dialog =
new OptionsDialog("Options for " + tool.getName(), "Options", getEditableOptions(),
null, true);
String optionsName = "Options for " + tool.getName();
Options[] options = getEditableOptions();
OptionsDialog dialog = new OptionsDialog(optionsName, "Options", options, null, true);
dialog.setSelectedPath(path);
dialog.setHelpLocation(
new HelpLocation(ToolConstants.TOOL_HELP_TOPIC, "ToolOptions_Dialog"));

View File

@@ -182,14 +182,23 @@ public class LaunchProperties {
*
* @param text The string to expand environment variables in
* @return The given string, but with set environment variables expanded
* @throws ParseException if there was a problem expanding an environment variable
*/
private static String expandEnvVars(String text) {
private static String expandEnvVars(String text) throws ParseException {
Map<String, String> envMap = System.getenv();
for (Entry<String, String> entry : envMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
text = text.replaceAll("\\$\\{" + key + "\\}", value.replace("\\", "\\\\"));
}
return text;
}
for (Entry<String, String> entry : envMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
try {
text = text.replaceAll("\\$\\{" + key + "\\}", value.replace("\\", "\\\\"));
}
catch (IllegalArgumentException e) {
throw new ParseException(
"Error expanding environment variable in %s (env %s=%s) -- %s".formatted(text,
key, value, e.getMessage()),
0);
}
}
return text;
}
}