public static final class CommandMenu.Action2 extends Object implements CommandMenu.Action
CommandMenu.Action
which may be used
to execute two different commands depending on the value of
ActionEvent.getModifiers()
.Modifier and Type | Field and Description |
---|---|
Command |
altCmd
Command executed when the
ActionEvent do have
modifiers. |
String |
altCmdParam
The parameter of altCmd.
|
Command |
defaultCmd
Command executed when the
ActionEvent does NOT
have modifiers. |
int |
modifiers
The
ActionEvent modifiers selecting altCmd. |
Constructor and Description |
---|
Action2(Command defaultCmd,
int modifiers,
Command altCmd,
String altCmdParam)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent event,
Gadget gadget,
String parameter,
int x,
int y)
Prepare and execute wrapped command which corresponds to the value
of
ActionEvent.getModifiers() , if any,
and default wrapped command otherwise. |
CommandResult |
executeCommand(Gadget gadget,
String parameter,
int x,
int y)
Actually executes this command with specified parameter and in
specified context.
|
boolean |
prepareCommand(Gadget gadget,
String parameter,
int x,
int y)
Tests whether this command can be executed with specified parameter
and in specified context.
|
public final Command defaultCmd
ActionEvent
does NOT
have modifiers. Its parameter is the string passed to
prepareCommand
, executeCommand
and actionPerformed
.public final int modifiers
ActionEvent
modifiers selecting altCmd.public final Command altCmd
ActionEvent
do have
modifiers.public final String altCmdParam
public Action2(Command defaultCmd, int modifiers, Command altCmd, String altCmdParam)
defaultCmd
- command executed when the ActionEvent
does NOT have modifiers.modifiers
- the ActionEvent
modifiers selecting
altCmd.altCmd
- command executed when the ActionEvent
do have modifiers.altCmdParam
- the parameter of altCmd.public boolean prepareCommand(Gadget gadget, String parameter, int x, int y)
Command
If the command can be executed, this method returns
true
after having configured its internal state for
consumption by method Command.executeCommand(com.xmlmind.xmledit.gadget.Gadget, java.lang.String, int, int)
which should be invoked
immediately after this one.
Returns false
if this command cannot be executed with
specified parameter and in specified context.
prepareCommand
in interface Command
gadget
- the target of this commandparameter
- parameterizes the command (that is, modifies the
behavior of the command in a command specific way)x
- X position relative to gadget of the mouse event
having triggered this command; -1 if this command was triggered by a
keyboard inputy
- Y position relative to gadget of the mouse event
having triggered this command; -1 if this command was triggered by a
keyboard inputpublic CommandResult executeCommand(Gadget gadget, String parameter, int x, int y)
Command
This method assumes that Command.prepareCommand(com.xmlmind.xmledit.gadget.Gadget, java.lang.String, int, int)
has been
successfully invoked immediately before its own invocation.
executeCommand
in interface Command
gadget
- the target of this commandparameter
- parameterizes the command (that is, modifies the
behavior of the command in a command specific way)x
- X position relative to gadget of the mouse event
having triggered this command; -1 if this command was triggered by a
keyboard inputy
- Y position relative to gadget of the mouse event
having triggered this command; -1 if this command was triggered by a
keyboard inputnull
public void actionPerformed(ActionEvent event, Gadget gadget, String parameter, int x, int y)
CommandMenu.Action
ActionEvent.getModifiers()
, if any,
and default wrapped command otherwise.actionPerformed
in interface CommandMenu.Action