|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.util.CommandManager
public class CommandManager
Provides various utility methods for managing commands. These include an implementation of ContextCommandsConsumerInterface, a method that concatenates the commands of all registered producers, methods for adding commands to menus, and methods that help avoid proliferation of zero-length command arrays.
Using this class, the typical ContextCommandsConsumerInterface implementation should simply be:
private transient CommandManager _commandManager;
private CommandManager getCommandManager ()
{
if (_commandManager == null)
_commandManager = new CommandManager();
return _commandManager;
}
public ContextCommandsInterface[] getContextCommandsProducers ()
{
return getCommandManager().getContextCommandsProducers();
}
public void addContextCommandsProducer (ContextCommandsInterface producer)
{
getCommandManager().addContextCommandsProducer(producer);
}
public void removeContextCommandsProducer (ContextCommandsInterface producer)
{
getCommandManager().removeContextCommandsProducer(producer);
}
ContextCommandsConsumerInterface
Constructor Summary | |
---|---|
CommandManager()
|
Method Summary | |
---|---|
static void |
addCommand(javax.swing.JMenu menu,
com.sas.util.Command command,
java.lang.Object executeParm)
Adds a command to a JMenu by constructing an appropriate menu item, including a submenu or separator as necessary. |
static void |
addCommand(javax.swing.JPopupMenu menu,
com.sas.util.Command command,
java.lang.Object executeParm)
Adds a command to a JPopupMenu by constructing an appropriate menu item, including a submenu or separator as necessary. |
static void |
addCommand(java.awt.Menu menu,
com.sas.util.Command command,
java.lang.Object executeParm)
Adds a command to a menu by constructing an appropriate menu item, including a submenu or separator as necessary. |
static void |
addCommands(javax.swing.JMenu menu,
com.sas.util.Command[] commands,
java.lang.Object executeParm)
Adds a set of commands to a JMenu by constructing a appropriate menu items, including a submenus and/or separators as necessary. |
static void |
addCommands(javax.swing.JPopupMenu menu,
com.sas.util.Command[] commands,
java.lang.Object executeParm)
Adds a set of commands to a JPopupMenu by constructing a appropriate menu items, including a submenus and/or separators as necessary. |
static void |
addCommands(java.awt.Menu menu,
com.sas.util.Command[] commands,
java.lang.Object executeParm)
Adds a set of commands to a menu by constructing a appropriate menu items, including a submenus and/or separators as necessary. |
void |
addContextCommandsProducer(ContextCommandsInterface producer)
Registers a new context commands producer. |
com.sas.util.Command[] |
getContextCommands(java.lang.Object context,
int x,
int y)
Returns a list of commands associated with a given context. |
ContextCommandsInterface[] |
getContextCommandsProducers()
Returns the set of context command producers that have been registered via addContextCommandsProducer(). |
static com.sas.util.Command[] |
getEmptyCommandArray()
Returns a zero-length Command array. |
static CommandsInterface[] |
getEmptyCommandsInterfaceArray()
Returns a zero-length CommandsInterface array. |
static ContextCommandsInterface[] |
getEmptyContextCommandsInterfaceArray()
Returns a zero-length ContextCommandsInterface array. |
boolean |
isSeparatorsAdded()
Returns whether or not getContextCommands adds a separator
between each producer's list of commands. |
void |
removeContextCommandsProducer(ContextCommandsInterface producer)
Unregisters a context commands producer. |
void |
setSeparatorsAdded(boolean newValue)
Specifies whether or not getContextCommands adds a separator
between each producer's list of commands. |
Constructor Detail |
---|
public CommandManager()
Method Detail |
---|
public ContextCommandsInterface[] getContextCommandsProducers()
getContextCommandsProducers
in interface ContextCommandsConsumerInterface
addContextCommandsProducer(com.sas.util.ContextCommandsInterface)
public void addContextCommandsProducer(ContextCommandsInterface producer)
addContextCommandsProducer
in interface ContextCommandsConsumerInterface
producer
- An object that implements ContextCommandsInterface
.removeContextCommandsProducer(com.sas.util.ContextCommandsInterface)
public void removeContextCommandsProducer(ContextCommandsInterface producer)
removeContextCommandsProducer
in interface ContextCommandsConsumerInterface
producer
- An object previously passed to
addContextCommandsProducer()
.addContextCommandsProducer(com.sas.util.ContextCommandsInterface)
public com.sas.util.Command[] getContextCommands(java.lang.Object context, int x, int y)
The list is generated by calling getContextCommands()
on each of the producers returned by
getContextCommandsProducers()
.
If isSeparatorsAdded()
returns true
,
then a separator is included
between each producer's list.
getContextCommands
in interface ContextCommandsInterface
context
- The object requesting the commands; If it is an instance of
com.sas.util.ContextInterface, the context will be
queried to see if it has any subcontext to be used.
This parameter is required, i.e. it may not be null
.x
- The x position to pass to the context if the context implements the
com.sas.util.ContextInterface. If the position is not relevant to the
context then -1 should be used.y
- The y position to pass to the context if the context implements the
com.sas.util.ContextInterface. If the position is not relevant to the
context then -1 should be used.
public boolean isSeparatorsAdded()
getContextCommands
adds a separator
between each producer's list of commands.
The default is true
.
true
if a separator is added,
and false
otherwisesetSeparatorsAdded(boolean)
public void setSeparatorsAdded(boolean newValue)
getContextCommands
adds a separator
between each producer's list of commands.
newValue
- true
if a separator should be added,
and false
otherwiseisSeparatorsAdded()
public static void addCommand(java.awt.Menu menu, com.sas.util.Command command, java.lang.Object executeParm)
If command is an instance of MenuCommand
,
a Menu
will be created and added to menu;
unless MenuCommand.isSeparator()
returns true
,
in which case menu.addSeparator()
will be called instead.
If command is an instance of BooleanDataInterface
,
a CheckBoxMenuItem
will be created and added to menu.
menu
- The menu to add to.command
- The command to add.executeParm
- The parameter to pass to command.execute()
when the
command's menu item is selected.addCommands(java.awt.Menu, com.sas.util.Command[], java.lang.Object)
,
MenuItem
,
MenuCommand
,
BooleanData
public static void addCommands(java.awt.Menu menu, com.sas.util.Command[] commands, java.lang.Object executeParm)
menu
- The menu to add to.commands
- The set of commands to add; may be null
.executeParm
- The parameter to pass to command.execute()
when a
command's menu item is selected.addCommand(java.awt.Menu, com.sas.util.Command, java.lang.Object)
public static void addCommand(javax.swing.JPopupMenu menu, com.sas.util.Command command, java.lang.Object executeParm)
If command is an instance of MenuCommand
,
a JMenu
will be created and added to menu;
unless MenuCommand.isSeparator()
returns true
,
in which case menu.addSeparator()
will be called instead.
If command is an instance of BooleanDataInterface
,
a JCheckBoxMenuItem
will be created and added to menu.
menu
- The menu to add to.command
- The command to add.executeParm
- The parameter to pass to command.execute()
when the
command's menu item is selected.addCommands(java.awt.Menu, com.sas.util.Command[], java.lang.Object)
,
JMenuItem
,
MenuCommand
,
BooleanData
public static void addCommands(javax.swing.JPopupMenu menu, com.sas.util.Command[] commands, java.lang.Object executeParm)
menu
- The menu to add to.commands
- The set of commands to add; may be null
.executeParm
- The parameter to pass to command.execute()
when a
command's menu item is selected.addCommand(java.awt.Menu, com.sas.util.Command, java.lang.Object)
public static void addCommand(javax.swing.JMenu menu, com.sas.util.Command command, java.lang.Object executeParm)
If command is an instance of MenuCommand
,
a JMenu
will be created and added to menu;
unless MenuCommand.isSeparator()
returns true
,
in which case menu.addSeparator()
will be called instead.
If command is an instance of BooleanDataInterface
,
a JCheckBoxMenuItem
will be created and added to menu.
menu
- The menu to add to.command
- The command to add.executeParm
- The parameter to pass to command.execute()
when the
command's menu item is selected.addCommands(java.awt.Menu, com.sas.util.Command[], java.lang.Object)
,
JMenuItem
,
MenuCommand
,
BooleanData
public static void addCommands(javax.swing.JMenu menu, com.sas.util.Command[] commands, java.lang.Object executeParm)
menu
- The menu to add to.commands
- The set of commands to add; may be null
.executeParm
- The parameter to pass to command.execute()
when a
command's menu item is selected.addCommand(java.awt.Menu, com.sas.util.Command, java.lang.Object)
public static com.sas.util.Command[] getEmptyCommandArray()
public static CommandsInterface[] getEmptyCommandsInterfaceArray()
public static ContextCommandsInterface[] getEmptyContextCommandsInterfaceArray()
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |