From acd4e04088ec62fd7e4eb83d2da411f76d2eabbc Mon Sep 17 00:00:00 2001 From: dragonmacher <48328597+dragonmacher@users.noreply.github.com> Date: Wed, 23 Sep 2026 15:30:40 -0400 Subject: [PATCH] Undo of previous change for html labels --- .../widgets/label/AbstractHtmlLabel.java | 19 ++++++++++--------- .../docking/widgets/label/GDHtmlLabel.java | 5 +++-- .../docking/widgets/label/GHtmlLabel.java | 5 +++-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/label/AbstractHtmlLabel.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/label/AbstractHtmlLabel.java index 2cd204c4cc..6266f4d05a 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/label/AbstractHtmlLabel.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/label/AbstractHtmlLabel.java @@ -34,21 +34,22 @@ import ghidra.util.WebColors; import ghidra.util.exception.AssertException; /** - * Base class for labels that render html using a custom rendering kit. + * Base class for labels that render HTML using a custom rendering kit. *
* This implementation uses custom html rendering. This custom rendering allows for basic - * formatting while eliminating potentially unsafe html tags. If for some reason this custom + * formatting while eliminating potentially unsafe HTML tags. If for some reason this custom * rendering is deficient, clients can instead use a standard Java {@link JLabel}. *
- * Clients do not need to prefix label text with "<html>", as is required for a standard - * JLabel. + * This abstract class supports rendering as HTML or non-HTML text. The text set on this label + * must include the "<html>" prefix to be rendered as html. See subclasses for expected + * usage. */ public abstract class AbstractHtmlLabel extends JLabel implements GComponent, PropertyChangeListener { private static final String HTML_TAG = ""; private boolean isUpdating; - private boolean expectsHtmlPrefix; + private boolean isHtml; protected AbstractHtmlLabel() { addPropertyChangeListener(this); @@ -65,10 +66,10 @@ public abstract class AbstractHtmlLabel extends JLabel // do not pass up to the parent so that it does not install its own html rendering if (text != null && text.toLowerCase().startsWith(HTML_TAG)) { text = text.substring(HTML_TAG.length()); - expectsHtmlPrefix = true; + isHtml = true; } else { - expectsHtmlPrefix = false; + isHtml = false; } super.setText(text); @@ -85,7 +86,7 @@ public abstract class AbstractHtmlLabel extends JLabel * @return text of this label */ public String getOriginalText() { - return expectsHtmlPrefix ? HTML_TAG + getText() : getText(); + return isHtml ? HTML_TAG + getText() : getText(); } @Override @@ -97,7 +98,7 @@ public abstract class AbstractHtmlLabel extends JLabel private void updateHtmlView() { String text = getText(); - if (text == null || !isHTMLRenderingEnabled()) { + if (text == null || !isHtml || !isHTMLRenderingEnabled()) { putClientProperty(BasicHTML.propertyKey, null); return; } diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/label/GDHtmlLabel.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/label/GDHtmlLabel.java index 9e5ce4c432..78d0aef8d0 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/label/GDHtmlLabel.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/label/GDHtmlLabel.java @@ -24,8 +24,9 @@ import docking.widgets.checkbox.GHtmlCheckBox; /** * A 'dynamic' label (the text can be changed), with HTML rendering allowed. *
- * Clients do not need to prefix label text with "<html>", as is required for a standard - * JLabel. + * Since HTML rendering is optional, the "<html>" prefix must be added this label's text in + * order to be rendered as HTML. Supporting both HTML and non-HTML allows clients to change how + * this label gets used over time without having to switch to a {@link GLabel}. *
* See also: *