com.ibm.as400.ui.util
Class CommandPrompter

java.lang.Object
  |
  +--com.ibm.as400.ui.util.CommandPrompter

public class CommandPrompter
extends java.lang.Object

This object displays a prompter for a given command string similar to the prompting done by the AS/400 command line. The command string may be a command name, a full command string, or a partial command name such as crt*. Any errors encountered during prompting will be handled by the CommandPrompter. The prompter requires the AS/400 system to be at release V4R4 or later.

Usage:

          AS400 system = new AS400("system1");
          CommandPrompter cp = new CommandPrompter(frame, system, "savlib");
 
if(cp.showDialog() == CommandPrompter.OK) { result = cp.getCommandString(); // get command string }

Since:
v5r1m0

Field Summary
static int CANCEL
          The user dismissed the dialog by pressing the Cancel button.
static int DATE_DAY_MONTH_YEAR
          Constant specifying the date format is day, month, and year.
static int DATE_JULIAN
          Constant specifying the date format is Julian.
static int DATE_MONTH_DAY_YEAR
          Constant specifying the date format is month, day, and year.
static int DATE_NONE
          Constant specifying a date format was not used by the command.
static int DATE_YEAR_MONTH_DAY
          Constant specifying the date format is year, month, and day.
static int ERROR
          The dialog was dismissed due to an error during prompting.
static int OK
          The user dismissed the dialog by pressing the OK button.
static int PTF_REQUIRED
          The host system requires a PTF for the prompter to function.
 
Constructor Summary
CommandPrompter()
          Constructs a CommandPrompter object.
CommandPrompter(java.awt.Frame parent, AS400 system, java.lang.String commandString)
          Constructs a CommandPrompter object.
CommandPrompter(java.awt.Frame parent, AS400 system, java.lang.String commandString, boolean usePromptPrograms, boolean promptInteractiveCommands)
          Constructs a CommandPrompter object.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a listener to be notified when the value of any bound property changes.
 void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
          Adds a listener to be notified when the value of any constrained property changes.
 java.lang.String getCommandString()
          Returns the prompted command string.
 int getDateFormat()
          Returns the date format used during prompting.
 java.awt.Frame getParent()
          Returns the parent Frame for the CommandPrompter dialog.
 boolean getPromptInteractiveCommands()
          Gets whether the CommandPrompter should prompt interactive commands in addition to batch commands.
 AS400 getSystem()
          Returns the system used by this dialog.
 boolean getUsePromptPrograms()
          Returns if the prompter should call the prompt override and change exit programs.
 boolean isBatch()
          Returns if the command prompted could be executed in batch.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a property change listener.
 void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
          Removes a vetoable change listener.
 void setCommandString(java.lang.String command)
          Sets the command string to be prompted.
 void setParent(java.awt.Frame parent)
          Sets the parent Frame for the CommandPrompter dialog.
 void setPromptInteractiveCommands(boolean prompt)
          Sets whether the prompter should prompt interactive commands in addition to batch commands.
 void setSystem(AS400 system)
          Sets the AS/400 system used to retrieve the command definition.
 void setUsePromptPrograms(boolean usePromptPrograms)
          Sets whether the prompter should call the prompt override and change exit programs for the command.
 int showDialog()
          Shows the dialog and returns how it was dismissed.
 int showHelp()
          Show the help window for the command without prompting.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OK

public static final int OK
The user dismissed the dialog by pressing the OK button.

CANCEL

public static final int CANCEL
The user dismissed the dialog by pressing the Cancel button.

ERROR

public static final int ERROR
The dialog was dismissed due to an error during prompting.

PTF_REQUIRED

public static final int PTF_REQUIRED
The host system requires a PTF for the prompter to function. Only applies to V4R4 and V4R5 systems.

DATE_NONE

public static final int DATE_NONE
Constant specifying a date format was not used by the command.

DATE_DAY_MONTH_YEAR

public static final int DATE_DAY_MONTH_YEAR
Constant specifying the date format is day, month, and year.

DATE_JULIAN

public static final int DATE_JULIAN
Constant specifying the date format is Julian.

DATE_MONTH_DAY_YEAR

public static final int DATE_MONTH_DAY_YEAR
Constant specifying the date format is month, day, and year.

DATE_YEAR_MONTH_DAY

public static final int DATE_YEAR_MONTH_DAY
Constant specifying the date format is year, month, and day.
Constructor Detail

CommandPrompter

public CommandPrompter()
Constructs a CommandPrompter object.
The dialog will be modal upon the parent.
Since:
v5r1m0

CommandPrompter

public CommandPrompter(java.awt.Frame parent,
                       AS400 system,
                       java.lang.String commandString)
Constructs a CommandPrompter object.
The dialog will be modal upon the parent.
Parameters:
parent - The parent Frame that displays the dialog.
system - The AS/400 system used to retrieve the command definition.
commandString - The command string to be prompted.
Since:
v5r1m0

CommandPrompter

public CommandPrompter(java.awt.Frame parent,
                       AS400 system,
                       java.lang.String commandString,
                       boolean usePromptPrograms,
                       boolean promptInteractiveCommands)
Constructs a CommandPrompter object.
The dialog will be modal upon the parent.
Parameters:
parent - The parent Frame that displays the dialog.
system - The AS/400 system used to retrieve the command definition.
commandString - The command string to be prompted.
usePromptPrograms - If the prompt override and change exit programs should be called for the command.
promptInteractiveCommands - If the prompter should prompt interactive commands.
Since:
v5r1m0
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a listener to be notified when the value of any bound property changes.
Since:
v5r1m0

addVetoableChangeListener

public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds a listener to be notified when the value of any constrained property changes.
Since:
v5r1m0

getCommandString

public java.lang.String getCommandString()
Returns the prompted command string.
The string is a valid command string if the user pressed OK to dismiss the dialog. Otherwise, it is the starting command string.
Returns:
A command string.
Since:
v5r1m0

getDateFormat

public int getDateFormat()
Returns the date format used during prompting. This date format is retrieved from the job used to prompt the command.
Returns:
DATE_NONE if the command did not use date fields or the command has yet to be prompted.
Since:
v5r1m0

getParent

public java.awt.Frame getParent()
Returns the parent Frame for the CommandPrompter dialog.
Returns:
The parent Frame for the CommandPrompter dialog.
Since:
v5r1m0

getPromptInteractiveCommands

public boolean getPromptInteractiveCommands()
Gets whether the CommandPrompter should prompt interactive commands in addition to batch commands.
If the prompter is set to not prompt interactive commands, an error will be displayed to the user if they try to prompt interactive commands.
By default, the prompter will prompt both batch and interactive commands.
Returns:
True if the prompter should prompt interactive commands, false otherwise.
Since:
v5r1m0
See Also:
setPromptInteractiveCommands(boolean)

getSystem

public AS400 getSystem()
Returns the system used by this dialog.
Returns:
The object that represents the system.
Since:
v5r1m0

getUsePromptPrograms

public boolean getUsePromptPrograms()
Returns if the prompter should call the prompt override and change exit programs.
A prompt override program is called to fill input fields with existing values on the AS/400 instead of *SAME. This value should be false if the command is not being retrieved from the same system it will be executed on. By default, CommandPrompter will call the prompt override and change exit programs for a command.
Returns:
true if the prompter will use the prompt override and change exit programs, false otherwise.
Since:
v5r1m0
See Also:
setUsePromptPrograms(boolean)

isBatch

public boolean isBatch()
Returns if the command prompted could be executed in batch.
Returns:
true if the command could be executed in batch, false otherwise.
Since:
v5r1m0

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a property change listener.
Since:
v5r1m0

removeVetoableChangeListener

public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Removes a vetoable change listener.
Since:
v5r1m0

setCommandString

public void setCommandString(java.lang.String command)
Sets the command string to be prompted.
Parameters:
command - The command string to be prompted.
Since:
v5r1m0

setParent

public void setParent(java.awt.Frame parent)
Sets the parent Frame for the CommandPrompter dialog.
Parameters:
parent - The parent Frame for the CommandPrompter dialog.
Since:
v5r1m0

setPromptInteractiveCommands

public void setPromptInteractiveCommands(boolean prompt)
                                  throws java.beans.PropertyVetoException
Sets whether the prompter should prompt interactive commands in addition to batch commands.
If the prompter is set to not prompt interactive commands, an error will be displayed to the user if they try to prompt interactive commands.
By default, the prompter will prompt both batch and interactive commands.
Parameters:
prompt - Specifies if the prompter should also prompt interactive commands.
Since:
v5r1m0
See Also:
getPromptInteractiveCommands()

setSystem

public void setSystem(AS400 system)
Sets the AS/400 system used to retrieve the command definition.
Parameters:
system - The AS/400 system to use to retrieve the command definition.
Since:
v5r1m0

setUsePromptPrograms

public void setUsePromptPrograms(boolean usePromptPrograms)
                          throws java.beans.PropertyVetoException
Sets whether the prompter should call the prompt override and change exit programs for the command.
A prompt override program is called to fill input fields with existing values on the AS/400 instead of *SAME. This value should be false if the command is not being retrieved from the same system it is being executed on. By default, the prompter will call the prompt override and change exit programs for a command.
Parameters:
usePromptPrograms - true to allow the prompt override and change exit programs to be called for the command, false otherwise.
Since:
v5r1m0
See Also:
getUsePromptPrograms()

showDialog

public int showDialog()
Shows the dialog and returns how it was dismissed.
Returns:
OK if the user dismissed the dialog by pressing the ok button.
Since:
v5r1m0
See Also:
OK, CANCEL, ERROR, PTF_REQUIRED

showHelp

public int showHelp()
Show the help window for the command without prompting.
Returns:
OK if the help was displayed.
Since:
v5r1m0f
See Also:
OK, ERROR, PTF_REQUIRED

toString

public java.lang.String toString()
Returns a string representation of this object.
Overrides:
toString in class java.lang.Object
Returns:
The class name and starting command string.
Since:
v5r1m0