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.

Bug 192089 - org.netbeans.core.ui.notifications.FlashingIcon has hardcoded dependency on NotificationDisplayerImpl, crashes with custom NotificationDisplayer
Summary: org.netbeans.core.ui.notifications.FlashingIcon has hardcoded dependency on N...
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 7.0
Hardware: PC All
: P3 normal (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-18 07:47 UTC by emi
Modified: 2011-07-18 14:55 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Patch to avoid the ClassCastException (981 bytes, patch)
2010-11-18 07:55 UTC, emi
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description emi 2010-11-18 07:47:52 UTC
Hy,

I've written my own NotificationDisplayer which acts as a Growl bridge on OSX. You may download the plugin here: http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=34354

While developing the plugin (and after install) I've seen the stacktrace at the bottom.

The problem seems to be that FlashingIcon uses NotificationDisplayerImpl directly and crashes if another NotificationDisplayer implementation exists in the lookup (due to the class cast in NotificationDisplayerImpl.getInstance).

It would be nice for FlashingIcon to degrade gracefully when there is an alternate NotificationDisplayer implementation.

In my module I just remove org.netbeans.core.ui.notifications.StatusLineElement so that FlashingIcon isn't used anymore but the exception could still show up after the install (without a restart) since the FlashingIcon is already in the status bar and it would at least be called in removeNotify().

I was thinking that perhaps I could make FlashingIcon work with my NotificationDisplayer implementation, but it seems to need a much more enriched API (.size, property listener, etc) which would just complicate things as I can't implement those at all (Growl architecture is a bit different).

So all I think could be done is check in FlashingIcon if there isn't another NotificationDisplayer implementation and then ignore everything.

Right now I've marked my module that it needs an IDE restart so I think the stacktrace should be visible to users anymore and I'm marking this as a P4, but still posting it as it might still give you some hints.

java.lang.ClassCastException: ro.emilianbold.notifications.GrowlNotification cannot be cast to org.netbeans.core.ui.notifications.NotificationDisplayerImpl
    at org.netbeans.core.ui.notifications.NotificationDisplayerImpl.getInstance(NotificationDisplayerImpl.java:93)
    at org.netbeans.core.ui.notifications.FlashingIcon.removeNotify(FlashingIcon.java:118)
    at java.awt.Container.removeNotify(Container.java:2653)
    at javax.swing.JComponent.removeNotify(JComponent.java:4701)
    at java.awt.Container.remove(Container.java:1140)
    at java.awt.Container.remove(Container.java:1198)
    at org.netbeans.core.windows.view.ui.MainWindow.decoratePanel(MainWindow.java:282)
    at org.netbeans.core.windows.view.ui.MainWindow.access$300(MainWindow.java:85)
    at org.netbeans.core.windows.view.ui.MainWindow$StatusLineElementsListener$1.run(MainWindow.java:327)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:633)
    at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:138)
[catch] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:205)
    at java.awt.Dialog$1.run(Dialog.java:1046)
    at java.awt.Dialog$3.run(Dialog.java:1098)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.Dialog.show(Dialog.java:1096)
    at org.netbeans.core.windows.services.NbPresenter.superShow(NbPresenter.java:1006)
    at org.netbeans.core.windows.services.NbPresenter.doShow(NbPresenter.java:1040)
    at org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:1028)
    at org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:121)
    at org.openide.util.Mutex.doEventAccess(Mutex.java:1361)
    at org.openide.util.Mutex.readAccess(Mutex.java:271)
    at org.netbeans.core.windows.services.NbPresenter.show(NbPresenter.java:1013)
    at java.awt.Component.show(Component.java:1563)
    at java.awt.Component.setVisible(Component.java:1515)
    at java.awt.Window.setVisible(Window.java:842)
    at java.awt.Dialog.setVisible(Dialog.java:986)
    at org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard.implInvokeWizard(InstallUnitWizard.java:93)
    at org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard.invokeWizard(InstallUnitWizard.java:78)
    at org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard.invokeWizard(InstallUnitWizard.java:73)
    at org.netbeans.modules.autoupdate.ui.UnitTab$LocalUpdateAction.performerImpl(UnitTab.java:1271)
    at org.netbeans.modules.autoupdate.ui.UnitTab$TabAction.actionPerformed(UnitTab.java:1044)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:6352)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6117)
    at java.awt.Container.processEvent(Container.java:2085)
    at java.awt.Component.dispatchEventImpl(Component.java:4714)
    at java.awt.Container.dispatchEventImpl(Container.java:2143)
    at java.awt.Component.dispatchEvent(Component.java:4544)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4621)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
    at java.awt.Container.dispatchEventImpl(Container.java:2129)
    at java.awt.Window.dispatchEventImpl(Window.java:2478)
    at java.awt.Component.dispatchEvent(Component.java:4544)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
    at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:138)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Comment 1 emi 2010-11-18 07:55:14 UTC
Created attachment 103060 [details]
Patch to avoid the ClassCastException
Comment 2 emi 2010-11-18 07:56:25 UTC
Marking this a P2 since I've also posted a patch that should fix the removeNotify() problem because there is an explicit check for null in there.
Comment 3 Stanislav Aubrecht 2010-11-23 11:56:02 UTC
core-main c200773b4366

thanks for the patch
Comment 4 Quality Engineering 2010-11-30 06:13:01 UTC
Integrated into 'main-golden', will be available in build *201011300001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/c200773b4366
User: S. Aubrecht <saubrecht@netbeans.org>
Log: #192089 - CCE
Comment 5 Geertjan Wielenga 2011-07-01 12:16:58 UTC
I don't see how this fixes the problem. I want my own NotificationDisplayer to replace the NotificationDisplayerImpl provided by NetBeans. Currently that's not possible. Lookup.getDefault should be used to find the registered NotificationDisplayer.
Comment 6 emi 2011-07-01 13:56:45 UTC
You are correct, my patch doesn't fix the whole design, just the CCE. It was enough to get NBnotify running and it should work in your case too.

One problem you have to think about is what happens if you have the default NotificationDisplayer and you install the module with yours -- that's then the CCE happened.

If you get into redesigning the default NotificationDisplayer and the NotificationDisplayer API, please let me know as I think there are multiple things wrong with the current API and usage style that make it quite hard to bridge towards other notification systems.
Comment 7 Stanislav Aubrecht 2011-07-18 14:55:31 UTC
(In reply to comment #5)
> I don't see how this fixes the problem. I want my own NotificationDisplayer to
> replace the NotificationDisplayerImpl provided by NetBeans. Currently that's
> not possible. Lookup.getDefault should be used to find the registered
> NotificationDisplayer.

you can provide your own NotificationDisplayer but then you have to write your own UI for it as well. there's no API contract allowing you to reuse notification UI impl classes