com.mucommander.ui.notifier
Class AbstractNotifier

java.lang.Object
  extended by com.mucommander.ui.notifier.AbstractNotifier
All Implemented Interfaces:
NotificationTypes
Direct Known Subclasses:
GrowlNotifier, SystemTrayNotifier

public abstract class AbstractNotifier
extends java.lang.Object
implements NotificationTypes

AbstractNotifier is a generic representation of a system notifier. It also provides factory methods to retrieve the current platform's notifier instance, if there is one.

A notifier serves the purpose of displaying notifications to the screen, to inform the user of an event when the application is not visible (in the background).

The notifier instance returnd by getNotifier() is platform-dependent. At this time, two notifier implementations are available:

Author:
Maxence Bernard

Field Summary
 
Fields inherited from interface com.mucommander.ui.notifier.NotificationTypes
NOTIFICATION_TYPE_JOB_COMPLETED, NOTIFICATION_TYPE_JOB_ERROR
 
Constructor Summary
AbstractNotifier()
           
 
Method Summary
 void displayBackgroundNotification(int notificationType, java.lang.String title, java.lang.String description)
          Displays a notification with the specified type, title and description and returns true if the notification could be displayed.
abstract  boolean displayNotification(int notificationType, java.lang.String title, java.lang.String description)
          Displays a notification with the specified type, title and description and returns true if the notification could be displayed.
static AbstractNotifier getNotifier()
          Returns an AbstractNotifier instance that can be used on the current platform, null if none is available.
abstract  java.lang.String getPrettyName()
          Returns a pretty name for the underlying notification system that can be displayed to the end user.
static boolean isAvailable()
          Returns true if an AbstractNotifier instance is available.
abstract  boolean isEnabled()
          Returns true if this notifier is enabled and ready to display notifications.
abstract  boolean setEnabled(boolean enabled)
          Enables/disables this notifier and returns true if the operation succeeded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractNotifier

public AbstractNotifier()
Method Detail

isAvailable

public static boolean isAvailable()
Returns true if an AbstractNotifier instance is available. In other words, if true is returned, getNotifier() will return a non-null value.

Returns:
true if an AbstractNotifier instance is available

getNotifier

public static AbstractNotifier getNotifier()
Returns an AbstractNotifier instance that can be used on the current platform, null if none is available. Note that the returned AbstractNotifier must be enabled before it can be used, which is not guaranteed to succeed.

Returns:
an AbstractNotifier instance that can be used on the current platform, null if none is available

displayBackgroundNotification

public void displayBackgroundNotification(int notificationType,
                                          java.lang.String title,
                                          java.lang.String description)
Displays a notification with the specified type, title and description and returns true if the notification could be displayed. The notification will not be displayed if the current muCommander window (or one of its child windows) is presently in the foreground, so that the user doesn't get notified for things that he/she can already see on the screen.

The notification will not be displayed if:

  • muCommander is in the foreground
  • this notifier is not enabled
  • the notification could not be delivered because of an error

Note that this method is executed in a separate thread after all pending Swing events have been processed, to ensure in the event of a window being made inactive that the notification will not be triggered. This method immediately return s(i.e. does not wait for pending events) and thus is not be able to return if the notification was displayed or not, unlike displayNotification(int, String, String).

Parameters:
notificationType - one of the available notification types, see NotificationTypes for possible values
title - the title of the notification to display
description - the description of the notification to display

setEnabled

public abstract boolean setEnabled(boolean enabled)
Enables/disables this notifier and returns true if the operation succeeded. A typical case for returning false, is when the underlying notification system (e.g. Growl under Mac OS X) could not be reached.

Parameters:
enabled - true to enable this notifier, false to disable it
Returns:
true if the operation succeeded

isEnabled

public abstract boolean isEnabled()
Returns true if this notifier is enabled and ready to display notifications.

Returns:
true if this notifier is enabled and ready to display notifications

displayNotification

public abstract boolean displayNotification(int notificationType,
                                            java.lang.String title,
                                            java.lang.String description)
Displays a notification with the specified type, title and description and returns true if the notification could be displayed. Unlike displayBackgroundNotification(int, String, String), the notification will be attempted for display even if muCommander is currently in the foreground.

Returns true if the notification could be displayed, false if:

  • this notifier is not enabled
  • the notification could not be delivered because of an error

Parameters:
notificationType - one of the available notification types, see NotificationTypes for possible values
title - the title of the notification to display
description - the description of the notification to display
Returns:
true if the notification was properly sent, false otherwise

getPrettyName

public abstract java.lang.String getPrettyName()
Returns a pretty name for the underlying notification system that can be displayed to the end user.

Returns:
a pretty name for the underlying notification system


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard