org.rococoa.contrib.growl
Class Growl

java.lang.Object
  extended by org.rococoa.contrib.growl.Growl

public final class Growl
extends Object

A class that encapsulates the work of talking to Growl.

Version:
$Id: Growl.java,v 1.0 Mar 26, 2009 12:24:28 PM haraldk Exp$
Author:
Karl Adam (original code using CocoaJavaBridge), Harald Kuhr (port to Rococoa)., last modified by $Author: haraldk$

Field Summary
static String GROWL_APP_ICON
          Ticket key for the application icon.
static String GROWL_APP_NAME
          Ticket key for the application name.
static String GROWL_APP_REGISTRATION
          The name of the growl registration notification for DNC.
static String GROWL_NOTIFICATION
          The name of the growl notification for DNC.
static String GROWL_NOTIFICATION_APP_ICON
          Notification key for the application icon.
static String GROWL_NOTIFICATION_DESCRIPTION
          Notification key for the description.
static String GROWL_NOTIFICATION_ICON
          Notification key for the icon.
static String GROWL_NOTIFICATION_IDENTIFIER
          Notification key for the identifier.
static String GROWL_NOTIFICATION_NAME
          Notification key for the name.
static String GROWL_NOTIFICATION_STICKY
          Notification key for the sticky flag.
static String GROWL_NOTIFICATION_TITLE
          Notification key for the title.
static String GROWL_NOTIFICATIONS_ALL
          Ticket key for all notifactions.
static String GROWL_NOTIFICATIONS_DEFAULT
          Ticket key for the default notifactions.
 
Constructor Summary
Growl(String inAppName, List<String> inAllNotes, List<String> inDefNotes)
          Convenience method to contruct a growl instance, defers to Growl(String inAppName, NSData inImageData, NSArray inAllNotes, NSArray inDefNotes, boolean registerNow) with the arrays passed here and empty Data for the icon.
Growl(String inAppName, NSImage inImage)
          Convenience method to contruct a growl instance, defers to Growl(String inAppName, NSData inImageData, NSArray inAllNotes, NSArray inDefNotes, boolean registerNow) with empty arrays for your notifications.
Growl(String inAppName, NSImage inImage, List<String> inAllNotes, List<String> inDefNotes, boolean registerNow)
          Convenience method to contruct a growl instance, defers to Growl(String inAppName, NSData inImageData, NSArray inAllNotes, NSArray inDefNotes, boolean registerNow) with empty arrays for your notifications.
 
Method Summary
 List<String> allowedNotifications()
          Accessor for the Array of allowed Notifications returned an NSArray
 String applicationName()
          Accessor for The currently set "Application" Name
 List<String> defaultNotifications()
          Accessor for the Array of default Notifications returned as an NSArray
 void postNotification(String inNotificationName, NSImage inIcon, String inTitle, String inDescription, NSDictionary inExtraInfo)
          Convenience method that defers to postNotificationGrowlOf(String inNotificationName, NSData inIconData, String inTitle, String inDescription, NSDictionary inExtraInfo, boolean inSticky, String inIdentifier).
 void postNotification(String inNotificationName, NSImage inIcon, String inTitle, String inDescription, NSDictionary inExtraInfo, boolean inSticky)
          Convenience method that defers to postNotificationGrowlOf(String inNotificationName, NSData inIconData, String inTitle, String inDescription, NSDictionary inExtraInfo, boolean inSticky, String inIdentifier).
 void postNotification(String inNotificationName, NSImage inIcon, String inTitle, String inDescription, NSDictionary inExtraInfo, boolean inSticky, String inIdentifier)
          The fun part is actually sending those notifications we worked so hard for so here we let growl know about things we think the user would like, and growl decides if that is the case.
 void postNotification(String inNotificationName, String inTitle, String inDescription)
          Convenienve method that defers to postNotificationGrowlOf(String inNotificationName, NSData inIconData, String inTitle, String inDescription, NSDictionary inExtraInfo, boolean inSticky, String inIdentifier) with null passed for icon, extraInfo and identifier arguments
 void postNotification(String inNotificationName, String inTitle, String inDescription, boolean inSticky)
          Convenience method that defers to postNotificationGrowlOf(String inNotificationName, NSData inIconData, String inTitle, String inDescription, NSDictionary inExtraInfo, boolean inSticky) with null passed for icon and extraInfo arguments.
 boolean register()
          Register all our notifications with Growl, this should only be called once.
 void setAllowedNotifications(List<String> inAllNotes)
          Set the list of allowed Notifications
 void setApplicationName(String inAppName)
          Sets The name of the Application talking to growl
 void setDefaultNotifications(List<String> inDefNotes)
          Set the list of Default Notfiications
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GROWL_APP_REGISTRATION

public static final String GROWL_APP_REGISTRATION
The name of the growl registration notification for DNC.

See Also:
Constant Field Values

GROWL_APP_NAME

public static final String GROWL_APP_NAME
Ticket key for the application name.

See Also:
Constant Field Values

GROWL_APP_ICON

public static final String GROWL_APP_ICON
Ticket key for the application icon.

See Also:
Constant Field Values

GROWL_NOTIFICATIONS_DEFAULT

public static final String GROWL_NOTIFICATIONS_DEFAULT
Ticket key for the default notifactions.

See Also:
Constant Field Values

GROWL_NOTIFICATIONS_ALL

public static final String GROWL_NOTIFICATIONS_ALL
Ticket key for all notifactions.

See Also:
Constant Field Values

GROWL_NOTIFICATION

public static final String GROWL_NOTIFICATION
The name of the growl notification for DNC.

See Also:
Constant Field Values

GROWL_NOTIFICATION_NAME

public static final String GROWL_NOTIFICATION_NAME
Notification key for the name.

See Also:
Constant Field Values

GROWL_NOTIFICATION_TITLE

public static final String GROWL_NOTIFICATION_TITLE
Notification key for the title.

See Also:
Constant Field Values

GROWL_NOTIFICATION_DESCRIPTION

public static final String GROWL_NOTIFICATION_DESCRIPTION
Notification key for the description.

See Also:
Constant Field Values

GROWL_NOTIFICATION_ICON

public static final String GROWL_NOTIFICATION_ICON
Notification key for the icon.

See Also:
Constant Field Values

GROWL_NOTIFICATION_APP_ICON

public static final String GROWL_NOTIFICATION_APP_ICON
Notification key for the application icon.

See Also:
Constant Field Values

GROWL_NOTIFICATION_STICKY

public static final String GROWL_NOTIFICATION_STICKY
Notification key for the sticky flag.

See Also:
Constant Field Values

GROWL_NOTIFICATION_IDENTIFIER

public static final String GROWL_NOTIFICATION_IDENTIFIER
Notification key for the identifier.

See Also:
Constant Field Values
Constructor Detail

Growl

public Growl(String inAppName,
             NSImage inImage)
Convenience method to contruct a growl instance, defers to Growl(String inAppName, NSData inImageData, NSArray inAllNotes, NSArray inDefNotes, boolean registerNow) with empty arrays for your notifications.

Parameters:
inAppName - The Name of your "application"
inImage - The NSImage Icon for your Application

Growl

public Growl(String inAppName,
             List<String> inAllNotes,
             List<String> inDefNotes)
Convenience method to contruct a growl instance, defers to Growl(String inAppName, NSData inImageData, NSArray inAllNotes, NSArray inDefNotes, boolean registerNow) with the arrays passed here and empty Data for the icon.

Parameters:
inAppName - The Name of your "Application"
inAllNotes - A String Array with the name of all your notifications
inDefNotes - A String Array with the na,es of the Notifications on by default

Growl

public Growl(String inAppName,
             NSImage inImage,
             List<String> inAllNotes,
             List<String> inDefNotes,
             boolean registerNow)
Convenience method to contruct a growl instance, defers to Growl(String inAppName, NSData inImageData, NSArray inAllNotes, NSArray inDefNotes, boolean registerNow) with empty arrays for your notifications.

Parameters:
inAppName - The Name of your "Application"
inImage - Your "Application"'s icon, or null to use your application's default application icon.
inAllNotes - The NSArray of Strings of all your Notifications
inDefNotes - The NSArray of Strings of your default Notifications
registerNow - Since we have all the necessary info we can go ahead and register
Method Detail

register

public final boolean register()
Register all our notifications with Growl, this should only be called once.

Returns:
true.

postNotification

public void postNotification(String inNotificationName,
                             NSImage inIcon,
                             String inTitle,
                             String inDescription,
                             NSDictionary inExtraInfo,
                             boolean inSticky,
                             String inIdentifier)
The fun part is actually sending those notifications we worked so hard for so here we let growl know about things we think the user would like, and growl decides if that is the case.

Parameters:
inNotificationName - The name of one of the notifications we told growl about.
inIcon - The NSImage for the icon for this notification, can be null
inTitle - The Title of our Notification as Growl will show it
inDescription - The Description of our Notification as Growl will display it
inExtraInfo - Growl is flexible and allows Display Plugins to do as they please with thier own special keys and values, you may use them here. These may be ignored by either the user's preferences or the current Display Plugin. This can be null
inSticky - Whether the Growl notification should be sticky
inIdentifier - Notification identifier for coalescing. This can be null.
Throws:
IllegalArgumentException - When a notification is not known

postNotification

public void postNotification(String inNotificationName,
                             NSImage inIcon,
                             String inTitle,
                             String inDescription,
                             NSDictionary inExtraInfo,
                             boolean inSticky)
Convenience method that defers to postNotificationGrowlOf(String inNotificationName, NSData inIconData, String inTitle, String inDescription, NSDictionary inExtraInfo, boolean inSticky, String inIdentifier). This is primarily for compatibility with older code

Parameters:
inNotificationName - The name of one of the notifications we told growl about.
inIcon - The NSData for the icon for this notification, can be null
inTitle - The Title of our Notification as Growl will show it
inDescription - The Description of our Notification as Growl will display it
inExtraInfo - Growl is flexible and allows Display Plugins to do as they please with their own special keys and values, you may use them here. These may be ignored by either the user's preferences or the current Display Plugin. This can be null.
inSticky - Whether the Growl notification should be sticky.
Throws:
IllegalArgumentException - When a notification is not known

postNotification

public void postNotification(String inNotificationName,
                             NSImage inIcon,
                             String inTitle,
                             String inDescription,
                             NSDictionary inExtraInfo)
Convenience method that defers to postNotificationGrowlOf(String inNotificationName, NSData inIconData, String inTitle, String inDescription, NSDictionary inExtraInfo, boolean inSticky, String inIdentifier). This is primarily for compatibility with older code

Parameters:
inNotificationName - The name of one of the notifications we told growl about.
inIcon - The NSData for the icon for this notification, can be null
inTitle - The Title of our Notification as Growl will show it
inDescription - The Description of our Notification as Growl will display it
inExtraInfo - Growl is flexible and allows Display Plugins to do as they please with their own special keys and values, you may use them here. These may be ignored by either the user's preferences or the current Display Plugin. This can be null.
Throws:
IllegalArgumentException - When a notification is not known

postNotification

public void postNotification(String inNotificationName,
                             String inTitle,
                             String inDescription)
Convenienve method that defers to postNotificationGrowlOf(String inNotificationName, NSData inIconData, String inTitle, String inDescription, NSDictionary inExtraInfo, boolean inSticky, String inIdentifier) with null passed for icon, extraInfo and identifier arguments

Parameters:
inNotificationName - The name of one of the notifications we told growl about.
inTitle - The Title of our Notification as Growl will show it
inDescription - The Description of our Notification as Growl will display it
Throws:
IllegalArgumentException - When a notification is not known

postNotification

public void postNotification(String inNotificationName,
                             String inTitle,
                             String inDescription,
                             boolean inSticky)
Convenience method that defers to postNotificationGrowlOf(String inNotificationName, NSData inIconData, String inTitle, String inDescription, NSDictionary inExtraInfo, boolean inSticky) with null passed for icon and extraInfo arguments.

Parameters:
inNotificationName - The name of one of the notifications we told growl about.
inTitle - The Title of our Notification as Growl will show it
inDescription - The Description of our Notification as Growl will display it
inSticky - Whether our notification should be sticky
Throws:
IllegalArgumentException - When a notification is not known

applicationName

public String applicationName()
Accessor for The currently set "Application" Name

Returns:
String Application Name

allowedNotifications

public List<String> allowedNotifications()
Accessor for the Array of allowed Notifications returned an NSArray

Returns:
the array of allowed notifications.

defaultNotifications

public List<String> defaultNotifications()
Accessor for the Array of default Notifications returned as an NSArray

Returns:
the array of default notifications.

setApplicationName

public void setApplicationName(String inAppName)
Sets The name of the Application talking to growl

Parameters:
inAppName - The Application Name
Throws:
IllegalStateException - if already registered

setAllowedNotifications

public void setAllowedNotifications(List<String> inAllNotes)
Set the list of allowed Notifications

Parameters:
inAllNotes - The array of allowed Notifications
Throws:
IllegalStateException - if already registered

setDefaultNotifications

public void setDefaultNotifications(List<String> inDefNotes)
Set the list of Default Notfiications

Parameters:
inDefNotes - The default Notifications
Throws:
IllegalArgumentException - when an element of the array is not in the allowedNotifications
IllegalStateException - if already registered


Copyright © 2012. All Rights Reserved.