Fixed tooltip usage in memory search widget

This commit is contained in:
dragonmacher 2025-08-18 16:36:08 -04:00
parent 98b938cc65
commit b4f7c920e6
3 changed files with 55 additions and 8 deletions

View file

@ -304,7 +304,7 @@ class MemorySearchControlPanel extends JPanel {
return;
}
DockingUtils.setTipWindowEnabled(false);
setMyToolTipsEnabled(false);
Point location = searchInputField.getLocation();
adjustLocationForCaretPosition(location);
@ -326,7 +326,7 @@ class MemorySearchControlPanel extends JPanel {
private void clearInputError() {
errorMessage = null;
DockingUtils.setTipWindowEnabled(true);
setMyToolTipsEnabled(true);
PopupWindow.hideAllWindows();
if (popup != null) {
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() {
ByteMatcher[] historyArray = searchHistory.getHistoryAsArray();

View file

@ -124,6 +124,8 @@ public class DockingUtils {
private static final KeyStroke REDO_KEYSTROKE =
KeyStroke.getKeyStroke(KeyEvent.VK_Y, CONTROL_KEY_MODIFIER_MASK);
private static boolean globalTooltipsEnabled = true;
public static JSeparator createToolbarSeparator() {
Dimension sepDim = new Dimension(2, ICON_SIZE + 2);
JSeparator separator = new JSeparator(SwingConstants.VERTICAL);
@ -355,19 +357,36 @@ public class DockingUtils {
}
/**
* Sets the application-wide Java tooltip enablement.
* @param enabled true if enabled; false prevents all Java tooltips
* Not meant for public consumption. This is for application code to control tooltips on
* 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));
}
/**
* 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.
* @return true if application-wide Java tooltips are enabled.
*/
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 */

View file

@ -370,7 +370,7 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
AnimationUtils.setAnimationEnabled(animationEnabled);
boolean showToolTips = options.getBoolean(SHOW_TOOLTIPS_OPTION_NAME, true);
DockingUtils.setTipWindowEnabled(showToolTips);
DockingUtils.setGlobalTooltipEnabledOption(showToolTips);
boolean compressDataBuffers =
options.getBoolean(ENABLE_COMPRESSED_DATABUFFER_OUTPUT, false);
@ -397,7 +397,7 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
AnimationUtils.setAnimationEnabled((Boolean) newValue);
}
else if (SHOW_TOOLTIPS_OPTION_NAME.equals(optionName)) {
DockingUtils.setTipWindowEnabled((Boolean) newValue);
DockingUtils.setGlobalTooltipEnabledOption((Boolean) newValue);
}
else if (ENABLE_COMPRESSED_DATABUFFER_OUTPUT.equals(optionName)) {
DataBuffer.enableCompressedSerializationOutput((Boolean) newValue);