You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ne...@apache.org on 2022/08/16 09:16:11 UTC
[netbeans] branch delivery updated: exception reporter improvments
This is an automated email from the ASF dual-hosted git repository.
neilcsmith pushed a commit to branch delivery
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/delivery by this push:
new 08bd636e32 exception reporter improvments
new 17c21d8ecb Merge pull request #4490 from mbien/exception-reporter-improvements
08bd636e32 is described below
commit 08bd636e32fe447ac7f59321497cf7ced011487a
Author: Michael Bien <mb...@gmail.com>
AuthorDate: Tue Aug 9 16:40:47 2022 +0200
exception reporter improvments
- improved the messages
* emphasized latest release requirement
* switched text to html
* added hyperlinks which open the issue/download page/log folder
- wrapped TextArea of NotifyDescriptor into a ScrollPane
- switched stack trace pane to TextArea and disabled line wrap
- slightly larger dimensions for everything
---
.../src/org/netbeans/core/Bundle_nb.properties | 11 ++--
.../src/org/netbeans/core/Bundle.properties | 8 +--
.../src/org/netbeans/core/NotifyExcPanel.java | 58 ++++++++++++++--------
.../src/org/openide/NotifyDescriptor.java | 11 ++--
4 files changed, 54 insertions(+), 34 deletions(-)
diff --git a/nb/ide.branding/o.n.core/src/org/netbeans/core/Bundle_nb.properties b/nb/ide.branding/o.n.core/src/org/netbeans/core/Bundle_nb.properties
index bccab0ce6b..8529024e27 100644
--- a/nb/ide.branding/o.n.core/src/org/netbeans/core/Bundle_nb.properties
+++ b/nb/ide.branding/o.n.core/src/org/netbeans/core/Bundle_nb.properties
@@ -18,9 +18,10 @@
# {0} - class name of exception
# {1} - path to system folder
NTF_ExceptionalException=\
- A {0} exception has occurred.\n\
- Please report this at https://netbeans.apache.org/nb/report-issue,\n\
- including a copy of your messages.log file as an attachment.\n\
- The messages.log file is located in your {1} folder.
+ A <code>{0}</code> has occurred.<br/><br/>\
+ If you are running the <a href="https://netbeans.apache.org/download">latest</a> version of NetBeans you can \
+ <a href="https://netbeans.apache.org/nb/report-issue">report this</a>, \
+ including a copy of your messages.log file as an attachment.<br/><br/>\
+ The messages.log file is located in <a href="{1}">this folder</a>.
-NTF_ExceptionalExceptionReport=Show and Report Problem to NetBeans Team
+NTF_ExceptionalExceptionReport=Show Details
diff --git a/platform/o.n.core/src/org/netbeans/core/Bundle.properties b/platform/o.n.core/src/org/netbeans/core/Bundle.properties
index 4a8da95598..18db39811f 100644
--- a/platform/o.n.core/src/org/netbeans/core/Bundle.properties
+++ b/platform/o.n.core/src/org/netbeans/core/Bundle.properties
@@ -28,13 +28,13 @@ OpenIDE-Module-Long-Description=\
# {0} - class name of exception
# {1} - path to system folder
NTF_ExceptionalException=\
- A {0} exception has occurred.\n\
-\tClick Show Details or see the messages.log file located in your {1} folder.
+ A {0} exception has occurred.<br/><br/>\
+ Click Show Details or see the messages.log file located in your {1} folder.
NTF_ExceptionalExceptionTitle=Unexpected Exception
# {0} - class name of exception
NTF_ExceptionWarning=\
- A {0} exception has occurred.\n\
- However, the system should continue working without further problems.\n\
+ A {0} exception has occurred.<br/><br/>\
+ However, the system should continue working without further problems.<br/><br/>\
Click Show Details for the stack trace.
NTF_ExceptionWarningTitle=Warning
diff --git a/platform/o.n.core/src/org/netbeans/core/NotifyExcPanel.java b/platform/o.n.core/src/org/netbeans/core/NotifyExcPanel.java
index f2417e0ddc..a809f09a91 100644
--- a/platform/o.n.core/src/org/netbeans/core/NotifyExcPanel.java
+++ b/platform/o.n.core/src/org/netbeans/core/NotifyExcPanel.java
@@ -21,6 +21,7 @@ package org.netbeans.core;
import java.awt.BorderLayout;
import java.awt.Cursor;
+import java.awt.Desktop;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.EventQueue;
@@ -38,6 +39,9 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
+import java.net.URISyntaxException;
+import java.nio.file.Paths;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.concurrent.Callable;
@@ -54,10 +58,12 @@ import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.UIManager;
+import javax.swing.event.HyperlinkEvent;
import org.netbeans.core.startup.CLIOptions;
import org.openide.DialogDescriptor;
import org.openide.DialogDisplayer;
@@ -87,7 +93,7 @@ public final class NotifyExcPanel extends JPanel implements ActionListener {
/** preferred width of this component */
private static final int SIZE_PREFERRED_WIDTH=550;
/** preferred height of this component */
- private static final int SIZE_PREFERRED_HEIGHT=250;
+ private static final int SIZE_PREFERRED_HEIGHT=350;
private static final int MAX_STORED_EXCEPTIONS = 500;
private static final boolean AUTO_FOCUS = Boolean.getBoolean("netbeans.winsys.auto_focus"); // NOI18N
@@ -107,7 +113,7 @@ public final class NotifyExcPanel extends JPanel implements ActionListener {
/** details button */
private JButton details;
/** details window */
- private JTextPane output;
+ private JTextArea output;
/** boolean to show/hide details */
private static boolean showDetails;
@@ -131,12 +137,13 @@ public final class NotifyExcPanel extends JPanel implements ActionListener {
details = new JButton ();
details.setDefaultCapable (false);
- output = new JTextPane() {
+ output = new JTextArea() {
public @Override boolean getScrollableTracksViewportWidth() {
return false;
}
};
output.setEditable(false);
+ output.setLineWrap(false);
Font f = output.getFont();
output.setFont(new Font("Monospaced", Font.PLAIN, null == f ? 12 : f.getSize() + 1)); // NOI18N
output.setForeground(UIManager.getColor("Label.foreground")); // NOI18N
@@ -484,32 +491,41 @@ public final class NotifyExcPanel extends JPanel implements ActionListener {
}
} else {
ResourceBundle curBundle = NbBundle.getBundle (NotifyExcPanel.class);
+ String message;
if (current.getSeverity() == Level.WARNING) {
// less scary message for warning level
- descriptor.setMessage (
- java.text.MessageFormat.format(
- curBundle.getString("NTF_ExceptionWarning"),
- new Object[] {
- current.getClassName ()
- }
- )
+ message = MessageFormat.format(
+ curBundle.getString("NTF_ExceptionWarning"),
+ new Object[] { current.getClassName() }
);
title = curBundle.getString("NTF_ExceptionWarningTitle"); // NOI18N
} else {
- // emphasize user-non-friendly exceptions
- // if (this.getMessage() == null || "".equals(this.getMessage())) { // NOI18N
- descriptor.setMessage (
- java.text.MessageFormat.format(
- curBundle.getString("NTF_ExceptionalException"),
- new Object[] {
- current.getClassName (),
- CLIOptions.getLogDir ()
- }
- )
+ message = MessageFormat.format(
+ curBundle.getString("NTF_ExceptionalException"),
+ new Object[] { current.getClassName(), Paths.get(CLIOptions.getLogDir()).toUri() }
);
-
title = curBundle.getString("NTF_ExceptionalExceptionTitle"); // NOI18N
}
+ JTextPane pane = new JTextPane();
+ pane.setContentType("text/html"); // NOI18N
+ pane.setText(message);
+ pane.setBackground(UIManager.getColor("Label.background")); // NOI18N
+ pane.setBorder(BorderFactory.createEmptyBorder());
+ pane.setEditable(false);
+ pane.setFocusable(true);
+ pane.addHyperlinkListener((e) -> {
+ if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
+ try {
+ Desktop.getDesktop().browse(e.getURL().toURI());
+ } catch (IOException | URISyntaxException ex) {
+ Exceptions.printStackTrace(ex);
+ }
+ }
+ });
+ JScrollPane sp = new JScrollPane(pane);
+ sp.setBorder(BorderFactory.createEmptyBorder());
+ sp.setPreferredSize(new Dimension(300, 120));
+ descriptor.setMessage(sp);
}
}
diff --git a/platform/openide.dialogs/src/org/openide/NotifyDescriptor.java b/platform/openide.dialogs/src/org/openide/NotifyDescriptor.java
index e195cfcaec..104b68398b 100644
--- a/platform/openide.dialogs/src/org/openide/NotifyDescriptor.java
+++ b/platform/openide.dialogs/src/org/openide/NotifyDescriptor.java
@@ -43,6 +43,7 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
+import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
@@ -183,10 +184,10 @@ public class NotifyDescriptor extends Object {
private static final int MAXIMUM_TEXT_WIDTH = 100;
/** preferred width of text area */
- private static final int SIZE_PREFERRED_WIDTH = 300;
+ private static final int SIZE_PREFERRED_WIDTH = 350;
/** preferred height of text area */
- private static final int SIZE_PREFERRED_HEIGHT = 100;
+ private static final int SIZE_PREFERRED_HEIGHT = 150;
private Object message;
/** The message type. */
@@ -342,7 +343,6 @@ public class NotifyDescriptor extends Object {
if (newMessage instanceof String) {
// bugfix #25457, use JTextArea for word-wrapping
JTextArea area = new JTextArea((String) newMessage);
- area.setPreferredSize(new Dimension(SIZE_PREFERRED_WIDTH, SIZE_PREFERRED_HEIGHT));
area.setBackground(UIManager.getColor("Label.background")); // NOI18N
area.setBorder(BorderFactory.createEmptyBorder());
area.setLineWrap(true);
@@ -351,7 +351,10 @@ public class NotifyDescriptor extends Object {
area.setFocusable(true);
area.getAccessibleContext().setAccessibleName(NbBundle.getMessage(NotifyDescriptor.class, "ACN_NotifyDescriptor_MessageJTextArea")); // NOI18N
area.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(NotifyDescriptor.class, "ACD_NotifyDescriptor_MessageJTextArea")); // NOI18N
- newMessage = area;
+ JScrollPane sp = new JScrollPane(area);
+ sp.setBorder(BorderFactory.createEmptyBorder());
+ sp.setPreferredSize(new Dimension(SIZE_PREFERRED_WIDTH, SIZE_PREFERRED_HEIGHT));
+ newMessage = sp;
}
message = newMessage;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists