Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-0 fixing fieldpanel test after blinking cusror change

ghidragon9ec93ee41f06
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/FieldPanel.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/FieldPanel.java
index dd524f3e4a..bc59a38322 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/FieldPanel.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/FieldPanel.java
@@ -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
diff --git a/Ghidra/Framework/Gui/src/main/java/generic/theme/Gui.java b/Ghidra/Framework/Gui/src/main/java/generic/theme/Gui.java
index 16e751dda7..fb7ead0812 100644
--- a/Ghidra/Framework/Gui/src/main/java/generic/theme/Gui.java
+++ b/Ghidra/Framework/Gui/src/main/java/generic/theme/Gui.java
@@ -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();
+ }
}
diff --git a/Ghidra/Framework/Gui/src/main/java/generic/theme/ThemeManager.java b/Ghidra/Framework/Gui/src/main/java/generic/theme/ThemeManager.java
index 62ce29f5f8..29343c19fc 100644
--- a/Ghidra/Framework/Gui/src/main/java/generic/theme/ThemeManager.java
+++ b/Ghidra/Framework/Gui/src/main/java/generic/theme/ThemeManager.java
@@ -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;
}
}
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/FrontEndTool.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/FrontEndTool.java
index 842790f6a2..81aecd1fc0 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/FrontEndTool.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/FrontEndTool.java
@@ -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);
}
}