GT-3103 - Look and Feel - fixed Linux Nimbus LaF issues with painting

tree row backgrounds
This commit is contained in:
dragonmacher 2019-08-23 14:11:38 -04:00
parent 0084a70f87
commit aa71d84620
6 changed files with 60 additions and 20 deletions

View file

@ -337,7 +337,6 @@ public class DataTypeArchiveGTree extends GTree {
// Background icon uses the label's color so set it to match the
// tree's background. Otherwise the icon's in the tree might have a
// different background and look odd.
label.setBackground(tree.getBackground());
MultiIcon multiIcon = new MultiIcon(new BackgroundIcon(ICON_WIDTH, ICON_HEIGHT, false));
Icon icon = getIcon();

View file

@ -19,7 +19,6 @@ import java.awt.Color;
import java.awt.Component;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.tree.TreePath;
import docking.widgets.tree.*;
@ -77,16 +76,13 @@ public class SymbolGTree extends GTree {
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean isSelected,
boolean expanded, boolean leaf, int row, boolean isFocused) {
JLabel label =
(JLabel) super.getTreeCellRendererComponent(tree, value, isSelected, expanded,
leaf, row, isFocused);
JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, value, isSelected,
expanded, leaf, row, isFocused);
if (label.getIcon() == null) {
label.setIcon(expanded ? OPEN_FOLDER_GROUP_ICON : CLOSED_FOLDER_GROUP_ICON);
}
label.setBorder(new EmptyBorder(1, 0, 0, 0)); // Force row padding
if (!isSelected && (value instanceof SymbolNode)) {
SymbolNode node = (SymbolNode) value;
Symbol symbol = node.getSymbol();

View file

@ -41,10 +41,6 @@ public class GTreeRenderer extends DefaultTreeCellRenderer implements GComponent
setHTMLRenderingEnabled(false);
}
/**
*
* @see javax.swing.tree.DefaultTreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
*/
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected1,
boolean expanded, boolean leaf, int row, boolean hasFocus1) {
@ -56,6 +52,9 @@ public class GTreeRenderer extends DefaultTreeCellRenderer implements GComponent
setText(text);
setToolTipText(node.getToolTip());
setOpaque(true);
setBackground(selected1 ? getBackgroundSelectionColor() : getBackgroundNonSelectionColor());
Icon icon = node.getIcon(expanded);
if (icon == null) {
icon = getIcon();

View file

@ -15,9 +15,9 @@
*/
package ghidra.docking.util;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.*;
import java.util.*;
import java.util.List;
import java.util.Map.Entry;
import javax.swing.*;
@ -206,10 +206,40 @@ public class DockingWindowsLookAndFeelUtils {
// This fix looks like it should not cause harm even if the bug is fixed on the jdk side.
UIDefaults defaults = lookAndFeel.getDefaults();
defaults.put("ScrollBar.minimumThumbSize", new Dimension(30, 30));
UIDefaults lafd = UIManager.getLookAndFeelDefaults();
Painter<JComponent> painterStub = new Painter<>() {
@Override
public void paint(Graphics2D g, JComponent c, int width, int height) {
// stub
}
};
// (see NimbusDefaults for key values)
// These settings disable tree row selection; when enable each tree row paints its
// selection independently from the renderer
lafd.put("Tree:TreeCell[Enabled+Selected].backgroundPainter", painterStub);
lafd.put("Tree:TreeCell[Focused+Selected].backgroundPainter", painterStub);
// These settings force the tree arrow icon painting to use the non-selected
// color. We need this since we disabled the row selection painting above.
swapPainters(lafd, "Tree[Enabled].collapsedIconPainter",
"Tree[Enabled+Selected].collapsedIconPainter");
swapPainters(lafd, "Tree[Enabled].expandedIconPainter",
"Tree[Enabled+Selected].expandedIconPainter");
break;
}
}
private static void swapPainters(UIDefaults lafd, String from, String to) {
@SuppressWarnings("unchecked")
Painter<JComponent> newPainter = (Painter<JComponent>) lafd.get(from);
lafd.put(to, newPainter);
}
private static void installGlobalLookAndFeelAttributes() {
// Fix up the default fonts that Java 1.5.0 changed to Courier, which looked terrible.
Font f = new Font("Monospaced", Font.PLAIN, 12);

View file

@ -64,7 +64,8 @@ import ghidra.framework.plugintool.Plugin;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.*;
import ghidra.framework.preferences.Preferences;
import ghidra.framework.project.tool.*;
import ghidra.framework.project.tool.GhidraTool;
import ghidra.framework.project.tool.GhidraToolTemplate;
import ghidra.util.*;
import ghidra.util.bean.GGlassPane;
import ghidra.util.classfinder.ClassSearcher;
@ -108,6 +109,7 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
private static final String FRONT_END_TOOL_XML_NAME = "FRONTEND";
private static final String FRONT_END_FILE_NAME = "FrontEndTool.xml";
private static final String CONFIGURE_GROUP = "Configure";
private WeakSet<ProjectListener> listeners;
private FrontEndPlugin plugin;
@ -316,8 +318,9 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
}
/**
* NOTE: do not call this from a non-Swing thread.
* NOTE: do not call this from a non-Swing thread
*
* @param tool the tool
* @return true if the repository is null or is connected.
*/
boolean checkRepositoryConnected(PluginTool tool) {
@ -511,6 +514,7 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
}
private void addManageExtensionsAction() {
DockingAction installExtensionsAction = new DockingAction("Extensions", "Project Window") {
@Override
public void actionPerformed(ActionContext context) {
@ -524,8 +528,11 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
return isConfigurable();
}
};
installExtensionsAction.setMenuBarData(new MenuData(
new String[] { ToolConstants.MENU_FILE, "Install Extensions..." }, null, "Extensions"));
MenuData menuData =
new MenuData(new String[] { ToolConstants.MENU_FILE, "Install Extensions..." }, null,
CONFIGURE_GROUP);
menuData.setMenuSubGroup(CONFIGURE_GROUP + 2);
installExtensionsAction.setMenuBarData(menuData);
installExtensionsAction.setHelpLocation(
new HelpLocation(GenericHelpTopics.FRONT_END, "Extensions"));
@ -548,8 +555,11 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
return isConfigurable();
}
};
configureToolAction.setMenuBarData(new MenuData(
new String[] { ToolConstants.MENU_FILE, "Configure..." }, null, "Configure"));
MenuData menuData = new MenuData(new String[] { ToolConstants.MENU_FILE, "Configure..." },
null, CONFIGURE_GROUP);
menuData.setMenuSubGroup(CONFIGURE_GROUP + 1);
configureToolAction.setMenuBarData(menuData);
configureToolAction.setHelpLocation(
new HelpLocation(GenericHelpTopics.FRONT_END, "Configure"));
@ -685,7 +695,7 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
/**
* Get the int value for the given string.
*
* @param value
* @param value the string value to parse
* @param defaultValue return this value if a NumberFormatException is
* thrown during the parseInt() method
*/

View file

@ -161,6 +161,12 @@ public class GhidraLauncher {
}
}
}
if (pathSet.isEmpty()) {
throw new IllegalStateException(
"Files listed in '" + LIBDEPS + "' are incorrect--rebuild this file");
}
pathList.addAll(pathSet);
}