diff options
author | Jiri Vanek <[email protected]> | 2013-01-30 16:51:08 +0100 |
---|---|---|
committer | Jiri Vanek <[email protected]> | 2013-01-30 16:51:08 +0100 |
commit | c06c5ab6dc8a8aa1b41af190188d1de99345810f (patch) | |
tree | dd2e2f2b01ce8a2acb4a4d9bbe7cf04a64af96bf /netx/net/sourceforge/jnlp/splashscreen/parts | |
parent | 924f9299d39b9bd985c58fde4ea2968b8ebdb229 (diff) |
Splashscreen error report made more detailed by stored LaunchErrors
* netx/net/sourceforge/jnlp/LaunchException.java: (LaunchExceptionWithStamp)
new inner class for storing timestamp togetehr with error.
(launchExceptionChain) new static list to capture LaunchErrors during
runtime.
* /netx/net/sourceforge/jnlp/resources/Messages.properties:
* netx/net/sourceforge/jnlp/resources/Messages_cs_CZ.properties:
Added explanation string
* netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java:
Is now displaying launchExceptionChain in its error report and is copying
it to clipboard.
* tests/unit/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialogTest.java:
(getTextTest) adapted calls of getText for new Date.
Diffstat (limited to 'netx/net/sourceforge/jnlp/splashscreen/parts')
-rw-r--r-- | netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java b/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java index 8cc6070..dbd860e 100644 --- a/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java +++ b/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java @@ -42,6 +42,8 @@ import java.awt.datatransfer.StringSelection; import java.awt.event.WindowEvent; import java.io.PrintWriter; import java.io.StringWriter; +import java.text.DateFormat; +import java.util.Date; import java.util.List; import javax.swing.BorderFactory; import javax.swing.GroupLayout; @@ -60,6 +62,7 @@ import javax.swing.SwingConstants; import javax.swing.WindowConstants; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; +import net.sourceforge.jnlp.LaunchException; import net.sourceforge.jnlp.runtime.Translator; public class JEditorPaneBasedExceptionDialog extends JDialog implements HyperlinkListener { @@ -78,15 +81,19 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin // End of components declaration private final String message; private final Throwable exception; + private final Date shown; + private final String anotherInfo; /** Creates new form JEditorPaneBasedExceptionDialog */ public JEditorPaneBasedExceptionDialog(java.awt.Frame parent, boolean modal, Throwable ex, InformationElement information, String anotherInfo) { super(parent, modal); + shown = new Date(); initComponents(); htmlErrorAndHelpPanel.setContentType("text/html"); htmlErrorAndHelpPanel.setEditable(false); + this.anotherInfo=anotherInfo; List<String> l = infoElementToList(information); - this.message = getText(ex, l, anotherInfo); + this.message = getText(ex, l, anotherInfo, shown); this.exception = ex; if (exception == null) { closeAndCopyButton.setVisible(false); @@ -199,7 +206,7 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin private void copyAndCloseButtonActionPerformed(java.awt.event.ActionEvent evt) { if (exception != null) { try { - StringSelection data = new StringSelection(getExceptionStackTraceAsString(exception)); + StringSelection data = new StringSelection(anotherInfo+"\n"+shown.toString()+"\n"+getExceptionStackTraceAsString(exception)+addPlainChain()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(data, data); } catch (Exception ex) { @@ -241,7 +248,7 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin }); } - static String getText(Throwable ex, List<String> l, String anotherInfo) { + static String getText(Throwable ex, List<String> l, String anotherInfo,Date shown) { StringBuilder s = new StringBuilder("<html><body>"); String info = "<p>" + Translator.R(InfoItem.SPLASH + "mainL1", createLink()) @@ -258,9 +265,11 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin + Translator.R(InfoItem.SPLASH + "mainL4") + " </p>\n" + info + formatListInfoList(l) + formatInfo(anotherInfo) + +"<br>"+DateFormat.getInstance().format(shown)+"<br>" + "<p>" + Translator.R(InfoItem.SPLASH + "exWas") - + " <br/>\n" + "<pre>" + getExceptionStackTraceAsString(ex) + "</pre>"; + + " <br/>\n" + "<pre>" + getExceptionStackTraceAsString(ex) + "</pre>" + + addChain(); } else { @@ -354,4 +363,47 @@ public class JEditorPaneBasedExceptionDialog extends JDialog implements Hyperlin } + private static String addChain() { + if (LaunchException.getLaunchExceptionChain().isEmpty()) { + return ""; + } + return Translator.R(InfoItem.SPLASH + "chainWas") + + " <br/>\n" + "<pre>" + getChainAsString(true) + "</pre>"; + + } + + private static String addPlainChain() { + if (LaunchException.getLaunchExceptionChain().isEmpty()) { + return ""; + } + return "\n Chain: \n" + getChainAsString(false); + + } + + private static String getChainAsString(boolean formatTime) { + return getChainAsString(LaunchException.getLaunchExceptionChain(), formatTime); + } + + private static String getChainAsString(List<LaunchException.LaunchExceptionWithStamp> launchExceptionChain, boolean formatTime) { + String s = ""; + if (launchExceptionChain != null) { + int i = 0; + for (LaunchException.LaunchExceptionWithStamp launchException : launchExceptionChain) { + i++; + s = s + i + ") at " + formatTime(launchException.getStamp(), formatTime) + "\n" + getExceptionStackTraceAsString(launchException.getEx()); + } + } + return s; + } + + private static String formatTime(Date dateTime, boolean formatTime) { + if (dateTime == null) { + return "unknown time"; + } + if (formatTime) { + return DateFormat.getInstance().format(dateTime); + } else { + return dateTime.toString(); + } + } } |