|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.levigo.util.swing.action.DefaultMenuComponentFactory
public class DefaultMenuComponentFactory
Used by GUI components to create CommandAction-based toolbars, contextmenus and menus. This class not just returns GUI components, but can also return a collection of actions for a specific area (given by the template key or context name which is used as a key).
MenuComponentFactory
Field Summary | |
---|---|
static String |
COMPONENT_KEY
Accessor key for the structure identifier of JComponents builded by this factory. |
static String |
COMPONENT_RESOURCE
Accessor key for the resource name of JComponents builded by this factory. |
protected String |
factoryName
Name of this menu component factory, usually its properties file name. |
protected List<BasicMenuComponentFactory> |
linkedMenuComponentFactories
List of associated menu component factories |
Fields inherited from interface com.levigo.util.swing.action.MenuComponentFactory |
---|
ACTIONS, CONTEXT_MENU_ACTIONS, MENU_ACTIONS, TOOLBAR_ACTIONS |
Method Summary | |
---|---|
void |
addLinkedMenuComponentFactory(BasicMenuComponentFactory menuComponentFactory)
Adds a menu component factory as linked factory to this factory. |
static void |
addMenuComponentCreationListener(MenuComponentCreationListener listener)
Adds a command creation listener to receive informations or failure messages of command creation process. |
Collection<String> |
getActions(String key)
Create a collection of all currently available action names(!) for the given template key. |
Collection<String> |
getActionsForType(String key,
String type)
Create a collection of all currently available action names(!) for the given template key and action structure type. |
Collection<CommandAction> |
getCommandActions(String key,
Context context)
Create all currently available command actions for the given template key. |
JPopupMenu |
getContextMenu(String key,
Context context)
Create a JPopupMenu for the given template key or context name. |
JPopupMenu |
getContextMenu(String key,
Context context,
Action[] additionalActions)
Create a JPopupMenu for the given template key or context name. |
String |
getFactoryName()
Returns the name of this factory, usually its properties resource name. |
static DefaultMenuComponentFactory |
getInstance(String propertiesFileName)
Create instance for the factory. |
String |
getLinkedFactoryDescription()
Returns a description of linked factories. |
NamedMenuComponentFactory[] |
getLinkedMenuComponentFactories()
Returns an array of linked menu component factories |
String |
getLookupProperty(String key)
Allows an application to programmatically request lookup properties. |
JMenu |
getMenu(String key,
Context context)
Create a JMenu for the given template key or context name. |
JMenu |
getMenu(String key,
Context context,
Action[] additionalActions)
Create a JMenu for the given template key or context name. |
JMenuBar |
getMenuBar(String key,
Context context)
Create a JMenuBar for the given template key or context name. |
static MenuComponentCreationListener[] |
getMenuComponentCreationListeners()
Returns an array of currently registered creation listeners |
JToolBar |
getToolbar(String key,
Context context)
Create a JToolBar for the given template key or context name. |
JToolBar |
getToolbar(String key,
Context context,
Action[] additionalActions)
Create a JToolbar for the given template key or context name. |
void |
insertLinkedMenuComponentFactory(int index,
BasicMenuComponentFactory menuComponentFactory)
Inserts a menu component factory at index position of linked factories. |
static boolean |
isIgnoreEmptyActions()
Returns an indicator whether to ignore actions with no commands configured. |
void |
putLookupProperty(String key,
String value)
Deprecated. use setLookupProperty(String, String) instead |
void |
removeLinkedMenuComponentFactory(BasicMenuComponentFactory menuComponentFactory)
Removes a menu component factory of linked factories. |
static void |
removeMenuComponentCreationListener(MenuComponentCreationListener listener)
Removes a command creation listener. |
void |
reset()
Clears, resets and reloads this factory instance. |
static void |
setIgnoreEmptyActions(boolean ignore)
Whether to ignore actions with no commands configured. |
void |
setLookupProperty(String key,
String value)
Allows an application to overwrite or set lookup properties programmatically. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static String COMPONENT_RESOURCE
public static String COMPONENT_KEY
protected List<BasicMenuComponentFactory> linkedMenuComponentFactories
protected String factoryName
Method Detail |
---|
public static void setIgnoreEmptyActions(boolean ignore)
It may be "misconfigured" by purpose to support a "maximum" action set in a modular product. In some deployments, not all actions may be available. If this is the case, we certainly do not want to paint menu entries for non-existent actions.
ignore
- public static boolean isIgnoreEmptyActions()
It may be "misconfigured" by purpose to support a "maximum" action set in a modular product. In some deployments, not all actions may be available. If this is the case, we certainly do not want to paint menu entries for non-existent actions.
public static void addMenuComponentCreationListener(MenuComponentCreationListener listener)
listener
- the listener instance to addpublic static void removeMenuComponentCreationListener(MenuComponentCreationListener listener)
listener
- the listener instance to removepublic static MenuComponentCreationListener[] getMenuComponentCreationListeners()
public static DefaultMenuComponentFactory getInstance(String propertiesFileName)
MenuComponentFactory
but just one instance.
The default properties File doesn't have to be used. It can be used the custom property File. If the custom property file is null then will be the default property file used.
propertiesFileName
- custom properties file name
public String getLinkedFactoryDescription()
public String getFactoryName()
NamedMenuComponentFactory
getFactoryName
in interface NamedMenuComponentFactory
NamedMenuComponentFactory.getFactoryName()
public Collection<String> getActions(String key)
MenuComponentFactory
MenuComponentFactory
.ACTIONS);
getActions
in interface MenuComponentFactory
key
- template key
MenuComponentFactory.getActions(java.lang.String)
public Collection<CommandAction> getCommandActions(String key, Context context)
MenuComponentFactory
getCommandActions
in interface MenuComponentFactory
key
- template key for action structurecontext
- the returned actions refer to this context.
MenuComponentFactory.getCommandActions(java.lang.String,
com.levigo.util.swing.action.Context)
public JPopupMenu getContextMenu(String key, Context context)
MenuComponentFactory
JPopupMenu
for the given template key or context name.
getContextMenu
in interface MenuComponentFactory
key
- of the context menu which should be createdcontext
- for the actions in the context menu. Actions in the context
menu belong then in this context.
MenuComponentFactory.getContextMenu(java.lang.String,
com.levigo.util.swing.action.Context)
public JPopupMenu getContextMenu(String key, Context context, Action[] additionalActions)
MenuComponentFactory
getContextMenu
in interface MenuComponentFactory
MenuComponentFactory.getContextMenu(java.lang.String,
com.levigo.util.swing.action.Context, javax.swing.Action[])
public JMenu getMenu(String key, Context context)
MenuComponentFactory
JMenu
for the given template key or context name.
Note:The JMenuBar
is created outside of this factory.
The created menus can be added in the JMenuBar
!
getMenu
in interface MenuComponentFactory
key
- of the menu which should be createdcontext
- for the actions in the menu. Actions in the menu belong then
in this context.
MenuComponentFactory.getMenu(java.lang.String,
com.levigo.util.swing.action.Context)
public JMenu getMenu(String key, Context context, Action[] additionalActions)
MenuComponentFactory
getMenu
in interface MenuComponentFactory
MenuComponentFactory.getMenu(java.lang.String,
com.levigo.util.swing.action.Context, javax.swing.Action[])
public JToolBar getToolbar(String key, Context context)
MenuComponentFactory
JToolBar
for the given template key or context name.
getToolbar
in interface MenuComponentFactory
key
- of the toolbar which should be createdcontext
- for the actions in the toolbar. Actions in the toolbar
belong then in this context.
MenuComponentFactory.getToolbar(java.lang.String,
com.levigo.util.swing.action.Context)
public JToolBar getToolbar(String key, Context context, Action[] additionalActions)
MenuComponentFactory
getToolbar
in interface MenuComponentFactory
MenuComponentFactory.getToolbar(java.lang.String,
com.levigo.util.swing.action.Context, javax.swing.Action[])
public JMenuBar getMenuBar(String key, Context context)
MenuComponentFactory
JMenuBar
for the given template key or context name.
getMenuBar
in interface MenuComponentFactory
MenuComponentFactory.getMenuBar(java.lang.String,
com.levigo.util.swing.action.Context)
public void putLookupProperty(String key, String value)
setLookupProperty(String, String)
instead
key
- value
- The value of the given key, null
if the key is
not mapped to any value.public void setLookupProperty(String key, String value)
key
- value
- The value of the given key, null
if the key is
not mapped to any value.
NullPointerException
- if the key or value is null
.public String getLookupProperty(String key)
key
- A key to look up
null
if the key is
not mapped to any value.
NullPointerException
- if the key is null.public Collection<String> getActionsForType(String key, String type)
MenuComponentFactory
getActionsForType
in interface MenuComponentFactory
key
- template keytype
- structure type like MenuComponentFactory
MenuComponentFactory.ACTIONS
,
MenuComponentFactory
MenuComponentFactory.CONTEXT_MENU_ACTIONS
,MenuComponentFactory
MenuComponentFactory.MENU_ACTIONS
,MenuComponentFactory
MenuComponentFactory.TOOLBAR_ACTIONS
MenuComponentFactory.getActionsForType(java.lang.String,
java.lang.String)
public NamedMenuComponentFactory[] getLinkedMenuComponentFactories()
NamedMenuComponentFactory
[] linked menu component
factories.public void addLinkedMenuComponentFactory(BasicMenuComponentFactory menuComponentFactory)
menuComponentFactory
- factory to addpublic void removeLinkedMenuComponentFactory(BasicMenuComponentFactory menuComponentFactory)
menuComponentFactory
- factory to removepublic void insertLinkedMenuComponentFactory(int index, BasicMenuComponentFactory menuComponentFactory)
index
- index of factorymenuComponentFactory
- factory to insertpublic void reset()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |