mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-02-18 00:20:10 +00:00
GP-4108 - Menu icons not appearing when disabled
This commit is contained in:
parent
14de932149
commit
4fcaeead0f
@ -303,7 +303,11 @@ public abstract class DockingAction implements DockingActionIf {
|
||||
String text = menuData.getMenuItemName();
|
||||
String trimmed = StringUtilities.trimMiddle(text, 50);
|
||||
menuItem.setText(trimmed);
|
||||
menuItem.setIcon(menuData.getMenuIcon());
|
||||
Icon icon = menuData.getMenuIcon();
|
||||
menuItem.setIcon(icon);
|
||||
if (icon != null) {
|
||||
menuItem.setDisabledIcon(ResourceManager.getDisabledIcon(icon));
|
||||
}
|
||||
menuItem.setMnemonic(menuData.getMnemonic());
|
||||
}
|
||||
else {
|
||||
|
@ -15,16 +15,15 @@
|
||||
*/
|
||||
package docking.menu;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.MenuItemUI;
|
||||
|
||||
/**
|
||||
* Overrides the painting behavior of the BasicCheckBoxMenuItemUI
|
||||
*/
|
||||
|
||||
public class DockingCheckboxMenuItemUI extends DockingMenuItemUI {
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
public static DockingCheckboxMenuItemUI createUI(JComponent c) {
|
||||
DockingCheckboxMenuItemUI result = new DockingCheckboxMenuItemUI();
|
||||
result.ui = (MenuItemUI) UIManager.getDefaults().getUI(c);
|
||||
return result;
|
||||
|
@ -35,17 +35,17 @@ import docking.util.GraphicsUtils;
|
||||
|
||||
/**
|
||||
* This class exists to make menu items display content with proper alignment whether or not
|
||||
* they are displaying an icon. That is, this class will introduce padding for absent icons
|
||||
* they are displaying an icon. That is, this class will introduce padding for absent icons
|
||||
* within menu items so that the item lines up with those items that do contain icons.
|
||||
* <p>
|
||||
* This class has an additional feature that allows clients to display menu item content in a
|
||||
* tabular fashion. A menu item using this UI can contain some combination of the of the following
|
||||
* items, in the given order:
|
||||
* items, in the given order:
|
||||
* <pre>
|
||||
* [Checkbox][Icon][Menu Item Content][Menu Pull-right/Accelerator Text]
|
||||
* </pre>
|
||||
* To display the <b>Menu Item Content</b> in a tabular fashion, use the <code>'\t'</code> character
|
||||
* to delimit the data into columns. This class will align all menu items in the given menu
|
||||
* To display the <b>Menu Item Content</b> in a tabular fashion, use the <code>'\t'</code> character
|
||||
* to delimit the data into columns. This class will align all menu items in the given menu
|
||||
* based upon the largest number of columns in the group and the largest width for each column.
|
||||
*/
|
||||
public class DockingMenuItemUI extends MenuItemUI {
|
||||
@ -170,7 +170,7 @@ public class DockingMenuItemUI extends MenuItemUI {
|
||||
}
|
||||
|
||||
public static class MenuTabulator {
|
||||
private ArrayList<Integer> columns = new ArrayList<Integer>();
|
||||
private ArrayList<Integer> columns = new ArrayList<>();
|
||||
|
||||
public static MenuTabulator tabulate(JMenuItem c) {
|
||||
MenuTabulator tabulator = get(c);
|
||||
|
@ -15,12 +15,12 @@
|
||||
*/
|
||||
package docking.menu;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.MenuItemUI;
|
||||
|
||||
public class DockingMenuUI extends DockingMenuItemUI {
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
public static DockingMenuUI createUI(JComponent c) {
|
||||
DockingMenuUI result = new DockingMenuUI();
|
||||
result.ui = (MenuItemUI) UIManager.getDefaults().getUI(c);
|
||||
return result;
|
||||
|
@ -20,8 +20,7 @@ import java.awt.event.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
import javax.swing.ButtonModel;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import docking.ActionContext;
|
||||
@ -29,6 +28,7 @@ import docking.DefaultActionContext;
|
||||
import docking.action.*;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.StringUtilities;
|
||||
import resources.ResourceManager;
|
||||
|
||||
/**
|
||||
* Class to manage a JMenuItem for an action. Handles property changes in the action
|
||||
@ -184,7 +184,11 @@ class MenuItemManager implements ManagedMenuItem, PropertyChangeListener, Action
|
||||
String text = menuData.getMenuItemName();
|
||||
String trimmed = StringUtilities.trimMiddle(text, 50);
|
||||
menuItem.setText(trimmed);
|
||||
menuItem.setIcon(menuData.getMenuIcon());
|
||||
Icon menuIcon = menuData.getMenuIcon();
|
||||
menuItem.setIcon(menuIcon);
|
||||
if (menuIcon != null) {
|
||||
menuItem.setDisabledIcon(ResourceManager.getDisabledIcon(menuIcon));
|
||||
}
|
||||
menuItem.setMnemonic(menuData.getMnemonic());
|
||||
menuItem.revalidate();
|
||||
}
|
||||
|
@ -164,10 +164,10 @@ public class MultipleActionDockingToolbarButton extends EmptyBorderButton {
|
||||
// 1) show a popup if it was not showing
|
||||
// 2) hide the popup if it was showing
|
||||
//
|
||||
// Case 2 requires timestamps. Java will close the popup as the button is clicked. This
|
||||
// means that when we are told to show the popup as the result of a click, the popup will
|
||||
// never be showing. To work around this, we track the elapsed time since last click. If
|
||||
// the period is too short, then we assume Java closed the popup when the click happened
|
||||
// Case 2 requires timestamps. Java will close the popup as the button is clicked. This
|
||||
// means that when we are told to show the popup as the result of a click, the popup will
|
||||
// never be showing. To work around this, we track the elapsed time since last click. If
|
||||
// the period is too short, then we assume Java closed the popup when the click happened
|
||||
//and thus we should ignore it.
|
||||
//
|
||||
long elapsedTime = System.currentTimeMillis() - popupLastClosedTime;
|
||||
@ -187,7 +187,7 @@ public class MultipleActionDockingToolbarButton extends EmptyBorderButton {
|
||||
}
|
||||
|
||||
// a custom Ghidra UI that handles alignment issues and allows for tabulating presentation
|
||||
item.setUI((DockingMenuItemUI) DockingMenuItemUI.createUI(item));
|
||||
item.setUI(DockingMenuItemUI.createUI(item));
|
||||
final DockingActionIf delegateAction = dockingAction;
|
||||
item.addActionListener(e -> {
|
||||
ActionContext context = getActionContext();
|
||||
|
@ -1401,8 +1401,8 @@ public class ClipboardPluginTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
Point point = wrapper.getStartMouseDragLocation();
|
||||
int startX = point.x;
|
||||
int startY = point.y;
|
||||
|
||||
Point endPoint = wrapper.getEndMouseDragLocation();
|
||||
|
||||
int endX = endPoint.x;
|
||||
int endY = endPoint.y;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user