mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
GT-2698 refactor JLabel -> GLabel, JComboBox -> GComboBox, renderers.
This commit is contained in:
parent
e0c25b0590
commit
6448f0da8f
280 changed files with 2277 additions and 1531 deletions
|
@ -32,6 +32,7 @@ public class ErrorPropertyEditor extends PropertyEditorSupport {
|
|||
message += " - value: " + value.toString();
|
||||
}
|
||||
|
||||
// Use native java JLabel because we can't use docking widgets here
|
||||
errorLabel = new JLabel(message);
|
||||
errorLabel.setForeground(Color.RED);
|
||||
errorLabel.putClientProperty("html.disable", true);
|
||||
|
|
|
@ -25,6 +25,8 @@ import javax.swing.JLabel;
|
|||
import javax.swing.plaf.basic.BasicHTML;
|
||||
import javax.swing.text.View;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
|
||||
import generic.text.TextLayoutGraphics;
|
||||
import ghidra.util.html.HtmlLineSplitter;
|
||||
import utilities.util.reflection.ReflectionUtilities;
|
||||
|
@ -520,37 +522,8 @@ public class HTMLUtilities {
|
|||
}
|
||||
|
||||
/**
|
||||
* Converts any special or reserved characters in the specified string into HTML-escaped
|
||||
* entities. Use this method when you have content containing HTML that you do not want
|
||||
* interpreted as HTML, such as when displaying text that uses angle brackets around words.
|
||||
*
|
||||
* <P>For example, consider the following<br><br>
|
||||
*
|
||||
* <table border=1>
|
||||
* <tr>
|
||||
* <th>Input</th><th>Output</th><th>Rendered as</th><th>(Without Friendly Encoding)</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>
|
||||
* Hi <b>mom </b>
|
||||
* </td>
|
||||
* <td>
|
||||
* Hi<font color="green">
|
||||
* &nbsp;<b>&lt;</b></font>b<font color="green"><b>&gt;</b></font>mom
|
||||
* <font color="green">&nbsp;<b>&lt;</b></font>/b<font color="green"><b>&gt;</b>
|
||||
* </font>
|
||||
* </td>
|
||||
* <td>
|
||||
* Hi <b>mom </b>
|
||||
* </td>
|
||||
* <td>
|
||||
* Hi <b>mom </b>
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* <br><br><br>
|
||||
*
|
||||
* @see {@link #friendlyEncodeHTML(String)}
|
||||
*
|
||||
* @param text string to be encoded
|
||||
* @param skipLeadingWhitespace true signals to ignore any leading whitespace characters.
|
||||
* This is useful when line wrapping to force wrapped lines to the left
|
||||
|
@ -625,6 +598,46 @@ public class HTMLUtilities {
|
|||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes any HTML special characters in the specified text.
|
||||
* <p>
|
||||
* Does not otherwise modify the input text or wrap lines.
|
||||
* <p>
|
||||
* See also {@link StringEscapeUtils#escapeHtml3(String)}.
|
||||
*
|
||||
* @param text plain-text that might have some characters that should NOT be interpreted as HTML
|
||||
* @return string with any html characters replaced with equivalents
|
||||
*/
|
||||
public static String escapeHTML(String text) {
|
||||
|
||||
StringBuilder buffer = new StringBuilder(text.length());
|
||||
text.codePoints().forEach(cp -> {
|
||||
switch (cp) {
|
||||
case '&':
|
||||
buffer.append("&");
|
||||
break;
|
||||
case '<':
|
||||
buffer.append("<");
|
||||
break;
|
||||
case '>':
|
||||
buffer.append(">");
|
||||
break;
|
||||
default:
|
||||
if (cp < ' ' || cp >= 0x7F) {
|
||||
buffer.append("&#x");
|
||||
buffer.append(Integer.toString(cp, 16).toUpperCase());
|
||||
buffer.append(";");
|
||||
}
|
||||
else {
|
||||
buffer.appendCodePoint(cp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* A convenience method to split the given HTML into lines, based on the given length, and
|
||||
* then to {@link #friendlyEncodeHTML(String)} the text.
|
||||
|
|
|
@ -690,4 +690,12 @@ public class ResourceManager {
|
|||
testSearchPaths = results;
|
||||
return testSearchPaths;
|
||||
}
|
||||
|
||||
public static List<ImageIcon> loadImages(String... filenames) {
|
||||
List<ImageIcon> results = new ArrayList<>(filenames.length);
|
||||
for (String filename : filenames) {
|
||||
results.add(loadImage(filename));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue