talx x1.0.5

talx.controller
Class HandlerUtils

java.lang.Object
  extended bytalx.controller.HandlerUtils
All Implemented Interfaces:
ControllerConstants, GUIStateConstants, MailConstants, SearchConstants

public class HandlerUtils
extends java.lang.Object
implements GUIStateConstants, SearchConstants, ControllerConstants, MailConstants

Utility functions for handler classes. This class defined an API of handler behaviors that can be shared throughout various handler sets. All handlers are encouraged to call the initialize method here.


Field Summary
 
Fields inherited from interface talx.model.GUIStateConstants
ACTIVE_COMMANDS, ARCHIVE_MESSAGE, CHOICE_DIALOG, COMPOSE_FOCUS, COMPOSE_WINDOW, COMPOSER_CAPTION, COMPOSER_DIRTY, CONFIRM_DIALOG, CURRENT_PEOPLE, CURRENT_PLAYER, DEFAULT_MESSAGE, DIALOG_FOCUS, DIALOG_TEXT, INBOX_FOCUS, INBOX_MAIL_COUNTS, INBOX_MAIL_COUNTS_ANSWERED, INBOX_MAIL_COUNTS_NEW, INBOX_PANEL, INBOX_PLAYER_CAPTIONS, NO_CHANGE, NO_MESSAGE, NO_PEOPLE, NO_PERSON, NO_PLAYER, READER_CAPTION, READER_FOCUS, READER_HEADERS, READER_WINDOW, STATE_ABBR, STATE_CONST, STATE_DESC
 
Fields inherited from interface talx.model.mail.SearchConstants
hasBeenAnswered, hasBeenSeen, hasNotBeenAnswered, hasNotBeenSeen
 
Fields inherited from interface talx.controller.ControllerConstants
EXIT_COMMAND, FILE_ATTACHMENTS_KEY, ILLEGAL_ACTION_COMMAND, LOGOUT_COMMAND, MAIL_COUNT_CHANGED_COMMAND, REMOTE_GAME_COMMAND, SAVE_COMMAND, STOP_COMMAND, TEST_COMMAND
 
Fields inherited from interface talx.util.MailConstants
ARCHIVE_ID, BOUNCE_HEADER, COMPOSE_TIME, DEFAULT_ID, ERASE_COUNTS, EXPIRATION_TIME, NO_DELETE, NO_REPLY, REMINDER
 
Constructor Summary
HandlerUtils()
           
 
Method Summary
static javax.mail.internet.MimeMessage constructMessageFromComposer(Controller c, GUIState state, javax.mail.internet.MimeBodyPart[] attachments)
          Constructs a message from the data in the composer and state.
static void handleAbort(Controller c)
          Handles aborting a composition.
static void handlePostpone(Controller c)
          Handles postponing a composition.
static void handleReply(Controller c)
          Handles replying to a message.
static void handleSend(Controller c)
          Handles sending a composition.
static void initialize(Controller c)
          Handles shared state initialization.
static GUIState setComposeCaption(GUIState s, Settings settings)
          Returns a state with an appropriate composer caption.
static void showArchive(Archive a, Controller c)
          Handles showing an archive message.
static void showGame(StartGame sg, Controller c)
          Handles showing a game screen.
static void showMailCounts(Person p, Controller c)
          Handles showing new mail counts when a PersonActionEvent occurs.
static boolean showMessage(MailBox b, Controller c)
          Handles showing a message when a mailbox is activated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HandlerUtils

public HandlerUtils()
Method Detail

initialize

public static void initialize(Controller c)
Handles shared state initialization. This method changes the controller state and fires a controller change. This method should be called by handlers that have been passed a null event. This method does: This method does not alter the focus or visibility of windows, disable any buttons or alter the GUIState's message or people.


showArchive

public static void showArchive(Archive a,
                               Controller c)
Handles showing an archive message. This method changes the controller state and fires a controller change. This method does This method does not alter the focus or visibility of windows.


showGame

public static void showGame(StartGame sg,
                            Controller c)
Handles showing a game screen. This method changes the controller state and fires a controller change. This method does This method does not alter the focus or visibility of other windows.

Throws:
java.lang.NullPointerException - if the game is not properly installed. When this happens, this method also displays that fact in the task frame. ActionHandlers should generally catch this and throw an ActionVetoExcpetion.

showMailCounts

public static void showMailCounts(Person p,
                                  Controller c)
Handles showing new mail counts when a PersonActionEvent occurs. This method changes the controller state and fires a controller change. This method does This method does not alter the focus or visibility of windows, or alter the GUIState's message or people.


showMessage

public static boolean showMessage(MailBox b,
                                  Controller c)
Handles showing a message when a mailbox is activated. This method changes the controller state and fires a controller change. This method does This method does not alter the focus. This method displays a task frame while it is in operation.

Returns:
true if a draft response exists to the message.

handleReply

public static void handleReply(Controller c)
Handles replying to a message. This method changes the controller state and fires a controller change. This method does This method does not alter the focus.


handleSend

public static void handleSend(Controller c)
Handles sending a composition. This method changes the controller state and fires a controller change. This method does This method does not alter the focus or visibility of windows.


handleAbort

public static void handleAbort(Controller c)
Handles aborting a composition. This method changes the controller state and fires a controller change. This method does This method does not alter the focus or visibility of windows.


handlePostpone

public static void handlePostpone(Controller c)
Handles postponing a composition. This method changes the controller state and fires a controller change. This method does This method does not alter the focus or visibility of windows.


constructMessageFromComposer

public static javax.mail.internet.MimeMessage constructMessageFromComposer(Controller c,
                                                                           GUIState state,
                                                                           javax.mail.internet.MimeBodyPart[] attachments)
                                                                    throws javax.mail.MessagingException
Constructs a message from the data in the composer and state. This method returns a message with the proper headers set, based on the original message, the current people, and the composer timer and deletion counts.

Parameters:
attachments - if null, the message is constructed as a single part, otherwise, the message is a multipart message with the composer text inline, and the attachments included. Notice that if attachements is empty (ie had length 0) the message is still multipart, but it has only one part.
Throws:
javax.mail.MessagingException

setComposeCaption

public static GUIState setComposeCaption(GUIState s,
                                         Settings settings)
Returns a state with an appropriate composer caption.

Parameters:
s - the state containing the appropriate list of people.
settings - the settings containing the base initiate and response captions.
Returns:
s modified to contain a composer caption appropriate to its list of people and the base captions found in settings.

talx x1.0.5

© 2001-2005 University of Oregon.
Eugene OR 97403, U.S.A. All Rights Reserved.