|
SRJRCFrames v0.1.296 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.schwarzrot.ui.action.support.ApplicationCommandFactory
public class ApplicationCommandFactory
a factory to generate action related UI elements like menues, menuebars, toolbars. General menubar creation is implemented by contract. The application defines some enums, that serve as key in message lookup and translation, as well as finding related icons, ...
To allow general processing, the name of the enum consists of several parts. Divider is the '_' (underscore).
sample:
private enum Command { FILE_NEW, SEP_FILE_0, FILE_READ, FILE_WRITE, SEP_FILE_1, FILE_EXIT, VIEW_DETAIL, SEP_VIEW_0, VIEW_SPECIAL, EDIT_RENAME, EDIT_TAG, EDIT_SPLIT, EDIT_JOIN, SEP_EDIT_0, EDIT_PREFERENCES, EXTRA_SCAN, EXTRA_SWITCH_SUB };The last enum entry consists of 3 parts: EXTRA, wich is recognized as menue identifier (menu-name of menubar). The second part SWITCH is the simple name of the menue action (but the action identifier is the entire enum name). The last part SUB signals, that this menueitem will be a submenu.
Another special entry is i.e. SEP_FILE_0, where the first part SEP signals the creation of a separator. So the second part FILE is the menue identifier, where the separator should be added to. To allow multiple separators in command definitions, a suffix may be added. Its value is to keep enum entries unique, the suffix is not evaluated at all.
The items will be processed in the given order, so different orders in different situations could be fulfilled by the use of EnumSet.
The creation of submenus is performed by a call to
ActionHandler.createSubMenu(<i>Enum<?> cmd</i>)
, so dynamic
menus could be created, as well as static submenus. The default
implementation of createSubMenu
returns null.
The ActionHandler
is a class to hold and handle Actions, as well as
to provide access to actions by name. All ActionHandlers are related and able
to find a given Action, even if it was defined in an unknown, but active
Handler. For this reason - naturally - the handler names must be unique - as
well as the application identifiers.
The Desktop class is responsable for the main menue and the handling of
active applications. To fulfill that job, the application has a public
accessor to the default ActionHandler ActionHandler getActionHandler
.
The ActionHandler
itself gives access to its implemented
ActionCommands by the getter Enum<?>[] getCommands()
.
AbstractDesktop
,
Application
,
ActionHandler
Constructor Summary | |
---|---|
ApplicationCommandFactory(ActionHandler[] handlers)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ApplicationCommandFactory(ActionHandler[] handlers)
Method Detail |
---|
public JButton createButton(String appID, Enum<?> cmd)
public JMenuItem createCheckBoxMenuItem(String appID, Enum<?> cmd)
public JMenuItem createContextMenuItem(String appID, Enum<?> cmd, Object context)
public JMenu createMenu(Enum<?> cmd)
public JMenu createMenu(String key)
public JMenu createMenu(String name, Enum<?>[] commands)
public JMenu createMenu(String name, Enum<?>[][] cmdList)
public JMenu createMenu(String appID, String menuID)
public JMenu createMenu(String name, String[] commands)
public JMenuBar createMenuBar()
public JMenuBar createMenuBar(JMenuBar menuBar, String name, Enum<?>[] commands)
public JMenuItem createMenuItem(String appID, Enum<?> cmd)
public JMenuItem createMenuItem(String appID, String actionKey)
public JPopupMenu createPopup(String name, Enum<?>[] commands)
public JPopupMenu createPopup(String name, Enum<?>[][] cmdList)
public JMenuItem createRadioButtonMenuItem(String appID, Enum<?> cmd)
public JToolBar createToolBar()
public JToolBar createToolBar(int orientation)
public JToolBar createToolBar(String appID, Enum<?>[] commands)
public JToolBar createToolBar(String appID, Enum<?>[] commands, int orientation)
public JButton createToolBarButton(String appID, Enum<?> cmd, int orientation)
public JButton createToolBarButton(String appID, String cmd, int orientation)
public final ActionHandler[] getHandlers()
public void setupAppIcon(JToggleButton ai, String name)
protected JMenu buildMenu(JMenu menu, String name, Enum<?>[] commands)
protected JPopupMenu buildPopup(JPopupMenu pm, String name, Enum<?>[] commands)
protected void createMenus(JMenuBar menuBar, String name, Enum<?>[] commands)
protected JMenu createSubMenu(Enum<?> cmd)
protected JMenu createSubMenu(String cmd)
protected void createToolBar(JToolBar tb, String appID, Enum<?>[] commands, int orientation)
protected AbstractAction findAction(Enum<?> cmd)
protected AbstractAction findAction(String itemID)
protected AbstractAction findAction(String appID, Enum<?> cmd)
protected AbstractAction findAction(String appID, String cmd)
protected void validateMenu(JMenu menu)
protected void validateMenuBar(JMenuBar mb)
|
SRJRCFrames v0.1.296 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |