diff --git a/Ghidra/Framework/Docking/src/main/java/docking/DockingErrorDisplay.java b/Ghidra/Framework/Docking/src/main/java/docking/DockingErrorDisplay.java index 834ccb7623..9a84d580c3 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/DockingErrorDisplay.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/DockingErrorDisplay.java @@ -109,18 +109,9 @@ public class DockingErrorDisplay implements ErrorDisplay { int dialogType = OptionDialog.PLAIN_MESSAGE; - String messageString = message != null ? message.toString() : null; - if (messageString != null) { - // prevent excessive message degenerate cases - int maxChars = 1000; - String safeMessage = StringUtilities.trimMiddle(messageString, maxChars); + String cleanMessage = cleanupMessage(message); - // wrap any poorly formatted text that gets displayed in the label; 80-100 chars is - // a reasonable line length based on historical print margins - messageString = wrap(safeMessage); - } - - String unformattedMessage = HTMLUtilities.fromHTML(messageString); + String unformattedMessage = HTMLUtilities.fromHTML(cleanMessage); switch (messageType) { case INFO: dialogType = OptionDialog.INFORMATION_MESSAGE; @@ -140,7 +131,25 @@ public class DockingErrorDisplay implements ErrorDisplay { break; } - showDialog(title, throwable, dialogType, messageString, getWindow(parent)); + showDialog(title, throwable, dialogType, cleanMessage, getWindow(parent)); + } + + private String cleanupMessage(Object message) { + + if (message == null) { + return null; + } + + // prevent excessive message degenerate cases + int maxChars = 1000; + String messageString = message.toString(); + String safeMessage = StringUtilities.trimMiddle(messageString, maxChars); + + // wrap any poorly formatted text that gets displayed in the label; 80-100 chars is + // a reasonable line length based on historical print margins + messageString = wrap(safeMessage); + + return messageString; } private Component getWindow(Component component) { @@ -150,20 +159,19 @@ public class DockingErrorDisplay implements ErrorDisplay { return component; } - private void showDialog(String title, Throwable throwable, int dialogType, - String messageString, Component parent) { + private void showDialog(String title, Throwable throwable, int dialogType, String messageString, + Component parent) { if (dialogType == OptionDialog.ERROR_MESSAGE) { - showDialogOnSwing(title, throwable, dialogType, messageString, parent); + showErrorDialogOnSwing(title, throwable, messageString, parent); } else { - DockingWindowManager.showDialog(parent, - new OkDialog(title, messageString, dialogType)); + DockingWindowManager.showDialog(parent, new OkDialog(title, messageString, dialogType)); } } - private void showDialogOnSwing(String title, Throwable throwable, int dialogType, - String messageString, Component parent) { + private void showErrorDialogOnSwing(String title, Throwable throwable, String messageString, + Component parent) { if (activeDialog != null) { activeDialog.addException(messageString, throwable); diff --git a/Ghidra/Framework/Docking/src/main/java/docking/ErrLogDialog.java b/Ghidra/Framework/Docking/src/main/java/docking/ErrLogDialog.java index 02c8a8ea57..7e7f828d28 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/ErrLogDialog.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/ErrLogDialog.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,8 +24,7 @@ import java.util.List; import javax.swing.*; import docking.widgets.ScrollableTextArea; -import docking.widgets.label.GHtmlLabel; -import docking.widgets.label.GIconLabel; +import docking.widgets.label.*; import docking.widgets.table.*; import generic.json.Json; import generic.util.WindowUtilities; @@ -157,16 +156,24 @@ public class ErrLogDialog extends AbstractErrDialog { introPanel.add( new GIconLabel(UIManager.getIcon("OptionPane.errorIcon"), SwingConstants.RIGHT), BorderLayout.WEST); - String html = HTMLUtilities.toHTML(message); - introPanel.add(new GHtmlLabel(html) { - @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; - } - }, BorderLayout.CENTER); + + JLabel messageLabel; + 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); mainPanel = new JPanel(new BorderLayout(10, 20)); mainPanel.add(introPanel, BorderLayout.NORTH);