mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Fixed tooltip usage in memory search widget
This commit is contained in:
parent
98b938cc65
commit
b4f7c920e6
3 changed files with 55 additions and 8 deletions
|
@ -304,7 +304,7 @@ class MemorySearchControlPanel extends JPanel {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DockingUtils.setTipWindowEnabled(false);
|
setMyToolTipsEnabled(false);
|
||||||
|
|
||||||
Point location = searchInputField.getLocation();
|
Point location = searchInputField.getLocation();
|
||||||
adjustLocationForCaretPosition(location);
|
adjustLocationForCaretPosition(location);
|
||||||
|
@ -326,7 +326,7 @@ class MemorySearchControlPanel extends JPanel {
|
||||||
|
|
||||||
private void clearInputError() {
|
private void clearInputError() {
|
||||||
errorMessage = null;
|
errorMessage = null;
|
||||||
DockingUtils.setTipWindowEnabled(true);
|
setMyToolTipsEnabled(true);
|
||||||
PopupWindow.hideAllWindows();
|
PopupWindow.hideAllWindows();
|
||||||
if (popup != null) {
|
if (popup != null) {
|
||||||
popup.dispose();
|
popup.dispose();
|
||||||
|
@ -336,6 +336,34 @@ class MemorySearchControlPanel extends JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setMyToolTipsEnabled(boolean enabled) {
|
||||||
|
|
||||||
|
if (!DockingUtils.isTipWindowEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolTipManager ttm = ToolTipManager.sharedInstance();
|
||||||
|
doSetMyToolTipsEnabled(this, ttm, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doSetMyToolTipsEnabled(JComponent c, ToolTipManager ttm, boolean enabled) {
|
||||||
|
|
||||||
|
if (enabled) {
|
||||||
|
ttm.registerComponent(c);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ttm.unregisterComponent(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
Component[] children = c.getComponents();
|
||||||
|
for (Component child : children) {
|
||||||
|
if (child instanceof JComponent) {
|
||||||
|
doSetMyToolTipsEnabled((JComponent) child, ttm, enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void updateCombo() {
|
private void updateCombo() {
|
||||||
ByteMatcher[] historyArray = searchHistory.getHistoryAsArray();
|
ByteMatcher[] historyArray = searchHistory.getHistoryAsArray();
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,8 @@ public class DockingUtils {
|
||||||
private static final KeyStroke REDO_KEYSTROKE =
|
private static final KeyStroke REDO_KEYSTROKE =
|
||||||
KeyStroke.getKeyStroke(KeyEvent.VK_Y, CONTROL_KEY_MODIFIER_MASK);
|
KeyStroke.getKeyStroke(KeyEvent.VK_Y, CONTROL_KEY_MODIFIER_MASK);
|
||||||
|
|
||||||
|
private static boolean globalTooltipsEnabled = true;
|
||||||
|
|
||||||
public static JSeparator createToolbarSeparator() {
|
public static JSeparator createToolbarSeparator() {
|
||||||
Dimension sepDim = new Dimension(2, ICON_SIZE + 2);
|
Dimension sepDim = new Dimension(2, ICON_SIZE + 2);
|
||||||
JSeparator separator = new JSeparator(SwingConstants.VERTICAL);
|
JSeparator separator = new JSeparator(SwingConstants.VERTICAL);
|
||||||
|
@ -355,19 +357,36 @@ public class DockingUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the application-wide Java tooltip enablement.
|
* Not meant for public consumption. This is for application code to control tooltips on
|
||||||
* @param enabled true if enabled; false prevents all Java tooltips
|
* behalf of the user.
|
||||||
|
* @param enabled true if enabled
|
||||||
*/
|
*/
|
||||||
public static void setTipWindowEnabled(boolean enabled) {
|
public static void setGlobalTooltipEnabledOption(boolean enabled) {
|
||||||
|
globalTooltipsEnabled = enabled;
|
||||||
Swing.runLater(() -> ToolTipManager.sharedInstance().setEnabled(enabled));
|
Swing.runLater(() -> ToolTipManager.sharedInstance().setEnabled(enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note: calling this method has no effect
|
||||||
|
* @param enabled true if enabled; false prevents all Java tooltips
|
||||||
|
* @deprecated this method is not longer supported; controlling application tooltips should be
|
||||||
|
* done through tool options in the UI
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "12")
|
||||||
|
public static void setTipWindowEnabled(boolean enabled) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if application-wide Java tooltips are enabled.
|
* Returns true if application-wide Java tooltips are enabled.
|
||||||
* @return true if application-wide Java tooltips are enabled.
|
* @return true if application-wide Java tooltips are enabled.
|
||||||
*/
|
*/
|
||||||
public static boolean isTipWindowEnabled() {
|
public static boolean isTipWindowEnabled() {
|
||||||
return Swing.runNow(() -> ToolTipManager.sharedInstance().isEnabled());
|
// Note: using this call would allow for client code to control tooltip enablement. We use
|
||||||
|
// tool options to control enablement, which is reflected in the boolean used below.
|
||||||
|
// return Swing.runNow(() -> ToolTipManager.sharedInstance().isEnabled());
|
||||||
|
|
||||||
|
return globalTooltipsEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Hides any open tooltip window */
|
/** Hides any open tooltip window */
|
||||||
|
|
|
@ -370,7 +370,7 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
|
||||||
AnimationUtils.setAnimationEnabled(animationEnabled);
|
AnimationUtils.setAnimationEnabled(animationEnabled);
|
||||||
|
|
||||||
boolean showToolTips = options.getBoolean(SHOW_TOOLTIPS_OPTION_NAME, true);
|
boolean showToolTips = options.getBoolean(SHOW_TOOLTIPS_OPTION_NAME, true);
|
||||||
DockingUtils.setTipWindowEnabled(showToolTips);
|
DockingUtils.setGlobalTooltipEnabledOption(showToolTips);
|
||||||
|
|
||||||
boolean compressDataBuffers =
|
boolean compressDataBuffers =
|
||||||
options.getBoolean(ENABLE_COMPRESSED_DATABUFFER_OUTPUT, false);
|
options.getBoolean(ENABLE_COMPRESSED_DATABUFFER_OUTPUT, false);
|
||||||
|
@ -397,7 +397,7 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
|
||||||
AnimationUtils.setAnimationEnabled((Boolean) newValue);
|
AnimationUtils.setAnimationEnabled((Boolean) newValue);
|
||||||
}
|
}
|
||||||
else if (SHOW_TOOLTIPS_OPTION_NAME.equals(optionName)) {
|
else if (SHOW_TOOLTIPS_OPTION_NAME.equals(optionName)) {
|
||||||
DockingUtils.setTipWindowEnabled((Boolean) newValue);
|
DockingUtils.setGlobalTooltipEnabledOption((Boolean) newValue);
|
||||||
}
|
}
|
||||||
else if (ENABLE_COMPRESSED_DATABUFFER_OUTPUT.equals(optionName)) {
|
else if (ENABLE_COMPRESSED_DATABUFFER_OUTPUT.equals(optionName)) {
|
||||||
DataBuffer.enableCompressedSerializationOutput((Boolean) newValue);
|
DataBuffer.enableCompressedSerializationOutput((Boolean) newValue);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue