public class ShowMenu extends CommandBase
Modifier and Type | Field and Description |
---|---|
protected CommandMenu |
menu
The content of the menu, referencing instances of
Command . |
CommandMenuSpec |
spec
The specification of the content of the menu, where commands
are referenced by their names.
|
recordable, repeatable
Constructor and Description |
---|
ShowMenu(CommandMenuSpec spec)
Constructs a command which popups specified menu.
|
Modifier and Type | Method and Description |
---|---|
protected CommandMenu |
compileMenu(CommandMenuSpec spec,
DocumentView docView)
Invokes
toMenu(com.xmlmind.xmledit.control.CommandMenuSpec, com.xmlmind.xmledit.view.DocumentView) to convert the specification of the content
of the menu to the actual content of the menu. |
ShowMenu |
copy()
Makes a deep copy of this command.
|
CommandResult |
doExecute(DocumentView docView,
String parameter,
int x,
int y)
Actually executes this command with specified parameter and in
specified context.
|
protected static CommandMenu |
parameterizeMenu(CommandMenu menu,
String parameter)
Returns a copy of specified menu specification where
%* ,
%0 , %1 , etc, have been substituted with their
values taken from specified parameter string. |
boolean |
prepare(DocumentView docView,
String parameter,
int x,
int y)
Tests whether this command can be executed with specified parameter
and in specified context.
|
protected CommandMenu |
prepareMenu(DocumentView docView,
String parameter,
int x,
int y)
Returns a menu which is ready to be displayed.
|
static void |
setCapturedContextualMenus(DocumentView docView,
List<CommandMenu> list) |
protected CommandResult |
showMenu(CommandMenu popupMenu,
DocumentView docView,
int x,
int y)
Display specified ready-to-use menu at specified document view
coordinates.
|
protected static CommandMenu |
toMenu(CommandMenuSpec spec,
DocumentView docView)
Converts the specification of the content of the menu to the
actual content of the menu.
|
doExecuteByName, execute, executeCommand, isRecordable, isRepeatable, prepareCommand
public final CommandMenuSpec spec
May be null
when the content of the menu is
dynamically built like in ContextualMenu
.
protected CommandMenu menu
Command
.
This field, initially null
is lazily initialized
from menu
or dynamically built like in ContextualMenu
.
Therefore it may be null
.
public ShowMenu(CommandMenuSpec spec)
spec
- the specification of the content of the menu,
where commands are referenced by their names.
May be null
when the content of the menu is
dynamically built like in ContextualMenu
.
public ShowMenu copy()
Command
null
if how to copy this command
cannot be determinedpublic boolean prepare(DocumentView docView, String parameter, int x, int y)
CommandBase
If the command can be executed, this method returns
true
after having configured its internal state for
consumption by method CommandBase.execute(com.xmlmind.xmledit.view.DocumentView, 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.
prepare
in class CommandBase
docView
- 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 docView of the mouse event
having triggered this command; -1 if this command was triggered by a
keyboard inputy
- Y position relative to docView of the mouse event
having triggered this command; -1 if this command was triggered by a
keyboard inputpublic CommandResult doExecute(DocumentView docView, String parameter, int x, int y)
This method assumes that CommandBase.prepare(com.xmlmind.xmledit.view.DocumentView, java.lang.String, int, int)
has been
successfully invoked immediately before its own invocation.
IMPORTANT: application code which executes a command
must always use CommandBase.execute(com.xmlmind.xmledit.view.DocumentView, java.lang.String, int, int)
or CommandBase.executeCommand(com.xmlmind.xmledit.gadget.Gadget, java.lang.String, int, int)
to do so,
NOT CommandBase.doExecute(com.xmlmind.xmledit.view.DocumentView, java.lang.String, int, int)
. CommandBase.doExecute(com.xmlmind.xmledit.view.DocumentView, java.lang.String, int, int)
is intended to be used
only by commands which invoke helper "sub-commands".
Invokes prepareMenu(com.xmlmind.xmledit.view.DocumentView, java.lang.String, int, int)
and then showMenu(com.xmlmind.xmledit.control.CommandMenu, com.xmlmind.xmledit.view.DocumentView, int, int)
.
doExecute
in class CommandBase
docView
- 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 docView of the mouse event
having triggered this command; -1 if this command was triggered by a
keyboard inputy
- Y position relative to docView of the mouse event
having triggered this command; -1 if this command was triggered by a
keyboard inputnull
.
If the command execution is successful and
the command is repeatable and/or recordable then
CommandResult.details
field of the result is expected
to be one of:
null
Object
String
s
protected CommandMenu prepareMenu(DocumentView docView, String parameter, int x, int y)
null
in which case no menu will be displayed.protected CommandMenu compileMenu(CommandMenuSpec spec, DocumentView docView)
toMenu(com.xmlmind.xmledit.control.CommandMenuSpec, com.xmlmind.xmledit.view.DocumentView)
to convert the specification of the content
of the menu to the actual content of the menu.protected static final CommandMenu toMenu(CommandMenuSpec spec, DocumentView docView)
spec
- the specification of the content of the menu,
where commands are referenced by their names.Command
;
or null
if some of the commands have not been registered.protected static final CommandMenu parameterizeMenu(CommandMenu menu, String parameter)
%*
,
%0
, %1
, etc, have been substituted with their
values taken from specified parameter string.protected CommandResult showMenu(CommandMenu popupMenu, DocumentView docView, int x, int y)
public static void setCapturedContextualMenus(DocumentView docView, List<CommandMenu> list)