diff --git a/swing/src/net/sf/openrocket/gui/dialogs/BugReportDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/BugReportDialog.java index 2fd0f26b4..6b1817990 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/BugReportDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/BugReportDialog.java @@ -14,10 +14,12 @@ import java.util.TreeSet; import javax.swing.JButton; import javax.swing.JDialog; +import javax.swing.JEditorPane; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; +import javax.swing.JTextPane; import com.jogamp.opengl.JoglVersion; @@ -68,11 +70,13 @@ public class BugReportDialog extends JDialog { panel.add(new JLabel(trans.get("bugreport.dlg.otherwise") + " "), "gapleft para, split 2, gapright rel"); panel.add(new URLLabel(REPORT_EMAIL_URL, REPORT_EMAIL), "growx, wrap para"); - - - final JTextArea textArea = new JTextArea(message, 20, 70); - textArea.setEditable(true); - panel.add(new JScrollPane(textArea), "grow, wrap"); + + final JEditorPane editorPane = new JEditorPane("text/html", formatNewlineHTML(message)); + editorPane.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, true); + editorPane.setPreferredSize(new Dimension(600, 400)); + editorPane.setEditable(true); + editorPane.setCaretPosition(0); // Scroll to the top by default + panel.add(new JScrollPane(editorPane), "grow, wrap"); panel.add(new StyledLabel(trans.get("bugreport.lbl.Theinformation"), -1), "wrap para"); @@ -106,17 +110,18 @@ public class BugReportDialog extends JDialog { StringBuilder sb = new StringBuilder(); - sb.append("---------- Bug report ----------\n"); + sb.append("---------- Bug report ----------\n"); sb.append('\n'); - sb.append("Include detailed steps on how to trigger the bug:\n"); + sb.append("Include detailed steps on how to trigger the bug:\n"); + sb.append("(You can edit text directly in this window)\n"); sb.append('\n'); sb.append("1. \n"); sb.append("2. \n"); sb.append("3. \n"); sb.append('\n'); - sb.append("What does the software do and what in your opinion should it do in the " + - "case described above:\n"); + sb.append("What does the software do and what in your opinion should it do in the " + + "case described above:\n"); sb.append('\n'); sb.append('\n'); sb.append('\n'); @@ -133,7 +138,7 @@ public class BugReportDialog extends JDialog { addSystemInformation(sb); sb.append("---------- Error log ----------\n"); addErrorLog(sb); - sb.append("---------- End of bug report ----------\n"); + sb.append("---------- End of bug report ----------\n"); sb.append('\n'); BugReportDialog reportDialog = new BugReportDialog(parent, @@ -152,14 +157,15 @@ public class BugReportDialog extends JDialog { public static void showExceptionDialog(Window parent, Thread t, Throwable e) { StringBuilder sb = new StringBuilder(); - sb.append("---------- Bug report ----------\n"); - sb.append('\n'); - sb.append("Please include a description about what actions you were " + - "performing when the exception occurred:\n"); - sb.append('\n'); - sb.append('\n'); + sb.append("---------- Bug report ----------\n"); sb.append('\n'); + sb.append("Please include a description about what actions you were " + + "performing when the exception occurred:\n"); + sb.append("(You can edit text directly in this window)\n"); sb.append('\n'); + sb.append("1. \n"); + sb.append("2. \n"); + sb.append("3. \n"); sb.append("Include your email address (optional; it helps if we can " + @@ -191,7 +197,7 @@ public class BugReportDialog extends JDialog { addSystemInformation(sb); sb.append("---------- Error log ----------\n"); addErrorLog(sb); - sb.append("---------- End of bug report ----------\n"); + sb.append("---------- End of bug report ----------\n"); sb.append('\n'); BugReportDialog reportDialog = @@ -235,5 +241,16 @@ public class BugReportDialog extends JDialog { sb.append(l.toString()).append('\n'); } } + + /** + * Replace newline character \n to an HTML newline. Instead of just using a
tag, we replace newlines with a + * paragraph tag with zero margin. This is so that when you copy the HTML text and paste it somewhere, that the + * HTML newlines are also interpreted as newlines in the new text. A
tag would just be replaced by a space. + * @param text text to be formatted + * @return text with HTML newlines + */ + private static String formatNewlineHTML(String text) { + return text.replaceAll("\n(.*?)(?=(\n|$))", "

$1

"); + } } diff --git a/swing/src/net/sf/openrocket/logging/LogLine.java b/swing/src/net/sf/openrocket/logging/LogLine.java index c4c0d4cb1..af6f74f54 100644 --- a/swing/src/net/sf/openrocket/logging/LogLine.java +++ b/swing/src/net/sf/openrocket/logging/LogLine.java @@ -1,6 +1,7 @@ package net.sf.openrocket.logging; import java.io.PrintWriter; +import java.util.Locale; import java.util.concurrent.atomic.AtomicInteger; /** @@ -127,7 +128,7 @@ public class LogLine implements Comparable { public String toString() { if (formattedMessage == null) { String str; - str = String.format("%4d %10.3f %-" + LogLevel.LENGTH + "s %s %s", + str = String.format(Locale.ENGLISH, "%4d %10.3f %-" + LogLevel.LENGTH + "s %s %s", count, timestamp / 1000.0, (level != null) ? level.toString() : "NULL", getLocation(), message);