This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
In the NotificationDisplayer javadoc, inside the notify method text ( http://bits.netbeans.org/dev/javadoc/org-openide-awt/org/openide/awt/NotificationDisplayer.html ) it is written: "detailsAction - Action to invoke when user click details text or null.", but that is not correct! If I try to pass null to the method, I receive the following error:"NullPointerException: detailsAction cannot be null.";
Jesse, can you verify whether this is true? Or reassign to whoever can do that?
The API as defined since 6.7 onwards does specifically say null is permitted for detailsAction. It is the implementation which is incorrect. Suggest something like the following (untested): diff --git a/core.ui/src/org/netbeans/core/ui/notifications/NotificationDisplayerImpl.java b/core.ui/src/org/netbeans/core/ui/notifications/NotificationDisplayerImpl.java --- a/core.ui/src/org/netbeans/core/ui/notifications/NotificationDisplayerImpl.java +++ b/core.ui/src/org/netbeans/core/ui/notifications/NotificationDisplayerImpl.java @@ -65,6 +65,7 @@ import javax.swing.SwingUtilities; import org.openide.awt.Notification; import org.openide.awt.NotificationDisplayer; +import org.openide.util.Exceptions; import org.openide.util.Lookup; import org.openide.util.lookup.ServiceProvider; import org.openide.xml.XMLUtil; @@ -93,14 +94,7 @@ public Notification notify(String title, Icon icon, String detailsText, ActionListener detailsAction, Priority priority) { if( null == detailsText ) throw new NullPointerException("detailsText cannot be null."); //NOI18N - if( null == detailsAction ) - throw new NullPointerException("detailsAction cannot be null."); //NOI18N - try { - detailsText = XMLUtil.toElementContent(detailsText); - } catch( CharConversionException ex ) { - throw new IllegalArgumentException(ex); - } JComponent detailsComp1 = createDetails( detailsText, detailsAction ); JComponent detailsComp2 = createDetails( detailsText, detailsAction ); @@ -242,7 +236,14 @@ } private JComponent createDetails( String text, ActionListener action ) { - text = "<html><u>" + text; //NOI18N + if (action == null) { + return new JLabel(text); + } + try { + text = "<html><u>" + XMLUtil.toElementContent(detailsText); // NOI18N + } catch( CharConversionException ex ) { + Exceptions.printStackTrace(ex); + } JButton btn = new JButton(text); btn.setFocusable(false); btn.setBorder(BorderFactory.createEmptyBorder());
fixed as suggested core-main 7058b68701ea
Integrated into 'main-golden', will be available in build *200910150201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/7058b68701ea User: S. Aubrecht <saubrecht@netbeans.org> Log: #169890 - NotificationDisplayer fails to handle null detailsAction