Merge remote-tracking branch 'origin/GP-1-dragonmacher-ui-border-bug'

This commit is contained in:
Ryan Kurtz 2024-10-17 05:58:39 -04:00
commit 35910a36de
3 changed files with 35 additions and 24 deletions

View File

@ -24,6 +24,7 @@ import java.awt.event.*;
import java.util.List;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.text.DefaultFormatterFactory;
@ -36,6 +37,7 @@ import docking.widgets.label.GDLabel;
import docking.widgets.textfield.GFormattedTextField;
import generic.theme.GThemeDefaults.Colors.Palette;
import generic.theme.GThemeDefaults.Colors.Viewport;
import generic.theme.Gui;
import ghidra.app.plugin.core.compositeeditor.BitFieldPlacementComponent.BitAttributes;
import ghidra.program.model.data.*;
import ghidra.program.model.data.Composite;
@ -695,9 +697,19 @@ public class CompEditorPanel extends CompositeEditorPanel {
packingPanel.add(packingEnablementButton);
JPanel innerPanel = new JPanel(new GridBagLayout());
innerPanel.setBorder(UIManager.getBorder("TitledBorder.border"));
Border titledBorder = UIManager.getBorder("TitledBorder.border");
innerPanel.setBorder(titledBorder);
packingPanel.add(innerPanel);
// Since we set the border manually, it does not get updated when switching LaFs. Add a
// theme listener to update the border ourselves.
Gui.addThemeListener(e -> {
if (e.isLookAndFeelChanged()) {
Border updatedTitledBorder = UIManager.getBorder("TitledBorder.border");
innerPanel.setBorder(updatedTitledBorder);
}
});
setupDefaultPackingButton();
setupExplicitPackingButtonAndTextField();
setupPackingEnablementButton();

View File

@ -31,11 +31,13 @@ import ghidra.framework.plugintool.Plugin;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.Program;
import ghidra.util.HelpLocation;
import ghidra.util.SystemUtilities;
import ghidra.util.datastruct.WeakDataStructureFactory;
import ghidra.util.datastruct.WeakSet;
import ghidra.util.exception.AssertException;
import help.Help;
import help.HelpService;
import utilities.util.reflection.ReflectionUtilities;
/**
* Editor provider for a Composite Data Type.
@ -335,8 +337,22 @@ public abstract class CompositeEditorProvider extends ComponentProviderAdapter
}
protected void registerHelp(Object object, String anchor) {
String inception = recordHelpInception();
HelpService help = Help.getHelpService();
help.registerHelp(object, new HelpLocation(getHelpTopic(), getHelpName() + "_" + anchor));
String fullAnchor = getHelpName() + "_" + anchor;
help.registerHelp(object, new HelpLocation(getHelpTopic(), fullAnchor, inception));
}
private String recordHelpInception() {
if (!SystemUtilities.isInDevelopmentMode()) {
return "";
}
return getInceptionFromTheFirstClassThatIsNotUsOrABuilder();
}
protected String getInceptionFromTheFirstClassThatIsNotUsOrABuilder() {
Throwable t = ReflectionUtilities.createThrowableWithStackOlderThan("registerHelp");
return t.getStackTrace()[0].toString();
}
protected void requestTableFocus() {

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.
@ -27,8 +27,8 @@ import docking.DockingUtils;
import docking.action.*;
import docking.widgets.checkbox.GCheckBox;
import docking.widgets.label.GLabel;
import docking.widgets.table.*;
import docking.widgets.table.threaded.ThreadedTableModel;
import docking.widgets.table.GTableCellRenderer;
import docking.widgets.table.GTableCellRenderingData;
import docking.widgets.textfield.IntegerTextField;
import generic.theme.GIcon;
import ghidra.app.util.HelpTopics;
@ -488,27 +488,10 @@ public class StringTableProvider extends ComponentProviderAdapter implements Dom
}
}
private class StringTable extends GhidraTable {
public StringTable(ThreadedTableModel<FoundString, ?> model) {
super(model);
}
// @Override
// protected <T> SelectionManager createSelectionManager(TableModel tableModel) {
// return null;
// }
}
private JComponent buildTablePanel() {
stringModel = new StringTableModel(tool, options);
threadedTablePanel = new GhidraThreadedTablePanel<>(stringModel, 1000) {
@Override
protected GTable createTable(ThreadedTableModel<FoundString, ?> model) {
return new StringTable(model);
}
};
threadedTablePanel = new GhidraThreadedTablePanel<>(stringModel, 1000);
table = threadedTablePanel.getTable();
table.setActionsEnabled(true);
table.setName("DataTable");