com.ibm.as400.ui.util
Class MessageViewer

java.lang.Object
  |
  +--com.ibm.as400.ui.util.MessageViewer
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.ListSelectionListener

public class MessageViewer
extends java.lang.Object
implements javax.swing.event.ListSelectionListener

Displays a set of messages, and optionally additional message detail.

MessageViewer allows you to do the following:

MessageViewer accepts as input on creation:

Examples

The following code constructs a newly-defined panel, adds messages, sets the style and instructional text, and displays the panel.

 import com.ibm.as400.ui.framework.java.*;
  
 MessageViewer mv = new MessageViewer("Sample Messages");
 mv.addMessage("Test error message number one", "ID 1", "Detail information about error message number one. Something is very bad.");
 mv.addMessage("Test error message number two", "ID 2", "Detail information about error message number two. Something is very very bad.");
    
 mv.setStyle(MessageViewer.STYLE_OKCANCEL_DUAL);
 mv.setButtonText( MessageViewer.OK_DUAL_BUTTON, "Accept");
 mv.setButtonText( MessageViewer.CANCEL_BUTTON, "Reject");
 mv.setInstructionText("This is sample Instruction Text.  Press a button, any button");
 mv.setExitOnClose(true);
 mv.setVisible(true);
 

AS400 Messages

The standard way for AS400 Toolbox objects to provide user displayable error information is by returning one or more AS400Message objects. MessageViewer is designed to accept an AS400Message object or array as input. Detailed help for AS400 messages requires an AS400 object be provided using the setSystem method.

 import com.ibm.as400.access.*;
  
 AS400 system = new AS400("RCHASP04");
 MessageViewer mv = new MessageViewer("Test Message Viewer Title",owner);
 mv.setSystem(system);
 

Since:
v4r4

Field Summary
static java.lang.String ACTION_BUTTON
          Button identifier for the Action button.
static java.lang.String CANCEL_BUTTON
          Button identifier for the Cancel button.
static java.lang.String COPY_BUTTON
          Button identifier for the Copy button.
static java.lang.String DETAILS_BUTTON
          Button identifier for the Details button.
static java.lang.String OK_DUAL_BUTTON
          Button identifier for the dual OK button.
static java.lang.String OK_SINGLE_BUTTON
          Button identifier for the single OK button.
static int STYLE_OK_SINGLE
          Style which displays a single OK button, which can be relabelled.
static int STYLE_OKCANCEL_DUAL
          Style which displays dual buttons, an OK and a Cancel, which can be relabelled, if desired.
 
Constructor Summary
MessageViewer(java.lang.String strTitle)
          Constructs a modeless MessageViewer panel.
MessageViewer(java.lang.String strTitle, java.awt.Frame owner)
          Constructs a MessageViewer panel modal to a Frame.
MessageViewer(java.lang.String strTitle, PanelManager modalPanelManager)
          Constructs a MessageViewer panel modal to a PanelManager.
 
Method Summary
 void addActionListenerButtonAction(java.awt.event.ActionListener listener)
          Sets the listener of the Action button.
 void addActionListenerButtonCancel(java.awt.event.ActionListener listener)
          Adds an ActionListener to the CANCEL button of the STYLE_OKCANCEL_DUAL style
 void addActionListenerButtonDetails(java.awt.event.ActionListener listener)
          Sets the listener of the Details button.
 void addActionListenerButtonOKDual(java.awt.event.ActionListener listener)
          Adds an ActionListener to the OK button of the STYLE_OKCANCEL_DUAL style
 void addActionListenerButtonOKSingle(java.awt.event.ActionListener listener)
          Adds an ActionListener to the OK button of the STYLE_OK_SINGLE style
 void addMessage(AS400Message AS400msg)
          Adds a message to be displayed.
 void addMessage(java.lang.String strMessage)
          Adds a simple message to be displayed.
 void addMessage(java.lang.String strMessage, java.lang.String strID, java.lang.String strDetail)
          Adds a message to be displayed.
 void addMessage(java.lang.String strMessage, java.lang.String strID, java.lang.String strHTMLDetail, java.lang.String strAnchor)
          Adds a message to be displayed and provides HTML details.
 void addMessage(java.lang.String strMessage, java.lang.String strID, java.net.URL urlDetails)
          Adds a message to be displayed and provides a URL for details.
 void addMessages(AS400Message[] AS400msgList)
          Adds messages to be displayed.
 void addMessages(java.lang.String[] strMessages, java.lang.String[] strIDs, java.lang.String[] strDetails)
          Adds messages to be displayed.
 java.lang.String getButtonFlyoverText(java.lang.String buttonID)
          Gets the button flyover text of a button on MessageViewer.
 java.lang.String getButtonText(java.lang.String buttonID)
          Returns the button text of a MessageViewer button.
 java.lang.String getButtonTextCancel()
          Returns the button text of the CANCEL button in the STYLE_OKCANCEL_DUAL style.
 java.lang.String getButtonTextOKDual()
          Returns the label text of the OK button in the STYLE_OKCANCEL_DUAL style.
 java.lang.String getButtonTextOKSingle()
          Returns the button text of the OK button in the STYLE_OK_SINGLE style.
 boolean getExitOnClose()
          Determines whether the application exits when this panel is closed.
 java.lang.String getHelpSet()
          Gets current JavaHelp helpset name for HTML messages.
 java.lang.String getIconName()
          Returns the name of the icon used for this panel.
 java.lang.String getInstructionText()
          Returns the panel instruction text.
 int getStyle()
          Determines the display style of the panel.
 AS400 getSystem()
          Gets the AS400 system being used for help detail.
 java.lang.String getTitle()
          Returns the panel's title.
 void setButtonFlyoverText(java.lang.String buttonID, java.lang.String strFlyoverText)
          Sets the button flyover text of a button on MessageViewer.
 void setButtonText(java.lang.String buttonID, java.lang.String strButtonText)
          Sets the button text of a button on MessageViewer.
 void setButtonTextCancel(java.lang.String strButtonText)
          Sets the label text of the CANCEL button in the STYLE_OKCANCEL_DUAL style.
 void setButtonTextOKDual(java.lang.String strButtonText)
          Sets the label text of the OK button in the STYLE_OKCANCEL_DUAL style.
 void setButtonTextOKSingle(java.lang.String strButtonText)
          Sets the label text of the OK button in the STYLE_OK_SINGLE style.
 void setExitOnClose(boolean bExit)
          Controls whether the application exits when the panel is closed, based on the value of parameter bExit.
 void setHelpSet(java.lang.String helpSet)
          Sets the JavaHelp helpset used for any messages shown as HTML help.
 void setIconName(java.lang.String fileName)
          Overrides the name of the icon to use for this panel if a Frame is used.
 void setInstructionText(java.lang.String strInstruction)
          Changes the panel instruction text.
 void setStyle(int iStyle)
          Changes style settings, such as the display of the OK button, on a MessageViewer panel.
 void setSystem(AS400 as400)
          Sets the AS400 system used for help detail.
 void setTitle(java.lang.String strTitle)
          Overrides the panel title defined at the creation of the panel.
 void setVisible(boolean bVisible)
          Shows or hides the panel, depending on the value of bVisible.
static void showMessage(java.lang.String strTitle, AS400Message[] as400messages, AS400 system, java.lang.String strInstructionText, java.awt.Frame owner)
          Convenience method which prepares and displays a single AS400 message.
static void showMessage(java.lang.String strTitle, java.lang.String strMessage, java.lang.String strID, java.lang.String strDetails, java.lang.String strInstructionText, java.awt.Frame owner)
          Convenience method which prepares and displays a single message.
static void showMessage(java.lang.String strTitle, java.lang.String strMessage, java.lang.String strID, java.lang.String strHTMLDetails, java.lang.String strAnchor, java.lang.String strInstructionText, java.awt.Frame owner)
          Convenience method which prepares and displays a single message with HTML details.
 void valueChanged(javax.swing.event.ListSelectionEvent event)
          Implementation for ListSelectionListener interface
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STYLE_OK_SINGLE

public static final int STYLE_OK_SINGLE
Style which displays a single OK button, which can be relabelled. This is the default.
See Also:
getStyle(), setStyle(int)

STYLE_OKCANCEL_DUAL

public static final int STYLE_OKCANCEL_DUAL
Style which displays dual buttons, an OK and a Cancel, which can be relabelled, if desired. To be used when there is a need to make a choice based on the messages displayed.
See Also:
getStyle(), setStyle(int)

DETAILS_BUTTON

public static final java.lang.String DETAILS_BUTTON
Button identifier for the Details button.

OK_SINGLE_BUTTON

public static final java.lang.String OK_SINGLE_BUTTON
Button identifier for the single OK button.

OK_DUAL_BUTTON

public static final java.lang.String OK_DUAL_BUTTON
Button identifier for the dual OK button.

CANCEL_BUTTON

public static final java.lang.String CANCEL_BUTTON
Button identifier for the Cancel button.

ACTION_BUTTON

public static final java.lang.String ACTION_BUTTON
Button identifier for the Action button.

COPY_BUTTON

public static final java.lang.String COPY_BUTTON
Button identifier for the Copy button.
Constructor Detail

MessageViewer

public MessageViewer(java.lang.String strTitle)
Constructs a modeless MessageViewer panel.
Parameters:
strTitle - the Title to be displayed with the messages. If none given, defaults to "Display Messages"
Since:
v4r4

MessageViewer

public MessageViewer(java.lang.String strTitle,
                     java.awt.Frame owner)
Constructs a MessageViewer panel modal to a Frame.
Parameters:
strTitle - the Title to be displayed with the messages. If none given, defaults to "Display Messages"
owner - the owning frame
Since:
v4r5

MessageViewer

public MessageViewer(java.lang.String strTitle,
                     PanelManager modalPanelManager)
Constructs a MessageViewer panel modal to a PanelManager.
Parameters:
strTitle - the Title to be displayed with the messages. If none given, defaults to "Display Messages"
modalPanelManager - PanelManager object that controls the modality
Since:
v4r5
Method Detail

setVisible

public void setVisible(boolean bVisible)
Shows or hides the panel, depending on the value of bVisible.
Parameters:
bVisible - "true" causes the panel to display, "false" causes it to be hidden
Since:
v4r4

setStyle

public void setStyle(int iStyle)
Changes style settings, such as the display of the OK button, on a MessageViewer panel.
STYLE_OKCANCEL_DUAL
Displays dual buttons, an OK and a Cancel, which can be relabelled, if desired. To be used when there is a need to make a choice based on the messages displayed.

STYLE_OK_SINGLE
Displays a single OK button, which can be relabelled. This is the default.
Parameters:
iStyle - the style to apply
Since:
v4r5

getStyle

public int getStyle()
Determines the display style of the panel.
Returns:
the display style of the panel.
Since:
v4r4
See Also:
setStyle(int)

setExitOnClose

public void setExitOnClose(boolean bExit)
Controls whether the application exits when the panel is closed, based on the value of parameter bExit. The default value is false.

This method has no effect if it is called after this panel is made visible, or if the application supplied the container to be managed.

Parameters:
bExit - If true, exit the application; otherwise, just hide the panel.
Since:
v4r4
See Also:
getExitOnClose()

getExitOnClose

public boolean getExitOnClose()
Determines whether the application exits when this panel is closed.
Returns:
true if the application will be exited; false otherwise.
Since:
v4r4
See Also:
setExitOnClose(boolean)

setTitle

public void setTitle(java.lang.String strTitle)
Overrides the panel title defined at the creation of the panel.

Parameters:
strTitle - The title which should appear in the panel's title bar.
Since:
v4r4
See Also:
getTitle()

getTitle

public java.lang.String getTitle()
Returns the panel's title.
Returns:
The title which appears in the panel's title bar.
Since:
v4r4
See Also:
setTitle(java.lang.String)

setInstructionText

public void setInstructionText(java.lang.String strInstruction)
Changes the panel instruction text.

The default instruction text is blank.

Parameters:
strInstruction - The intruction text which should appear on the panel above the OK or YES/NO buttons.
Since:
v4r4
See Also:
getInstructionText()

getInstructionText

public java.lang.String getInstructionText()
Returns the panel instruction text.
Since:
v4r4
See Also:
setInstructionText(java.lang.String)

addActionListenerButtonOKDual

public void addActionListenerButtonOKDual(java.awt.event.ActionListener listener)
Adds an ActionListener to the OK button of the STYLE_OKCANCEL_DUAL style
Parameters:
listener - the listener to be added.
Since:
v4r4
See Also:
addActionListenerButtonOKSingle(java.awt.event.ActionListener), addActionListenerButtonCancel(java.awt.event.ActionListener)

addActionListenerButtonCancel

public void addActionListenerButtonCancel(java.awt.event.ActionListener listener)
Adds an ActionListener to the CANCEL button of the STYLE_OKCANCEL_DUAL style
Parameters:
listener - the listener to be added.
Since:
v4r4
See Also:
addActionListenerButtonOKSingle(java.awt.event.ActionListener), addActionListenerButtonOKDual(java.awt.event.ActionListener)

addActionListenerButtonOKSingle

public void addActionListenerButtonOKSingle(java.awt.event.ActionListener listener)
Adds an ActionListener to the OK button of the STYLE_OK_SINGLE style
Parameters:
listener - the listener to be added.
Since:
v4r4
See Also:
addActionListenerButtonOKDual(java.awt.event.ActionListener), addActionListenerButtonCancel(java.awt.event.ActionListener)

getButtonTextOKDual

public java.lang.String getButtonTextOKDual()
Returns the label text of the OK button in the STYLE_OKCANCEL_DUAL style.
Returns:
the button text
Since:
v4r4
See Also:
getButtonText(java.lang.String), setButtonText(java.lang.String, java.lang.String), setButtonTextOKDual(java.lang.String)

getButtonTextOKSingle

public java.lang.String getButtonTextOKSingle()
Returns the button text of the OK button in the STYLE_OK_SINGLE style.
Returns:
the button text
Since:
v4r4
See Also:
getButtonText(java.lang.String), setButtonText(java.lang.String, java.lang.String), setButtonTextOKSingle(java.lang.String)

getButtonTextCancel

public java.lang.String getButtonTextCancel()
Returns the button text of the CANCEL button in the STYLE_OKCANCEL_DUAL style.
Returns:
the button text
Since:
v4r4
See Also:
getButtonText(java.lang.String), setButtonText(java.lang.String, java.lang.String), setButtonTextCancel(java.lang.String)

setButtonTextOKDual

public void setButtonTextOKDual(java.lang.String strButtonText)
Sets the label text of the OK button in the STYLE_OKCANCEL_DUAL style.
Parameters:
strButtonText - the button text
Since:
v4r4
See Also:
setButtonText(java.lang.String, java.lang.String), getButtonText(java.lang.String), getButtonTextOKDual()

setButtonTextOKSingle

public void setButtonTextOKSingle(java.lang.String strButtonText)
Sets the label text of the OK button in the STYLE_OK_SINGLE style.
Parameters:
strButtonText - the button text
Since:
v4r4
See Also:
setButtonText(java.lang.String, java.lang.String), getButtonText(java.lang.String), getButtonTextOKSingle()

setButtonTextCancel

public void setButtonTextCancel(java.lang.String strButtonText)
Sets the label text of the CANCEL button in the STYLE_OKCANCEL_DUAL style.
Parameters:
strButtonText - the button text
Since:
v4r4
See Also:
setButtonText(java.lang.String, java.lang.String), getButtonText(java.lang.String), getButtonTextCancel()

getButtonText

public java.lang.String getButtonText(java.lang.String buttonID)
Returns the button text of a MessageViewer button.
Parameters:
buttonID - the string identifier of the button
Returns:
the text on the button
Since:
v5r1
See Also:
setButtonText(java.lang.String, java.lang.String)

setButtonText

public void setButtonText(java.lang.String buttonID,
                          java.lang.String strButtonText)
Sets the button text of a button on MessageViewer.
Parameters:
buttonID - the string identifier of the button
strButtonText - the text to display on the button
Since:
v5r1
See Also:
getButtonText(java.lang.String)

setButtonFlyoverText

public void setButtonFlyoverText(java.lang.String buttonID,
                                 java.lang.String strFlyoverText)
Sets the button flyover text of a button on MessageViewer.
Parameters:
buttonID - the string identifier of the button
strFlyoverText - the flyover text to display
Since:
v5r1
See Also:
getButtonFlyoverText(java.lang.String)

getButtonFlyoverText

public java.lang.String getButtonFlyoverText(java.lang.String buttonID)
Gets the button flyover text of a button on MessageViewer.
Parameters:
buttonID - the string identifier of the button
Returns:
the flyover text
Since:
v5r1
See Also:
setButtonFlyoverText(java.lang.String, java.lang.String)

addActionListenerButtonDetails

public void addActionListenerButtonDetails(java.awt.event.ActionListener listener)
Sets the listener of the Details button. If provided, this listener is called instead of standard processing when the Details button is pressed.

The Details button is visible if one of more of the messages has detail.

Since:
v5r1

addActionListenerButtonAction

public void addActionListenerButtonAction(java.awt.event.ActionListener listener)
Sets the listener of the Action button. If provided, the Action button is visible and this listener is called the Action button is pressed.
Parameters:
listener - the ActionListener to be added.
Since:
v5r1

valueChanged

public void valueChanged(javax.swing.event.ListSelectionEvent event)
Implementation for ListSelectionListener interface
Specified by:
valueChanged in interface javax.swing.event.ListSelectionListener
Parameters:
event - the ListSelectionEvent that has occurred.
Since:
v5r1

addMessage

public void addMessage(java.lang.String strMessage,
                       java.lang.String strID,
                       java.lang.String strDetail)
Adds a message to be displayed.

If strDetail has a value, the Details button will be enabled.

Parameters:
strMessage - the short message to be displayed in the MessageViewer
strID - an identifier for the message. Displayed on the MessageDetail panel.
strDetail - detail information about the message. Displayed on the MessageDetail panel.
Since:
v4r4

addMessage

public void addMessage(java.lang.String strMessage,
                       java.lang.String strID,
                       java.lang.String strHTMLDetail,
                       java.lang.String strAnchor)
Adds a message to be displayed and provides HTML details.

If strHTMLDetail has a value, the Details button will be enabled.

Parameters:
strMessage - the short message to be displayed in the MessageViewer
strID - an identifier for the message. Displayed on the MessageDetail panel.
strHTMLDetail - detail information about the message in HTML format. Displayed in HelpViewer.
strAnchor - an anchor within the HTML to position to.
Since:
v5r1

addMessage

public void addMessage(java.lang.String strMessage,
                       java.lang.String strID,
                       java.net.URL urlDetails)
Adds a message to be displayed and provides a URL for details.

If strDetail has a value, the Details button will be enabled.

Parameters:
strMessage - the short message to be displayed in the MessageViewer
strID - an identifier for the message. Displayed on the MessageDetail panel.
urlDetails - a URL where detail information exists. Displayed in HelpViewer.
Since:
v5r1

addMessage

public void addMessage(java.lang.String strMessage)
Adds a simple message to be displayed.

Messages added with this method have no detail. The Details button remains disabled.

Parameters:
strMessage - the short message to be displayed in the MessageViewer
Since:
v4r4

addMessage

public void addMessage(AS400Message AS400msg)
Adds a message to be displayed. The message will show second level help only if an AS400 object is provided using setSystem.
Parameters:
AS400msg - an AS400 message object
Since:
v4r4
See Also:
setSystem(com.ibm.as400.access.AS400)

addMessages

public void addMessages(AS400Message[] AS400msgList)
Adds messages to be displayed. The messages will show second level help only if an AS400 object is provided using setSystem.
Parameters:
AS400msgList - an array AS400 message objects
Since:
v4r4
See Also:
setSystem(com.ibm.as400.access.AS400)

addMessages

public void addMessages(java.lang.String[] strMessages,
                        java.lang.String[] strIDs,
                        java.lang.String[] strDetails)
Adds messages to be displayed. Three arrays have corresponding ID's, messages, and detail information. The caller is responsible for synchronizing the positions in the array. Empty positions may contain null, or an empty String.
Parameters:
strMessages - array of short messages to be displayed in the MessageViewer
strIDs - array of message identifiers. Displayed on the MessageDetail panel.
strDetails - array of matching detail information for each message. Displayed on the MessageDetail panel.
Since:
v5r1

showMessage

public static void showMessage(java.lang.String strTitle,
                               java.lang.String strMessage,
                               java.lang.String strID,
                               java.lang.String strDetails,
                               java.lang.String strInstructionText,
                               java.awt.Frame owner)
Convenience method which prepares and displays a single message. Displays the single OK button style.
Parameters:
strTitle - the title of the message box
strMessage - the short message to be displayed in the MessageViewer
strID - an identifier for the message. Displayed on the MessageDetail panel.
strDetail - detail information about the message. Displayed on the MessageDetail panel.
strInstructionText - instruction text for the user
owner - the owning frame, may be null
Since:
v5r1

showMessage

public static void showMessage(java.lang.String strTitle,
                               java.lang.String strMessage,
                               java.lang.String strID,
                               java.lang.String strHTMLDetails,
                               java.lang.String strAnchor,
                               java.lang.String strInstructionText,
                               java.awt.Frame owner)
Convenience method which prepares and displays a single message with HTML details. Displays the single OK button style.
Parameters:
strTitle - the title of the message box
strMessage - the short message to be displayed in the MessageViewer
strID - an identifier for the message. Displayed on the MessageDetail panel.
strHTMLDetails - HTML information which should be displayed as Detail. Displayed in a HelpViewer window. Takes precedence over standard Detail information.
strAnchor - Optional anchor withing the HTML information to scroll to.
strInstructionText - instruction text for the user
owner - the owning frame, may be null
Since:
v5r1

showMessage

public static void showMessage(java.lang.String strTitle,
                               AS400Message[] as400messages,
                               AS400 system,
                               java.lang.String strInstructionText,
                               java.awt.Frame owner)
Convenience method which prepares and displays a single AS400 message. Displays the single OK button style.
Parameters:
strTitle - the title of the message box
as400messages - an array of AS400Message objects to display
system - the AS400 object to get the detail information from
strInstructionText - instruction text for the user
owner - the owning frame, may be null
Since:
v5r1

setSystem

public void setSystem(AS400 as400)
Sets the AS400 system used for help detail. If no AS400 is specified, no help detail is available for AS400 messages.
Parameters:
as400 - An AS400 object.
Since:
v5r1

getSystem

public AS400 getSystem()
Gets the AS400 system being used for help detail.
Returns:
The system being used for help detail.
Since:
v5r1

setIconName

public void setIconName(java.lang.String fileName)
Overrides the name of the icon to use for this panel if a Frame is used. Use the package structure and the the filename so the icon file is found in the classpath.
Parameters:
fileName - The filename of the icon to search for in the classpath.
Since:
v5r1m0
See Also:
getIconName()

getIconName

public java.lang.String getIconName()
Returns the name of the icon used for this panel.
Returns:
The filename of the icon.
Since:
v5r1m0
See Also:
getIconName()

setHelpSet

public void setHelpSet(java.lang.String helpSet)
Sets the JavaHelp helpset used for any messages shown as HTML help. All HTML help messages use this provided helpset. If no helpset is specified, a default system helpset is used.
Parameters:
helpSet - name of the help set
Since:
v5r1

getHelpSet

public java.lang.String getHelpSet()
Gets current JavaHelp helpset name for HTML messages.
Returns:
a string with the helpset contents
Since:
v5r1