Using Mylyn Notifications

A couple of years ago I wrote briefly about how to implement desktop notifications using a feature in Mylyn Commons. Since then the notification system in Mylyn has improved. In the 3.5 release there is now a extensible framework for handling and configuring notifications. While this API is still provisional I see no harm in using it as long as you’re aware of the potential consequences. I also think some feedback (and patches) from early adopters would be good. If you’re interested in the background story, take a look at these Eclipse bugs.

The org.eclipse.mylyn.commons.notifications.notifications extension point allows four extension types: category, event, eventMapping and sink. The category is used simply to organize the various events. Event is used to declare the event types and add some GUI attributes. The eventMapping is used for assigning default event type handlers. And lastly a sink is used to declare a mechanism that will handle the event.

If want to use a popup notification sink there is no longer a need to implement it yourself. You start by declaring the event type itself (a existing category is reused). An added benefit is that you get preference settings for configuring notifications.

In order to display the popup you will also have to implement an instance of AbstractNotification and trigger the notification.

In Mylyn Builds we demonstrate use of this framework where both a popup and a special service message inside a view are used. Check out the source code for details. Also take a look at the extension point documentation.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.