Search in sources :

Example 1 with NSUserNotificationCenter

use of net.hearthstats.osx.jna.NSUserNotificationCenter in project HearthStats.net-Uploader by HearthStats.

the class OsxNotificationQueue method add.

@Override
public void add(String header, String message, boolean allowFocus) {
    debugLog.debug("    Showing OS X notification \"{}\", \"{}\"", header, message);
    final NSAutoreleasePool pool = NSAutoreleasePool.new_();
    try {
        NSUserNotification nsUserNotification = NSUserNotification.CLASS.alloc();
        nsUserNotification.setTitle(header);
        nsUserNotification.setSubtitle(message);
        NSUserNotificationCenter defaultNotificationCenter = NSUserNotificationCenter.CLASS.defaultUserNotificationCenter();
        defaultNotificationCenter.setDelegate(defaultNotificationCenter);
        defaultNotificationCenter.deliverNotification(nsUserNotification);
    } finally {
        pool.drain();
    }
}
Also used : NSAutoreleasePool(org.rococoa.cocoa.foundation.NSAutoreleasePool) NSUserNotificationCenter(net.hearthstats.osx.jna.NSUserNotificationCenter) NSUserNotification(net.hearthstats.osx.jna.NSUserNotification)

Example 2 with NSUserNotificationCenter

use of net.hearthstats.osx.jna.NSUserNotificationCenter in project HearthStats.net-Uploader by HearthStats.

the class OsxNotificationQueue method clearAllNotifications.

@Override
public void clearAllNotifications() {
    debugLog.debug("    Clearing all notifications");
    final NSAutoreleasePool pool = NSAutoreleasePool.new_();
    try {
        NSUserNotificationCenter defaultNotificationCenter = NSUserNotificationCenter.CLASS.defaultUserNotificationCenter();
        defaultNotificationCenter.removeAllDeliveredNotifications();
    } finally {
        pool.drain();
    }
}
Also used : NSAutoreleasePool(org.rococoa.cocoa.foundation.NSAutoreleasePool) NSUserNotificationCenter(net.hearthstats.osx.jna.NSUserNotificationCenter)

Aggregations

NSUserNotificationCenter (net.hearthstats.osx.jna.NSUserNotificationCenter)2 NSAutoreleasePool (org.rococoa.cocoa.foundation.NSAutoreleasePool)2 NSUserNotification (net.hearthstats.osx.jna.NSUserNotification)1