addHoverListener
public void addHoverListener(HoverListener l)
Adds a
HoverListener
to the command manager. The listener will be notified when
ever the mouse hovers over a command.
commandIterator
public Iterator commandIterator()
configure
protected void configure(Command command)
Initialises the command from the current loaded set of properties.
command
- the Command
to initialise.
defaultInstance
public static CommandManager defaultInstance()
- the current installed CommandManager
dispose
public void dispose()
This method removes any listeners from this command managers parent (if it exists). This method
should only be called when the command manager is no longer in use.
fireCommandRegistered
protected void fireCommandRegistered(Command command)
fireHoverEnded
protected void fireHoverEnded(HoverEvent e)
fireHoverStarted
protected void fireHoverStarted(HoverEvent e)
getClassLoader
public ClassLoader getClassLoader()
Gets the class loader the library is to use. If not explicitly set, this defaults
to the class loader that loaded the command manager.
- the
ClassLoader
the library is to use.
getCommand
public ActionCommand getCommand(String commandId)
Gets the specifed command from this container. If the command isn't registered with this
container then the request is delegated to the containers parent.
commandId
- the commands id.
- the command with the specified id, or null if it hasn't been registered
with this container of one of its parents.
getConditionEvaluator
public ConditionEvaluator getConditionEvaluator()
Gets the commands managers current condition evaluator. Conditions are used by
groups to determine if a given command should be included.
- the current condition evaluator.
getContext
public Object getContext()
Gets the context object specified in the constructor.
- this managers context object, or null if there is none.
getDefaultButtonFactory
public static ButtonFactory getDefaultButtonFactory()
getDefaultMenuFactory
public static MenuFactory getDefaultMenuFactory()
getDefaultToolbarFactory
public static ToolbarFactory getDefaultToolbarFactory()
getGroup
public CommandGroup getGroup(String groupId)
Gets the specifed group from the container. If the group hasn't already beed registered
with this container, it will be be created automatically and registered. Please note that
parent containers are never checked.
groupId
- the Id of the group.
getGroupFactory
public GroupFactory getGroupFactory()
Gets the
GroupFactory
being used by the library. This factory is used
by the library whenever a group must be created. This is typically during calls
to
getGroup(String)
.
getGroupMemberFactory
public GroupMemberFactory getGroupMemberFactory()
Gets the
GroupMemberFactory
used by the library to construct
GroupMember
. This factory
will be used by groups to create the infrastructure for managing its members. By supplying custom implementations
you can control the way groups populate their containers.
getIconFactory
public IconFactory getIconFactory()
Gets this command managers
IconFactory
. If the icon factory
hasn't been configured, the parent, if present, is queried.
getLogger
public static Logger getLogger(Class aClass)
Gets a new logger for the command library.
getMenuFactory
public MenuFactory getMenuFactory()
- the
MenuFactory
that is to be used by commands to create menu items.
getResourceBundle
public ResourceBundle getResourceBundle()
Gets the java.util.ResourceBundle
for resolving i18n configuration parameters. This value is
null by default.
- the command managers ResourceBundle
setResourceBundle(java.util.ResourceBundle)
instance
public static CommandManager instance()
defaultInstance
should now be the preferred method for obtaining the
global command manager. This method will be removed in a future release.
- the current installed CommandManager
isGroup
public boolean isGroup(String commandId)
Checks if the command identified by the specified id is a group.
commandId
- the command id.
- true if the command id represents a
CommandGroup
, false
otherwise.
isMacOS
public static boolean isMacOS()
A convenience method for GUI Commands to check if we're running in an
apple Mac environment.
true
if running in the Mac environment, false
otherwise.
isMenuTooltipsEnabled
public boolean isMenuTooltipsEnabled()
Checks if tooltip are globally enabled on menus. This setting will only be used by
faces
that haven't been explicitly configured to enable or disable tooltips on
menus.
- true if tooltips are enabled on menus, false otherwise.
isRegistered
protected boolean isRegistered(Command command)
load
public void load(File file)
throws LoadException
Load the command definitions in the specified file.
load
public void load(File file,
Locale locale)
throws LoadException
Load the command definitions in the specified file.
file
- the file to load.locale
- the locale to load.
load
public void load(InputStream in)
throws LoadException
Load the command definitions using the specified reader.
load
public void load(InputStream in,
Locale locale)
throws LoadException
Load the command definitions using the specified reader.
in
- the reader to use.locale
- the locale to load.
load
public void load(URL url)
throws LoadException
Load the command definitions from the specified URL.
url
- the url of the command definition file.
load
public void load(URL url,
Locale locale)
throws LoadException
Load the command definitions from the specified URL.
url
- the url of the command definition file.locale
- the locale to load.
registerCommand
protected void registerCommand(Command command)
Registers this command with the manager so it can be accessed by the
rest of the application.
command
- the command to register
removeHoverListener
public void removeHoverListener(HoverListener l)
setButtonFactory
public void setButtonFactory(ButtonFactory factory)
setClassLoader
public void setClassLoader(ClassLoader classLoader)
Sets the class loader the libary is to use for opertations like loading icons from the
classpath. This parameter must be set before calling load
to take affect.
classLoader
- the class loader to use for resource loading.
setConditionEvaluator
public void setConditionEvaluator(ConditionEvaluator conditionEvaluator)
Sets the commands managers condition evaluator. Conditions are used by
groups to determine if a given command should be included. This must be configured
before an command files are loaded.
The default implementation is an instance of
DefaultConditionEvaluator
.
conditionEvaluator
- the new condition evaluator.
setDefaultButtonFactory
public static void setDefaultButtonFactory(ButtonFactory defaultButtonFactory)
Configures the default factory to be used when creating buttons. This can be overriden
on a per command manager basis by calling
setButtonFactory(ButtonFactory)
.
defaultButtonFactory
- the factory to use when creating buttons.
setDefaultInstance
public static void setDefaultInstance(CommandManager manager)
Sets the command manager to use for
defaultInstance
singleton. The method must be
called before
defaultInstance()
is called. Otherwise an
IllegalStateException
will be
thrown.
manager
- the CommandManager instance to use as the default.
setDefaultMenuFactory
public static void setDefaultMenuFactory(MenuFactory defaultMenuFactory)
Configures the default factory to be used when creating menus. This can be overriden
on a per command manager basis by calling
setMenuFactory(MenuFactory)
.
defaultMenuFactory
- the factory to use when creating menus.
setDefaultToolbarFactory
public static void setDefaultToolbarFactory(ToolbarFactory defaultToolbarFactory)
Configures the default factory to be used when creating toolbars and toolbar buttons. This
can be overriden on a per command manager basis by calling
setToolbarFactory(ToolbarFactory)
.
defaultToolbarFactory
- the factory to use when creating toolbar and toolbar buttons.
setGroupFactory
public void setGroupFactory(GroupFactory groupFactory)
Sets the
GroupFactory
being used by the library. This factory will be used
by the library whenever a group must be created. This is typically during calls
to
getGroup(String)
.
setGroupMemberFactory
public void setGroupMemberFactory(GroupMemberFactory groupMemberFactory)
Gets the
GroupMemberFactory
used by the library to construct
GroupMember
. This factory
will be used by groups to create the infrastructure for managing its members. By pluggin custome implementations
you can control the way groups populate their containers.
setIconFactory
public void setIconFactory(IconFactory iconFactory)
setLoggerFactory
public static void setLoggerFactory(LoggerFactory loggerFactory)
Sets the log factory to use for creating new logger instances.
loggerFactory
- the factory to use.
setMenuFactory
public void setMenuFactory(MenuFactory factory)
Sets the
MenuFactory
that is to be used by commands to create menu items. This
factory will be used unless a specific factory has been configured for an individual
command.
setMenuTooltipsEnabled
public void setMenuTooltipsEnabled(boolean menuTooltipsEnabled)
Configures the current menu tooltip state and notifies all
faces
that the
state has changed. This setting will be used by all
faces
that haven't been
explicitly configured to enable or disable tooltips on menus.
menuTooltipsEnabled
- true to enable tooltips on menus, false to
disable them.
setResourceBundle
public void setResourceBundle(ResourceBundle resourceBundle)
Sets the java.util.ResourceBundle
for resolving i18n configuration parameters.
resourceBundle
- the ResourceBundle for resolving i18n configuration parameters.
setToolbarFactory
public void setToolbarFactory(ToolbarFactory factory)
Sets the
ToolbarFactory
that will be the default used by all commands when creating
toolbars and their associated buttons.