mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-31 14:41:05 +08:00
Merge remote-tracking branch 'origin/GP-1-dragonmacher-error-dialog-newline-fix' into patch
This commit is contained in:
@@ -157,21 +157,7 @@ public class ErrLogDialog extends AbstractErrDialog {
|
|||||||
new GIconLabel(UIManager.getIcon("OptionPane.errorIcon"), SwingConstants.RIGHT),
|
new GIconLabel(UIManager.getIcon("OptionPane.errorIcon"), SwingConstants.RIGHT),
|
||||||
BorderLayout.WEST);
|
BorderLayout.WEST);
|
||||||
|
|
||||||
JLabel messageLabel;
|
JLabel messageLabel = createMessageLabel(message);
|
||||||
if (HTMLUtilities.isHTML(message)) {
|
|
||||||
messageLabel = new GHtmlLabel(message) {
|
|
||||||
@Override
|
|
||||||
public Dimension getPreferredSize() {
|
|
||||||
// rendering HTML the label can expand larger than the screen; keep it reasonable
|
|
||||||
Dimension size = super.getPreferredSize();
|
|
||||||
size.width = 300;
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
messageLabel = new GLabel(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
introPanel.add(messageLabel, BorderLayout.CENTER);
|
introPanel.add(messageLabel, BorderLayout.CENTER);
|
||||||
|
|
||||||
@@ -209,6 +195,25 @@ public class ErrLogDialog extends AbstractErrDialog {
|
|||||||
detailsPane.selectFirstError();
|
detailsPane.selectFirstError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JLabel createMessageLabel(String message) {
|
||||||
|
|
||||||
|
if (HTMLUtilities.isHTML(message)) {
|
||||||
|
// Client HTML; keep as-is
|
||||||
|
return new MaxWidthHtmlLabel(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.indexOf('\n') != 0) {
|
||||||
|
// JLabels do not handle newlines, so we must update the text to reflect the client's
|
||||||
|
// desired newlines. Escape any content that may have angle brackets so it does not get
|
||||||
|
// removed when we convert the text to HTML. Convert newlines to break tags so the
|
||||||
|
// label will correctly line wrap as intended by the client.
|
||||||
|
String html = HTMLUtilities.toLiteralHTML(message, 0);
|
||||||
|
return new MaxWidthHtmlLabel(html);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new GLabel(message);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void cancelCallback() {
|
protected void cancelCallback() {
|
||||||
close();
|
close();
|
||||||
@@ -270,6 +275,10 @@ public class ErrLogDialog extends AbstractErrDialog {
|
|||||||
return baseTitle;
|
return baseTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=================================================================================================
|
||||||
|
// Inner Classes
|
||||||
|
//=================================================================================================
|
||||||
|
|
||||||
private class ErrorDetailsSplitPane extends JSplitPane {
|
private class ErrorDetailsSplitPane extends JSplitPane {
|
||||||
|
|
||||||
private final double TOP_PREFERRED_RESIZE_WEIGHT = .80;
|
private final double TOP_PREFERRED_RESIZE_WEIGHT = .80;
|
||||||
@@ -584,4 +593,19 @@ public class ErrLogDialog extends AbstractErrDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class MaxWidthHtmlLabel extends GHtmlLabel {
|
||||||
|
|
||||||
|
MaxWidthHtmlLabel(String text) {
|
||||||
|
super(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension getPreferredSize() {
|
||||||
|
// rendering HTML can expand larger than the screen; keep it reasonable
|
||||||
|
Dimension size = super.getPreferredSize();
|
||||||
|
size.width = 300;
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user