|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pietschy.command.CommandManager
public class CommandManager
The CommandManger is the core of the GUI Command libarary. It provides the mechanism to load
command configuration files and to manage and locate ActionCommand
and CommandGroup
instances.
load(java.io.File)
,
load(java.net.URL)
,
load(java.io.InputStream)
,
getGroup(java.lang.String)
,
getCommand(java.lang.String)
Field Summary | |
---|---|
protected java.util.HashMap |
registeredCommands
|
Constructor Summary | |
---|---|
CommandManager()
Constructs and initializes the command manager. |
|
CommandManager(CommandManager parent)
Constructs and initializes the command manager. |
|
CommandManager(CommandManager parent,
java.lang.Object context)
Constructs and initializes the command manager. |
|
CommandManager(java.lang.Object context)
Constructs and initializes the command manager. |
Method Summary | |
---|---|
void |
addCommandManagerListener(CommandManagerListener l)
|
void |
addHoverListener(HoverListener l)
Adds a HoverListener to the command manager. |
java.util.Iterator |
commandIterator()
|
void |
commandRegistered(CommandManagerEvent event)
Pass on events from our parent. |
protected void |
configure(Command command)
Initialises the command from the current loaded set of properties. |
static CommandManager |
defaultInstance()
Returns an instance of the CommandManager. |
void |
dispose()
This method removes any listeners from this command managers parent (if it exists). |
protected void |
fireCommandRegistered(Command command)
|
protected void |
fireHoverEnded(HoverEvent e)
|
protected void |
fireHoverStarted(HoverEvent e)
|
ButtonFactory |
getButtonFactory()
Gets the default ButtonFactory to use for buttons created by this command manager. |
java.lang.ClassLoader |
getClassLoader()
Gets the class loader the library is to use. |
ActionCommand |
getCommand(java.lang.String commandId)
Gets the specifed command from this container. |
CommandManagerListener[] |
getCommandManagerListeners()
|
ConditionEvaluator |
getConditionEvaluator()
Gets the commands managers current condition evaluator. |
java.lang.Object |
getContext()
Gets the context object specified in the constructor. |
static ButtonFactory |
getDefaultButtonFactory()
Gets the default ButtonFactory . |
static MenuFactory |
getDefaultMenuFactory()
Gets the default MenuFactory . |
static ToolbarFactory |
getDefaultToolbarFactory()
Gets the default ToolbarFactory . |
FaceManager |
getFaceManager()
Gets the FaceManager in use by the CommandManager. |
CommandGroup |
getGroup(java.lang.String groupId)
Gets the specifed group from the container. |
GroupFactory |
getGroupFactory()
Gets the GroupFactory being used by the library. |
GroupMemberFactory |
getGroupMemberFactory()
Gets the GroupMemberFactory used by the library to construct GroupMember . |
IconFactory |
getIconFactory()
Gets this command managers IconFactory . |
static Logger |
getLogger(java.lang.Class aClass)
Gets a new logger for the command library. |
MenuFactory |
getMenuFactory()
Gets the MenuFactory that is to be used by commands to create menu items. |
CommandManager |
getParent()
Gets the parent of this CommandManager . |
java.util.ResourceBundle |
getResourceBundle()
Gets the ResourceBundle for resolving i18n configuration parameters. |
ToolbarFactory |
getToolbarFactory()
Gets the default ToolbarFactory to be used by commands to create toolbars and their
associated buttons. |
static CommandManager |
instance()
Deprecated. defaultInstance should now be the preferred method for obtaining the
global command manager. This method will be removed in a future release. |
boolean |
isGroup(java.lang.String commandId)
Checks if the command identified by the specified id is a group. |
static boolean |
isMacOS()
A convenience method for GUI Commands to check if we're running in an apple Mac environment. |
boolean |
isMenuTooltipsEnabled()
Checks if tooltip are globally enabled on menus. |
protected boolean |
isRegistered(Command command)
|
void |
load(java.io.File file)
Load the command definitions in the specified file. |
void |
load(java.io.File file,
java.util.Locale locale)
Load the command definitions in the specified file. |
void |
load(java.io.InputStream in)
Load the command definitions using the specified reader. |
void |
load(java.io.InputStream in,
java.util.Locale locale)
Load the command definitions using the specified reader. |
void |
load(java.net.URL url)
Load the command definitions from the specified URL. |
void |
load(java.net.URL url,
java.util.Locale locale)
Load the command definitions from the specified URL. |
protected void |
registerCommand(Command command)
Registers this command with the manager so it can be accessed by the rest of the application. |
void |
removeCommandManagerListener(CommandManagerListener l)
|
void |
removeHoverListener(HoverListener l)
Removes the HoverListener from the command manager. |
void |
setButtonFactory(ButtonFactory factory)
Sets the ButtonFactory that will be the default used by all ActionCommand s and
CommandGroup s. |
void |
setClassLoader(java.lang.ClassLoader classLoader)
Sets the class loader the libary is to use for opertations like loading icons from the classpath. |
void |
setConditionEvaluator(ConditionEvaluator conditionEvaluator)
Sets the commands managers condition evaluator. |
static void |
setDefaultButtonFactory(ButtonFactory defaultButtonFactory)
Configures the default factory to be used when creating buttons. |
static void |
setDefaultInstance(CommandManager manager)
Sets the command manager to use for defaultInstance singleton. |
static void |
setDefaultMenuFactory(MenuFactory defaultMenuFactory)
Configures the default factory to be used when creating menus. |
static void |
setDefaultToolbarFactory(ToolbarFactory defaultToolbarFactory)
Configures the default factory to be used when creating toolbars and toolbar buttons. |
void |
setGroupFactory(GroupFactory groupFactory)
Sets the GroupFactory being used by the library. |
void |
setGroupMemberFactory(GroupMemberFactory groupMemberFactory)
Gets the GroupMemberFactory used by the library to construct GroupMember . |
void |
setIconFactory(IconFactory iconFactory)
Sets this command managers IconFactory . |
static void |
setLoggerFactory(LoggerFactory loggerFactory)
Sets the log factory to use for creating new logger instances. |
void |
setMenuFactory(MenuFactory factory)
Sets the MenuFactory that is to be used by commands to create menu items. |
void |
setMenuTooltipsEnabled(boolean menuTooltipsEnabled)
Configures the current menu tooltip state and notifies all faces that the
state has changed. |
void |
setResourceBundle(java.util.ResourceBundle resourceBundle)
Sets the ResourceBundle for resolving i18n configuration parameters. |
void |
setToolbarFactory(ToolbarFactory factory)
Sets the ToolbarFactory that will be the default used by all commands when creating
toolbars and their associated buttons. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.HashMap registeredCommands
Constructor Detail |
---|
public CommandManager()
public CommandManager(java.lang.Object context)
public CommandManager(CommandManager parent)
public CommandManager(CommandManager parent, java.lang.Object context)
Method Detail |
---|
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.
setDefaultInstance(org.pietschy.command.CommandManager)
before calling this method.
public static CommandManager defaultInstance()
setDefaultInstance(org.pietschy.command.CommandManager)
before calling this method.
public static void setDefaultInstance(CommandManager manager)
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.public static Logger getLogger(java.lang.Class aClass)
setLoggerFactory(org.pietschy.command.log.LoggerFactory)
public static void setLoggerFactory(LoggerFactory loggerFactory)
loggerFactory
- the factory to use.getLogger(java.lang.Class)
public static boolean isMacOS()
true
if running in the Mac environment, false
otherwise.public static MenuFactory getDefaultMenuFactory()
MenuFactory
.
MenuFactory
.public static void setDefaultMenuFactory(MenuFactory defaultMenuFactory)
setMenuFactory(MenuFactory)
.
defaultMenuFactory
- the factory to use when creating menus.public static ButtonFactory getDefaultButtonFactory()
ButtonFactory
.
ButtonFactory
.public static void setDefaultButtonFactory(ButtonFactory defaultButtonFactory)
setButtonFactory(ButtonFactory)
.
defaultButtonFactory
- the factory to use when creating buttons.public static ToolbarFactory getDefaultToolbarFactory()
ToolbarFactory
.
ToolbarFactory
.public static void setDefaultToolbarFactory(ToolbarFactory defaultToolbarFactory)
setToolbarFactory(ToolbarFactory)
.
defaultToolbarFactory
- the factory to use when creating toolbar and toolbar buttons.public CommandManager getParent()
CommandManager
. If present, the parent is used to resolve
requests for ActionCommands
that aren't present in this
CommandManager
CommandManager
or null if it doesn't have a parent.public void dispose()
public java.lang.Object getContext()
public java.lang.ClassLoader getClassLoader()
ClassLoader
the library is to use.setClassLoader(java.lang.ClassLoader)
public void setClassLoader(java.lang.ClassLoader classLoader)
load(java.io.File)
to take affect.
classLoader
- the class loader to use for resource loading.public java.util.ResourceBundle getResourceBundle()
ResourceBundle
for resolving i18n configuration parameters. This value is
null by default.
setResourceBundle(java.util.ResourceBundle)
public void setResourceBundle(java.util.ResourceBundle resourceBundle)
ResourceBundle
for resolving i18n configuration parameters.
resourceBundle
- the ResourceBundle for resolving i18n configuration parameters.getResourceBundle()
public ConditionEvaluator getConditionEvaluator()
public void setConditionEvaluator(ConditionEvaluator conditionEvaluator)
The default implementation is an instance of DefaultConditionEvaluator
.
conditionEvaluator
- the new condition evaluator.public IconFactory getIconFactory()
IconFactory
. If the icon factory
hasn't been configured, the parent, if present, is queried.
IconFactory
.public void setIconFactory(IconFactory iconFactory)
IconFactory
.
iconFactory
- this command managers IconFactory
.public boolean isMenuTooltipsEnabled()
faces
that haven't been explicitly configured to enable or disable tooltips on
menus.
public void setMenuTooltipsEnabled(boolean menuTooltipsEnabled)
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.public MenuFactory getMenuFactory()
MenuFactory
that is to be used by commands to create menu items. If not
explicitly set, the global getDefaultMenuFactory()
will be used.
MenuFactory
that is to be used by commands to create menu items.setMenuFactory(org.pietschy.command.MenuFactory)
public void setMenuFactory(MenuFactory factory)
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.
public ButtonFactory getButtonFactory()
ButtonFactory
to use for buttons created by this command manager.
If explicitly configured the global getDefaultButtonFactory()
will be used.
public void setButtonFactory(ButtonFactory factory)
ButtonFactory
that will be the default used by all ActionCommand
s and
CommandGroup
s.
factory
- the default ButtonFactory
public ToolbarFactory getToolbarFactory()
ToolbarFactory
to be used by commands to create toolbars and their
associated buttons. If not explicitly set, the global getDefaultToolbarFactory()
will be used.
ToolbarFactory
.public void setToolbarFactory(ToolbarFactory factory)
ToolbarFactory
that will be the default used by all commands when creating
toolbars and their associated buttons.
factory
- the default ToolbarFactory
.public GroupFactory getGroupFactory()
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(java.lang.String)
.
GroupFactory
being used by the library.setGroupFactory(org.pietschy.command.GroupFactory)
public void setGroupFactory(GroupFactory groupFactory)
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(java.lang.String)
.
groupFactory
- the GroupFactory
to use.public GroupMemberFactory getGroupMemberFactory()
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.
GroupMemberFactory
.CommandGroup.getMemberFactory()
public void setGroupMemberFactory(GroupMemberFactory groupMemberFactory)
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.
groupMemberFactory
- the default GroupMemberFactory
for all groups to use.public FaceManager getFaceManager()
FaceManager
in use by the CommandManager.
FaceManager
in use by the CommandManager.public void load(java.io.File file) throws LoadException
file
- the file to load.
LoadException
- if an error occurs loading the file.public void load(java.io.File file, java.util.Locale locale) throws LoadException
file
- the file to load.locale
- the locale to load.
LoadException
- if an error occurs loading the file.public void load(java.net.URL url) throws LoadException
url
- the url of the command definition file.
LoadException
- if an error occurs loading the file.public void load(java.net.URL url, java.util.Locale locale) throws LoadException
url
- the url of the command definition file.locale
- the locale to load.
LoadException
- if an error occurs loading the file.public void load(java.io.InputStream in) throws LoadException
in
- the reader to use.
LoadException
- if an error occurs loading the file.public void load(java.io.InputStream in, java.util.Locale locale) throws LoadException
in
- the reader to use.locale
- the locale to load.
LoadException
- if an error occurs loading the file.protected void configure(Command command)
command
- the Command
to initialise.public boolean isGroup(java.lang.String commandId)
commandId
- the command id.
CommandGroup
, false
otherwise.public void addHoverListener(HoverListener l)
HoverListener
to the command manager. The listener will be notified when
ever the mouse hovers over a command.
l
- the hover listenerHoverListener
,
removeHoverListener(org.pietschy.command.HoverListener)
public void removeHoverListener(HoverListener l)
HoverListener
from the command manager.
l
- the hover listenerHoverListener
,
addHoverListener(org.pietschy.command.HoverListener)
protected void fireHoverStarted(HoverEvent e)
protected void fireHoverEnded(HoverEvent e)
protected void registerCommand(Command command)
command
- the command to registerprotected boolean isRegistered(Command command)
public ActionCommand getCommand(java.lang.String commandId)
commandId
- the commands id.
public CommandGroup getGroup(java.lang.String groupId)
groupId
- the Id of the group.
CommandGroup
with the specified Id.public java.util.Iterator commandIterator()
public void commandRegistered(CommandManagerEvent event)
commandRegistered
in interface CommandManagerListener
event
- public void addCommandManagerListener(CommandManagerListener l)
public void removeCommandManagerListener(CommandManagerListener l)
public CommandManagerListener[] getCommandManagerListeners()
protected void fireCommandRegistered(Command command)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |