GP-0 fixing fieldpanel test after blinking cusror change

This commit is contained in:
ghidragon 2024-06-14 18:22:38 -04:00
parent 3ec2dfb201
commit 9ec93ee41f
4 changed files with 32 additions and 10 deletions

View File

@ -42,7 +42,7 @@ import docking.widgets.indexedscrollpane.IndexScrollListener;
import docking.widgets.indexedscrollpane.IndexedScrollable;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors.Messages;
import generic.theme.ThemeManager;
import generic.theme.Gui;
import ghidra.util.*;
public class FieldPanel extends JPanel
@ -401,9 +401,7 @@ public class FieldPanel extends JPanel
}
private void initializeCursorBlinking() {
ThemeManager themeManager = ThemeManager.getInstance();
boolean blinkingCursors = themeManager != null ? themeManager.isBlinkingCursors() : true;
setBlinkCursor(blinkingCursors);
setBlinkCursor(Gui.isBlinkingCursors());
}
@Override

View File

@ -220,4 +220,28 @@ public class Gui {
static void setThemeManager(ThemeManager manager) {
themeManager = manager;
}
/**
* Sets application's blinking cursor state. This will affect all JTextFields, JTextAreas,
* JTextPanes via {@link UIDefaults}. Custom components can also respect this setting by
* either adding a {@link ThemeListener} or overriding {@link JComponent#updateUI()}
* <P> NOTE: This method is a bit odd here as it doesn't really apply to a theme. But it
* requires manipulation of the look and feel which is managed by the theme. If other
* application level properties come along and also require changing the UIDefaults,
* perhaps a more general solution might be to add a way for clients to register a callback
* so that they get a chance to change the UIDefaults map as the look and feel is loaded.
* @param b true for blinking text cursors, false for non-blinking text cursors
*/
public static void setBlinkingCursors(boolean b) {
themeManager.setBlinkingCursors(b);
}
/**
* Returns true if the application should allow blinking cursors, false otherwise. Custom
* components can use this method to determine if they should have a blinking cursor or not.
* @return true if the application should allow blinking cursors, false otherwise.
*/
public static boolean isBlinkingCursors() {
return themeManager.isBlinkingCursors();
}
}

View File

@ -679,8 +679,8 @@ public abstract class ThemeManager {
* so that they get a chance to change the UIDefaults map as the look and feel is loaded.
* @param b true for blinking text cursors, false for non-blinking text cursors
*/
public void setBlinkingCursors(boolean b) {
throw new UnsupportedOperationException();
protected void setBlinkingCursors(boolean b) {
// do nothing
}
/**
@ -688,7 +688,7 @@ public abstract class ThemeManager {
* components can use this method to determine if they should have a blinking cursor or not.
* @return true if the application should allow blinking cursors, false otherwise.
*/
public boolean isBlinkingCursors() {
protected boolean isBlinkingCursors() {
return true;
}
}

View File

@ -42,7 +42,7 @@ import docking.util.AnimationUtils;
import docking.util.image.ToolIconURL;
import docking.widgets.OptionDialog;
import generic.jar.ResourceFile;
import generic.theme.ThemeManager;
import generic.theme.Gui;
import generic.util.WindowUtilities;
import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.util.GenericHelpTopics;
@ -379,7 +379,7 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
shouldRestorePreviousProject = options.getBoolean(RESTORE_PREVIOUS_PROJECT_NAME, true);
boolean blink = options.getBoolean(BLINKING_CURSORS_OPTION_NAME, true);
ThemeManager.getInstance().setBlinkingCursors(blink);
Gui.setBlinkingCursors(blink);
options.addOptionsChangeListener(this);
}
@ -406,7 +406,7 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
shouldRestorePreviousProject = (Boolean) newValue;
}
else if (BLINKING_CURSORS_OPTION_NAME.equals(optionName)) {
ThemeManager.getInstance().setBlinkingCursors((Boolean) newValue);
Gui.setBlinkingCursors((Boolean) newValue);
}
}