com.sun.rave.designtime
Class Result


java.lang.Object

  extended bycom.sun.rave.designtime.Result

Direct Known Subclasses:
CustomizerResult

public class Result
extends java.lang.Object

A Result object represents the logical result of an operation. The SUCCESS and FAILURE Result objects are useful when returning an otherwise empty result with no user messages. null Results should never be returned, but if one is, it will be treated as Result.SUCCESS with no messages.

Some Result objects may contain user messages, returned by the 'getMessages()' method. These messages will be displayed to the user in one of three ways:

Status Bar The Status Bar displays very low-importance messages. Any ResultMessage objects of type ResultMessage.TYPE_INFORMATION will be displayed here, as long as there are no result options returned from the 'getResultOptions()' method.
Message Window The Message Window displays more important messages than the status bar, as they are persisted until the user clears the message window. Any ResultMessage objects of type ResultMessage.TYPE_WARNING will be displayed here, as long as there are no result options returned from the 'getResultOptions()' method.
Message Dialog A pop-up modal Message Dialog displays the most important messages, as the user must stop work to 'handle' the dialog. Any ResultMessage objects of type ResultMessage.TYPE_CRITICAL will be displayed in an modal dialog. If there are any result options returned from the 'getResultOptions()' method, they will be displayed as buttons in the dialog, otherwise a default 'OK' button will be displayed. If a Result contains messages that are less than TYPE_CRITICAL, but result options are included - the messages will be 'upgraded' and displayed in the model dialog, as if they were TYPE_CRITICAL.

The three most important methods of this class are: 'isSuccess()', 'getMessages()', and 'getMessageOptions()'. These are called by the IDE to investigate the details of a Result object.

Version:
1.0
Author:
Joe Nuxoll

Field Summary
protected  java.lang.String dialogTitle
          Protected storage for the 'resultDialogTitle' property
static Result FAILURE
          Common instance of a failed result object
protected  java.lang.String helpKey
          Protected storage for the 'dialogHelpKey' property
protected  java.util.ArrayList messages
          Protected storage for the message list (ResultMessage[])
protected  java.util.ArrayList options
          Protected storage for the result option list (DisplayAction[])
protected  boolean success
          Protected storage for the 'success' property
static Result SUCCESS
          Common instance of a successful result object
 
Constructor Summary
Result(boolean success)
          Constructs a Result object with the specified success status
Result(boolean success, ResultMessage message)
          Constructs a Result object with the specified success status and message
Result(boolean success, ResultMessage[] messages)
          Constructs a Result object with the specified success status and messages
Result(boolean success, ResultMessage[] messages, DisplayAction[] options)
          Constructs a Result object with the specified success status, messages, and options
 
Method Summary
 void addMessage(ResultMessage message)
          Adds a ResultMessage to this Result to be displayed to the user
 void addMessages(ResultMessage[] messages)
          Adds an array of ResultMessage to this Result to be displayed to the user
 void addResultOption(DisplayAction option)
          Adds a DisplayAction to this Result to be displayed to the user as an option button in a dialog
 void addResultOptions(DisplayAction[] options)
          Adds a set of DisplayAction(s) to this Result to be displayed to the user as option buttons in a dialog
 java.lang.String getDialogHelpKey()
          Returns the 'dialogHelpKey' property.
 java.lang.String getDialogTitle()
          Returns the 'dialogTitle' property.
 int getMessageCount()
          Returns the count of ResultMessage(s) in this Result
 ResultMessage[] getMessages()
          Returns an (optional) set of ResultMessage objects from the completed operation.
 int getResultOptionCount()
          Returns the count of DisplayAction(s) in this Result which will be displayed to the user as option buttons in a dialog
 DisplayAction[] getResultOptions()
          Returns an (optional) set of DisplayAction objects representing options in a dialog box for the user.
 boolean isSuccess()
          Returns true if the operation represented by this Result object was successful
 void removeMessage(ResultMessage message)
          Removes a ResultMessage from the set to display to the user
 void removeMessages(ResultMessage[] messages)
          Removes an array of ResultMessage(s) from the set to display to the user
 void removeResultOption(DisplayAction option)
          Removes a DisplayAction (option button in a dialog) from this Result
 void removeResultOptions(DisplayAction[] options)
          Removes an array of DisplayAction(s) (option buttons in a dialog) from this Result
 void setDialogHelpKey(java.lang.String helpKey)
          Sets the 'dialogHelpKey' property.
 void setDialogTitle(java.lang.String dialogTitle)
          Sets the 'dialogTitle' property.
 void setSuccess(boolean success)
          Sets the success state of this Result
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dialogTitle


protected java.lang.String dialogTitle
Protected storage for the 'resultDialogTitle' property


FAILURE


public static final Result FAILURE
Common instance of a failed result object


helpKey


protected java.lang.String helpKey
Protected storage for the 'dialogHelpKey' property


messages


protected java.util.ArrayList messages
Protected storage for the message list (ResultMessage[])


options


protected java.util.ArrayList options
Protected storage for the result option list (DisplayAction[])


success


protected boolean success
Protected storage for the 'success' property


SUCCESS


public static final Result SUCCESS
Common instance of a successful result object

Constructor Detail

Result


public Result(boolean success)
Constructs a Result object with the specified success status

Parameters:
success - true if successful, false if not

Result


public Result(boolean success,
              ResultMessage message)
Constructs a Result object with the specified success status and message

Parameters:
success - true if successful, false if not
message - A ResultMessage to display to the user

Result


public Result(boolean success,
              ResultMessage[] messages)
Constructs a Result object with the specified success status and messages

Parameters:
success - true if successful, false if not
messages - A set of ResultMessage(s) to display to the user

Result


public Result(boolean success,
              ResultMessage[] messages,
              DisplayAction[] options)
Constructs a Result object with the specified success status, messages, and options

Parameters:
success - true if successful, false if not
messages - A set of ResultMessage(s) to display to the user
options - A set of DisplayAction(s) to present to the user as option buttons
Method Detail

addMessage


public void addMessage(ResultMessage message)
Adds a ResultMessage to this Result to be displayed to the user

Parameters:
message - The ResultMessage to add

addMessages


public void addMessages(ResultMessage[] messages)
Adds an array of ResultMessage to this Result to be displayed to the user

Parameters:
messages - The array of ResultMessage(s) to add

addResultOption


public void addResultOption(DisplayAction option)
Adds a DisplayAction to this Result to be displayed to the user as an option button in a dialog

Parameters:
option - The DisplayAction to add as an option button

addResultOptions


public void addResultOptions(DisplayAction[] options)
Adds a set of DisplayAction(s) to this Result to be displayed to the user as option buttons in a dialog

Parameters:
options - The DisplayAction(s) to add as option buttons

getDialogHelpKey


public java.lang.String getDialogHelpKey()
Returns the 'dialogHelpKey' property. The Result can only trigger a dialog if there is a ResultMessage of TYPE_CRITICAL or there are result options to display.

Returns:
The help key for the result dialog

getDialogTitle


public java.lang.String getDialogTitle()
Returns the 'dialogTitle' property. The Result can only trigger a dialog if there is a ResultMessage of TYPE_CRITICAL or there are result options to display.

Returns:
The title for the result dialog

getMessageCount


public int getMessageCount()
Returns the count of ResultMessage(s) in this Result

Returns:
the count of ResultMessage(s) in this Result

getMessages


public ResultMessage[] getMessages()
Returns an (optional) set of ResultMessage objects from the completed operation. Any ResultMessage objects will be displayed to the user either via the status-line, message window, or in a dialog - depending on several conditions outlined above.

Returns:
An array of ResultMessage objects, or null if there the operation produced no messages

getResultOptionCount


public int getResultOptionCount()
Returns the count of DisplayAction(s) in this Result which will be displayed to the user as option buttons in a dialog

Returns:
The count of option buttons to show in the dialog

getResultOptions


public DisplayAction[] getResultOptions()
Returns an (optional) set of DisplayAction objects representing options in a dialog box for the user. If the returned array is non-null and has more than zero elements, a dialog box will automatically be shown to the user with a button for each returned DisplayAction. When the user 'clicks' a particular button, the DisplayAction will be 'invoked()'.

Returns:
An array of DisplayAction objects representing buttons in a dialog to show the user, or null

isSuccess


public boolean isSuccess()
Returns true if the operation represented by this Result object was successful

Returns:
true if the operation was successful, false if not

removeMessage


public void removeMessage(ResultMessage message)
Removes a ResultMessage from the set to display to the user

Parameters:
message - the ResultMessage to remove from the set

removeMessages


public void removeMessages(ResultMessage[] messages)
Removes an array of ResultMessage(s) from the set to display to the user

Parameters:
messages - the ResultMessage(s) to remove from the set

removeResultOption


public void removeResultOption(DisplayAction option)
Removes a DisplayAction (option button in a dialog) from this Result

Parameters:
option - The DisplayAction (option button) to remove

removeResultOptions


public void removeResultOptions(DisplayAction[] options)
Removes an array of DisplayAction(s) (option buttons in a dialog) from this Result

Parameters:
options - The DisplayAction(s) (option buttons) to remove

setDialogHelpKey


public void setDialogHelpKey(java.lang.String helpKey)
Sets the 'dialogHelpKey' property. The Result can only trigger a dialog if there is a ResultMessage of TYPE_CRITICAL or there are result options to display.


setDialogTitle


public void setDialogTitle(java.lang.String dialogTitle)
Sets the 'dialogTitle' property. The Result can only trigger a dialog if there is a ResultMessage of TYPE_CRITICAL or there are result options to display.

Parameters:
dialogTitle - The desired title for the result dialog

setSuccess


public void setSuccess(boolean success)
Sets the success state of this Result

Parameters:
success - the success state of this Result