be.ugent.caagt.swirl.menus
Class MenuBuilder
java.lang.Object
be.ugent.caagt.swirl.menus.MenuBuilder
public class MenuBuilder
extends java.lang.Object
Allows menus to be constructed from a configuration file.
The configuration file uses an XML-format, the DTD of which can be found
here. The corresponding
public identifier is "
-//SWIRL//MenuBuilder configuration 1.0//EN
".
More information can be found in the
MenuBuilder tutorial.
MenuBuilder() - Create a new object of this type with a default action map.
|
MenuBuilder(ActionMap actionMap) - Create a new object of this type with the associated action map.
|
JMenuBar | createJMenuBar(String key) - Build a menu bar which corresponds to the root configuration
element with the given key.
|
JPopupMenu | createJPopupMenu(String key) - Build a popup menu which corresponds to the menu configuration
element with the given key.
|
JToolBar | createJToolBar(String key) - Build a tool bar which corresponds to the menu configuration
element with the given key.
|
ActionMap | getActionMap() - The action map used by this builder
|
void | load(InputStream inputStream, String bundleName) - Load configuration information from the given input stream.
|
void | load(String resource, String bundleName) - Load configuration information from the given class path resource.
|
void | registerAction(String id, Action action) - Register an action this builder.
|
void | registerToggle(String id, ItemListener itemListener) - Register an item listener for a toggle.
|
void | removePredicate(String predicate) - Remove (unset) the predicate with the given name.
|
void | setPredicate(String predicate) - Set a predicate with the given name.
|
MenuBuilder
public MenuBuilder()
Create a new object of this type with a default action map.
MenuBuilder
public MenuBuilder(ActionMap actionMap)
Create a new object of this type with the associated action map.
createJMenuBar
public JMenuBar createJMenuBar(String key)
Build a menu bar which corresponds to the root configuration
element with the given key. All actions, groups and toggles that occur
in this menu must have been registered with the builder before this
method is called.
createJPopupMenu
public JPopupMenu createJPopupMenu(String key)
Build a popup menu which corresponds to the menu configuration
element with the given key.
createJToolBar
public JToolBar createJToolBar(String key)
Build a tool bar which corresponds to the menu configuration
element with the given key. The menu element should not have any submenus.
getActionMap
public ActionMap getActionMap()
The action map used by this builder
- the cation map used by this builder
load
public void load(InputStream inputStream,
String bundleName)
throws IOException
Load configuration information from the given input stream.
bundleName
- Name of the resource bundle which will be used
to resolve the various keys in the cnofiguration file
load
public void load(String resource,
String bundleName)
Load configuration information from the given class path resource.
bundleName
- Name of the resource bundle which will be used
to resolve the various keys in the cnofiguration file
registerAction
public void registerAction(String id,
Action action)
Register an action this builder.
Has the same effect as registering the action with the action map
of this builder.
id
- Identifier used in the configuration file for this actionaction
- Action object to be associated with this identifier
registerToggle
public void registerToggle(String id,
ItemListener itemListener)
Register an item listener for a toggle.
id
- Identifier used for this toggle in the configuration fileitemListener
- Item listener to be associated with this identifier
removePredicate
public void removePredicate(String predicate)
Remove (unset) the predicate with the given name.
setPredicate
public void setPredicate(String predicate)
Set a predicate with the given name. Predicates can influence
which parts of a menu are built.