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 | |
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')
4 files changed, 102 insertions, 5 deletions
diff --git a/netx/net/sourceforge/jnlp/LaunchException.java b/netx/net/sourceforge/jnlp/LaunchException.java index 6c194ed..818df1e 100644 --- a/netx/net/sourceforge/jnlp/LaunchException.java +++ b/netx/net/sourceforge/jnlp/LaunchException.java @@ -16,6 +16,11 @@ package net.sourceforge.jnlp; +import java.util.Collections; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + /** * Thrown when a JNLP application, applet, or installer could not * be created. @@ -25,6 +30,29 @@ package net.sourceforge.jnlp; */ public class LaunchException extends Exception { + + public static class LaunchExceptionWithStamp{ + private final LaunchException ex; + private final Date stamp; + + private LaunchExceptionWithStamp(LaunchException ex) { + this.ex=ex; + this.stamp=new Date(); + } + + public LaunchException getEx() { + return ex; + } + + public Date getStamp() { + return stamp; + } + + + + } + private static final List<LaunchExceptionWithStamp> launchExceptionChain = Collections.synchronizedList(new LinkedList<LaunchExceptionWithStamp>()); + private static final long serialVersionUID = 7283827853612357423L; /** the file being launched */ @@ -54,6 +82,7 @@ public class LaunchException extends Exception { this.summary = summary; this.description = description; this.severity = severity; + saveLaunchException(this); } /** @@ -61,6 +90,7 @@ public class LaunchException extends Exception { */ public LaunchException(Throwable cause) { super(cause); + saveLaunchException(this); } /** @@ -68,6 +98,7 @@ public class LaunchException extends Exception { */ public LaunchException(String message, Throwable cause) { super(message, cause); + saveLaunchException(this); } /** @@ -78,6 +109,7 @@ public class LaunchException extends Exception { */ public LaunchException(String message) { super(message); + saveLaunchException(this); } /** @@ -117,4 +149,15 @@ public class LaunchException extends Exception { return severity; } + private synchronized void saveLaunchException(LaunchException ex) { + launchExceptionChain.add(new LaunchExceptionWithStamp(ex)); + + } + + public synchronized static List<LaunchExceptionWithStamp> getLaunchExceptionChain() { + return launchExceptionChain; + } + + + } diff --git a/netx/net/sourceforge/jnlp/resources/Messages.properties b/netx/net/sourceforge/jnlp/resources/Messages.properties index 3fc0ddc..4dc45d5 100644 --- a/netx/net/sourceforge/jnlp/resources/Messages.properties +++ b/netx/net/sourceforge/jnlp/resources/Messages.properties @@ -473,3 +473,4 @@ SPLASHanotherInfo = Another available info SPLASHdefaultHomepage = Unspecified homepage, verify source rather SPLASHerrorInInformation = Error during loading of information element, verify source rather SPLASHmissingInformation = Information element is missing, verify source rather +SPLASHchainWas = This is the list of exceptions that occurred launching your applet. Please note, those exceptions can be from multiple applets. For a good bug report, be sure to run only one applet. diff --git a/netx/net/sourceforge/jnlp/resources/Messages_cs_CZ.properties b/netx/net/sourceforge/jnlp/resources/Messages_cs_CZ.properties index db23eff..f651e67 100644 --- a/netx/net/sourceforge/jnlp/resources/Messages_cs_CZ.properties +++ b/netx/net/sourceforge/jnlp/resources/Messages_cs_CZ.properties @@ -468,4 +468,5 @@ SPLASHvendorsInfo= Informace od dodavatele va\u0161\u00ed aplikace SPLASHanotherInfo= Dal\u0161\u00ed dostupn\u00e9 informace SPLASHdefaultHomepage = Nespecifikovan\u00e1 domovsk\u00e1 st\u00e1nka, je doporu\u010deno zkontrolovat zdroj SPLASHerrorInInformation = Chyba na\u010d\u00edt\u00e1n\u00ed informa\u010dn\u00edho elementu, je doporu\u010deno zkontrolovat zdroj -SPLASHmissingInformation = Informa\u010dn\u00ed element chyb\u00fd, je doporu\u010deno zkontrolovat zdroj
\ No newline at end of file +SPLASHmissingInformation = Informa\u010dn\u00ed element chyb\u00fd, je doporu\u010deno zkontrolovat zdroj +SPLASHchainWas = N\u00ed\u017ee je seznam v\u00fdjimek, kter\u00e9 prov\u00e1zely start appeltu. Tento seznam ale m\u016f\u017er poch\u00e1zet z n\u011bkolik\u00e1 r\u016fzn\u00fdch applet\u016f. Pro dob\u00e9 chybo\u00e9 hl\u00e1\u0161en\u00ed stoj\u00e9 za to pustit applet izolovane.
\ No newline at end of file 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(); + } + } } |