GUI Commands 2.0 has arrived! Find out what's new and improved.
Factories

GUI Commands uses factories at a number of different levels to facility easy customization of the library.  These are described below. 

Button, Toolbar and Menu Factories

All commands use the factories to create their buttons and menus.  This allows the library to use your own button, toolbar and menu implementations.  These factories can be configured at a number of different levels.

  • Globally by calling the static  setDefaultButtonFactory(...), setDefaultToolbarFactory(...) and setDefaultMenuFactory(...) on the CommandManager.
  • On a per CommandManager level by calling setButtonFactory(..), setToolbarFactory(..) and setMenuFactory(..) on the CommandManager.
  • On a per command/group level by calling setButtonFactory(..), setToolbarFactory(..) and setMenuFactory(..) on the Command.
  • On a per attachment level by calling the appropriate create method on the command with the desired factory.

For example, if you have your own toolbar implementation, you could create your own ToolbarFactory and call CommandManager.defaultInstance().setDefaultToolbarFactory().

The factories used by the library by default are DefaultButtonFactory, DefaultToolbarFactory and DefaultMenuFactory.

GroupFactory

The group factory allows control over the implementation of CommandGroups created by the library.  This is particularly useful if you want all your groups to be capable of providing a custom widget.  In such a case you'd develop your custom group implementation and then call CommandManager.defaultInstance().setGroupFactory(..) with a factory that creates it.  Feel free to subcalss DefaultGroupFactory.