Ghidra is a software reverse engineering (SRE) framework
Theming - Fixed clients that want empty viewport space to match the parent panel color
dragonmacher4f1866d4cc83
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/BitFieldEditorPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/BitFieldEditorPanel.javaindex 5059e982ef..859c73e76f 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/BitFieldEditorPanel.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/BitFieldEditorPanel.java@@ -21,7 +21,6 @@ import java.awt.event.*;import javax.swing.*;import javax.swing.event.CellEditorListener;import javax.swing.event.ChangeEvent;-import javax.swing.plaf.UIResource;import com.google.common.base.Predicate;@@ -33,6 +32,7 @@ import docking.widgets.button.GButton;import docking.widgets.label.GDLabel;import generic.theme.GIcon;import generic.theme.GThemeDefaults.Colors.Messages;+import generic.theme.GThemeDefaults.Colors.Viewport;import ghidra.app.plugin.core.compositeeditor.BitFieldPlacementComponent.BitAttributes;import ghidra.app.plugin.core.compositeeditor.BitFieldPlacementComponent.BitFieldAllocation;import ghidra.app.services.DataTypeManagerService;@@ -467,12 +467,7 @@ public class BitFieldEditorPanel extends JPanel {new JScrollPane(placementComponent, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);- Color bg = getBackground();- if (bg instanceof UIResource) {- // Nimbus does not honor the color if it is a UIResource- bg = new Color(bg.getRGB());- }- scrollPane.getViewport().setBackground(bg);+ scrollPane.getViewport().setBackground(Viewport.UNEDITABLE_BACKGROUND);scrollPane.setBorder(null);bitViewPanel.add(scrollPane);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompEditorPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompEditorPanel.javaindex d2ddcbd9dc..89640b4614 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompEditorPanel.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompEditorPanel.java@@ -31,6 +31,7 @@ import docking.widgets.button.GRadioButton;import docking.widgets.fieldpanel.support.FieldSelection;import docking.widgets.label.GDLabel;import generic.theme.GThemeDefaults.Colors.Palette;+import generic.theme.GThemeDefaults.Colors.Viewport;import ghidra.app.plugin.core.compositeeditor.BitFieldPlacementComponent.BitAttributes;import ghidra.program.model.data.*;import ghidra.program.model.data.Composite;@@ -89,7 +90,7 @@ public class CompEditorPanel extends CompositeEditorPanel {/*** Constructor for a panel that has a blank line in unlocked mode and* composite name and description that are editable.- *+ ** @param model* the model for editing the composite data type* @param provider@@ -222,7 +223,7 @@ public class CompEditorPanel extends CompositeEditorPanel {new JScrollPane(bitViewComponent, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);- bitViewScrollPane.getViewport().setBackground(getBackground());+ bitViewScrollPane.getViewport().setBackground(Viewport.UNEDITABLE_BACKGROUND);bitViewScrollPane.setBorder(null);// establish default preferred size of panel based upon fixed preferred height of bitViewComponent@@ -237,7 +238,7 @@ public class CompEditorPanel extends CompositeEditorPanel {* Create the Info Panel that is horizontally resizable. The panel contains* the name, category, data type, size, and edit mode for the current* structure in the editor.- *+ ** @return JPanel the completed composite data type information panel*/@Override@@ -350,8 +351,8 @@ public class CompEditorPanel extends CompositeEditorPanel {@Overridepublic Dimension getPreferredSize() {- // make sure our preferred size accounts for that of our components that the user- // may choose to show+ // make sure our preferred size accounts for that of our components that the user+ // may choose to showDimension preferredSize = super.getPreferredSize();if (alignPanel.isShowing()) {return preferredSize;@@ -395,9 +396,8 @@ public class CompEditorPanel extends CompositeEditorPanel {String alignmentToolTip ="<HTML>The <B>align</B> control allows the overall minimum alignment of this<BR>" +"data type to be specified. The actual computed alignment<BR>" +- "may be any multiple of this value. " +- "<font color=\"" + Palette.BLUE.toHexString() +- "\" size=\"-2\">(<F1> for help)</HTML>";+ "may be any multiple of this value. " + "<font color=\"" ++ Palette.BLUE.toHexString() + "\" size=\"-2\">(<F1> for help)</HTML>";alignPanel.setToolTipText(alignmentToolTip);addMinimumAlignmentComponents();@@ -449,11 +449,10 @@ public class CompEditorPanel extends CompositeEditorPanel {private void setupDefaultMinAlignButton() {defaultAlignButton.setName("Default Alignment");- String alignmentToolTip =- "<HTML>Sets this data type to use <B>default</B> alignment.<BR>" +- "If packing is disabled, the default will be 1 byte. If packing<BR>" +- "is enabled, the alignment is computed based upon the pack<BR>" +- "setting and the alignment of each component data type.</HTML>";+ String alignmentToolTip = "<HTML>Sets this data type to use <B>default</B> alignment.<BR>" ++ "If packing is disabled, the default will be 1 byte. If packing<BR>" ++ "is enabled, the alignment is computed based upon the pack<BR>" ++ "setting and the alignment of each component data type.</HTML>";defaultAlignButton.addActionListener(e -> {((CompEditorModel) model).setAlignmentType(AlignmentType.DEFAULT, -1);@@ -461,8 +460,8 @@ public class CompEditorPanel extends CompositeEditorPanel {defaultAlignButton.setToolTipText(alignmentToolTip);if (helpManager != null) {- helpManager.registerHelp(defaultAlignButton, new HelpLocation(- provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));+ helpManager.registerHelp(defaultAlignButton,+ new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));}}@@ -480,8 +479,8 @@ public class CompEditorPanel extends CompositeEditorPanel {});if (helpManager != null) {- helpManager.registerHelp(machineAlignButton, new HelpLocation(- provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));+ helpManager.registerHelp(machineAlignButton,+ new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));}}@@ -498,8 +497,8 @@ public class CompEditorPanel extends CompositeEditorPanel {});if (helpManager != null) {- helpManager.registerHelp(explicitAlignButton, new HelpLocation(- provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));+ helpManager.registerHelp(explicitAlignButton,+ new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));}explicitAlignTextField.setName("Explicit Alignment Value");@@ -524,8 +523,8 @@ public class CompEditorPanel extends CompositeEditorPanel {explicitAlignTextField.setToolTipText(alignmentToolTip);if (helpManager != null) {- helpManager.registerHelp(explicitAlignTextField, new HelpLocation(- provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));+ helpManager.registerHelp(explicitAlignTextField,+ new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Align"));}refreshGUIMinimumAlignmentValue(); // Display the initial value.@@ -620,8 +619,8 @@ public class CompEditorPanel extends CompositeEditorPanel {packingGroup.add(explicitPackingButton);if (helpManager != null) {- helpManager.registerHelp(packingPanel, new HelpLocation(provider.getHelpTopic(),- provider.getHelpName() + "_" + "Pack"));+ helpManager.registerHelp(packingPanel,+ new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Pack"));}addPackingComponents(innerPanel);@@ -674,8 +673,7 @@ public class CompEditorPanel extends CompositeEditorPanel {packingEnablementButton.setName("Packing Enablement");String packingToolTipText ="<HTML>Enable packing when details of all components are known (including sizing and" +- " alignment).<BR>" +- "Disable packing when Reverse Engineering composite. " ++ " alignment).<BR>" + "Disable packing when Reverse Engineering composite. " +"<font color=\"" + Palette.BLUE.toHexString() +"\" size=\"-2\">(<F1> for help)</font></HTML>";packingEnablementButton.addActionListener(e -> {@@ -702,8 +700,8 @@ public class CompEditorPanel extends CompositeEditorPanel {defaultPackingButton.setToolTipText(packingToolTipText);if (helpManager != null) {- helpManager.registerHelp(defaultPackingButton, new HelpLocation(provider.getHelpTopic(),- provider.getHelpName() + "_" + "Pack"));+ helpManager.registerHelp(defaultPackingButton,+ new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Pack"));}}@@ -716,8 +714,7 @@ public class CompEditorPanel extends CompositeEditorPanel {explicitPackingButton.setToolTipText(packingToolTipText);if (helpManager != null) {helpManager.registerHelp(explicitPackingButton,- new HelpLocation(provider.getHelpTopic(),- provider.getHelpName() + "_" + "Pack"));+ new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Pack"));}explicitPackingTextField.setName("Packing Value");@@ -742,8 +739,8 @@ public class CompEditorPanel extends CompositeEditorPanel {explicitPackingTextField.setToolTipText(packingToolTipText);if (helpManager != null) {- helpManager.registerHelp(explicitPackingTextField, new HelpLocation(- provider.getHelpTopic(), provider.getHelpName() + "_" + "Pack"));+ helpManager.registerHelp(explicitPackingTextField,+ new HelpLocation(provider.getHelpTopic(), provider.getHelpName() + "_" + "Pack"));}}@@ -979,8 +976,7 @@ public class CompEditorPanel extends CompositeEditorPanel {if (viewComposite.isPackingEnabled()) {defaultValue = viewComposite.getDataOrganization().getMachineAlignment();}- ((CompEditorModel) model).setAlignmentType(AlignmentType.EXPLICIT,- defaultValue);+ ((CompEditorModel) model).setAlignmentType(AlignmentType.EXPLICIT, defaultValue);}explicitAlignTextField.selectAll();explicitAlignTextField.requestFocus();@@ -1072,7 +1068,7 @@ public class CompEditorPanel extends CompositeEditorPanel {/*** Sets the currently displayed structure category name.- *+ ** @param name* the new category name*/@@ -1090,7 +1086,7 @@ public class CompEditorPanel extends CompositeEditorPanel {/*** Sets the currently displayed structure name in the edit area.- *+ ** @param name* the new name*/@@ -1115,7 +1111,7 @@ public class CompEditorPanel extends CompositeEditorPanel {/*** Sets the currently displayed structure description.- *+ ** @param description* the new description*/@@ -1164,7 +1160,7 @@ public class CompEditorPanel extends CompositeEditorPanel {/*** Sets the currently displayed composite's size.- *+ ** @param size the new size*/public void setCompositeSize(int size) {diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/editor/FunctionEditorDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/editor/FunctionEditorDialog.javaindex bde43ea7e2..0d5d275fd2 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/editor/FunctionEditorDialog.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/editor/FunctionEditorDialog.java@@ -39,7 +39,6 @@ import docking.widgets.label.GLabel;import docking.widgets.table.*;import generic.theme.GIcon;import generic.theme.GThemeDefaults.Colors;-import generic.theme.GThemeDefaults.Colors.Palette;import generic.util.WindowUtilities;import ghidra.app.services.DataTypeManagerService;import ghidra.app.util.ToolTipUtils;@@ -228,9 +227,6 @@ public class FunctionEditorDialog extends DialogComponentProvider implements Modscroll = new JScrollPane(verticalScrollPanel);scroll.setBorder(null);scroll.setOpaque(true);- scroll.setBackground(Colors.BACKGROUND);- scroll.getViewport().setBackground(Palette.NO_COLOR); // transparent- scroll.getViewport().setBackground(Colors.BACKGROUND);previewPanel.add(scroll, BorderLayout.CENTER);previewPanel.setBorder(BorderFactory.createLoweredBevelBorder());scroll.getViewport().addMouseListener(new MouseAdapter() {diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.javaindex 38aa0c0c54..540710298a 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusComponentProvider.java@@ -122,7 +122,6 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {filterPanel = new GTableFilterPanel<>(bundleStatusTable, bundleStatusTableModel);JScrollPane scrollPane = new JScrollPane(bundleStatusTable);- scrollPane.getViewport().setBackground(bundleStatusTable.getBackground());panel.add(filterPanel, BorderLayout.SOUTH);panel.add(scrollPane, BorderLayout.CENTER);@@ -159,8 +158,8 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {addBundlesAction("DisableBundles", "Disable selected bundle(s)",new GIcon("icon.plugin.bundlemanager.disable"), this::doDisableBundles);- addBundlesAction("CleanBundles", "Clean selected bundle build cache(s)",- Icons.CLEAR_ICON, this::doCleanBundleBuildCaches);+ addBundlesAction("CleanBundles", "Clean selected bundle build cache(s)", Icons.CLEAR_ICON,+ this::doCleanBundleBuildCaches);icon = Icons.ADD_ICON;new ActionBuilder("AddBundles", this.getName()).popupMenuPath("Add bundle(s)")diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/pathmanager/PathManager.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/pathmanager/PathManager.javaindex 29dd4d131f..602c0d01f9 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/pathmanager/PathManager.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/pathmanager/PathManager.java@@ -239,7 +239,6 @@ public class PathManager {});JScrollPane scrollPane = new JScrollPane(pathTable);- scrollPane.getViewport().setBackground(pathTable.getBackground());ListSelectionModel selModel = pathTable.getSelectionModel();selModel.addListSelectionListener(e -> {diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/pathmanager/PathnameTablePanel.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/pathmanager/PathnameTablePanel.javaindex 40360789d8..48c4935c95 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/pathmanager/PathnameTablePanel.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/pathmanager/PathnameTablePanel.java@@ -64,7 +64,7 @@ public class PathnameTablePanel extends JPanel {/*** Construct a new PathnameTablePanel.- *+ ** @param paths list of paths to show; may be null* @param enableEdits true to allow editing of entries <em>directly in the table</em>, i.e., via* the cell editor. The add and remove buttons still allow modification of the list.@@ -85,7 +85,7 @@ public class PathnameTablePanel extends JPanel {/*** Construct a new PathnameTablePanel with a reset button- *+ ** @param paths list of paths to show; may be null* @param resetCallback callback containing the action to perform if the reset button is pressed* @param enableEdits true to allow editing of entries <em>directly in the table</em>, i.e., via@@ -108,7 +108,7 @@ public class PathnameTablePanel extends JPanel {/*** Set properties on the file chooser that is displayed when the "Add" button is pressed.- *+ ** @param title title of the file chooser* @param preferenceForLastSelectedDir Preference to use as the current directory in the file* chooser@@ -129,7 +129,7 @@ public class PathnameTablePanel extends JPanel {/*** Set whether the entries in the table can be edited.- *+ ** @param enableEdits false means to not allow editing; the table is editable by default.*/public void setEditingEnabled(boolean enableEdits) {@@ -139,7 +139,7 @@ public class PathnameTablePanel extends JPanel {/*** Set whether new paths should be added to the top of the table (true) or at the end of the* table (false).- *+ ** @param addToTop true means to add to the top of the table*/public void setAddToTop(boolean addToTop) {@@ -148,13 +148,13 @@ public class PathnameTablePanel extends JPanel {/*** Set whether the order of entries in the table matters.- *+ ** <p>* <b>WARNING:</b> When this is set to false, the entries are immediately sorted and the up and* down buttons removed. Setting it back to true will replace the buttons, but will <em>not</em>* restore the order. In general, this should be set once, at the start of the table's life* cycle.- *+ ** @param ordered true means the user can control the order, false means they cannot.*/public void setOrdered(boolean ordered) {@@ -232,7 +232,6 @@ public class PathnameTablePanel extends JPanel {pathnameTable.setTableHeader(null);pathnameTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);JScrollPane scrollPane = new JScrollPane(pathnameTable);- scrollPane.getViewport().setBackground(pathnameTable.getBackground());setDefaultCellRenderer();diff --git a/Ghidra/Framework/Gui/src/main/java/generic/theme/GThemeDefaults.java b/Ghidra/Framework/Gui/src/main/java/generic/theme/GThemeDefaults.javaindex 53c6921130..f4afb3dece 100644--- a/Ghidra/Framework/Gui/src/main/java/generic/theme/GThemeDefaults.java+++ b/Ghidra/Framework/Gui/src/main/java/generic/theme/GThemeDefaults.java@@ -19,6 +19,9 @@ import static generic.theme.SystemThemeIds.*;import java.awt.Color;+import javax.swing.JPanel;+import javax.swing.JViewport;+/*** This class contains many suitable default values for commonly used concepts. See each static* class below.@@ -88,6 +91,19 @@ public class GThemeDefaults {//@formatter:on}+ public static class Viewport {+ //@formatter:off+ /**+ * By default the system {@link JViewport}s use BACKGROUND for their background, which+ * is the primary background color (typically white on light themes). Some clients+ * would like the background color to match the uneditable background color used by+ * {@link JPanel}. This color allows the empty space in the viewport to match the+ * parent panel color.+ */+ public static final GColor UNEDITABLE_BACKGROUND = new GColor("laf.color.Panel.background");+ //@formatter:on+ }+/*** Color values to use with tooltips*/diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/ManagePluginsDialog.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/ManagePluginsDialog.javaindex bf28134df4..1a4c52a9a3 100644--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/ManagePluginsDialog.java+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/ManagePluginsDialog.java@@ -25,7 +25,6 @@ import docking.action.*;import docking.tool.ToolConstants;import docking.widgets.OptionDialog;import generic.theme.GIcon;-import generic.theme.GThemeDefaults.Colors;import ghidra.app.util.GenericHelpTopics;import ghidra.framework.main.AppInfo;import ghidra.framework.plugintool.PluginConfigurationModel;@@ -56,7 +55,6 @@ public class ManagePluginsDialog extends ReusableDialogComponentProvider {this.pluginConfigurationModel = pluginConfigurationModel;pluginComponent = new PluginManagerComponent(tool, pluginConfigurationModel);JScrollPane scrollPane = new JScrollPane(pluginComponent);- scrollPane.getViewport().setBackground(Colors.BACKGROUND);scrollPane.getViewport().setViewPosition(new Point(0, 0));addWorkPanel(scrollPane);createActions(addSaveActions);diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/PluginInstallerDialog.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/PluginInstallerDialog.javaindex 1c49721a1b..2c4c202252 100644--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/PluginInstallerDialog.java+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/PluginInstallerDialog.java@@ -149,7 +149,6 @@ public class PluginInstallerDialog extends DialogComponentProvider {tableFilterPanel = new GTableFilterPanel<>(table, tableModel);JScrollPane sp = new JScrollPane(table);- sp.getViewport().setBackground(table.getBackground());pluginTablePanel.add(sp, BorderLayout.CENTER);pluginTablePanel.add(tableFilterPanel, BorderLayout.SOUTH);@@ -203,7 +202,6 @@ public class PluginInstallerDialog extends DialogComponentProvider {private class StatusCellRenderer extends GTableCellRenderer {public StatusCellRenderer() {- super();setHorizontalAlignment(SwingConstants.CENTER);}diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/project/extensions/ExtensionTablePanel.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/project/extensions/ExtensionTablePanel.javaindex b907364944..5afd16e6a5 100644--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/project/extensions/ExtensionTablePanel.java+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/project/extensions/ExtensionTablePanel.java@@ -41,7 +41,7 @@ public class ExtensionTablePanel extends JPanel {/*** Constructor; builds the panel and sets table attributes.- *+ ** @param tool the tool showing the extension dialog*/public ExtensionTablePanel(PluginTool tool) {@@ -56,7 +56,6 @@ public class ExtensionTablePanel extends JPanel {table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);JScrollPane sp = new JScrollPane(table);- sp.getViewport().setBackground(table.getBackground());add(sp, BorderLayout.CENTER);tableFilterPanel = new GTableFilterPanel<>(table, tableModel);@@ -98,7 +97,7 @@ public class ExtensionTablePanel extends JPanel {/*** Returns the filter panel.- *+ ** @return the filter panel*/public GTableFilterPanel<ExtensionDetails> getFilterPanel() {@@ -107,7 +106,7 @@ public class ExtensionTablePanel extends JPanel {/*** Replaces the contents of the table with the given list of extensions.- *+ ** @param extensions the new model data*/public void setExtensions(Set<ExtensionDetails> extensions) {