Class MenuTag
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- net.sf.jguiraffe.gui.builder.components.tags.FormBaseTag
-
- net.sf.jguiraffe.gui.builder.action.tags.MenuTag
-
- All Implemented Interfaces:
ActionContainer,ConditionalTag,IconSupport,org.apache.commons.jelly.Tag
public class MenuTag extends FormBaseTag implements ActionContainer, IconSupport
A tag handler class for defining menus.
With this tag handler a menu object can be defined that belongs to a menu bar. This menu is defined by a text, a mnemonic, and an optional icon (not all platforms may support icons for menus). Text and/or mnemonic can be specified either directly or as resource IDs.
The following table lists all supported attributes:
Attribute Description Optional textWith this attribute the menu's text can directly be set. yes textresDefines the resource ID for the menu's text. The real text is resolved using the current resource manager and the current locale. yes resgrpSpecifies the resource group of the menu's text. If set, this resource group is used when resolving the menu's text as defined by the textresattribute. If undefined, the form builder's default resource group will be used.yes mnemonicHere a mnemonic for this menu can be specified. yes mnemonicresThis attribute defines the mnemonic as a resource, which makes sense for i18n applications. yes In this tag's body an icon tag can be placed to define the icon for the menu.
- Version:
- $Id: MenuTag.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description MenuTag()Creates a new instance ofMenuTag.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSeparator()Adds a separator to this menu.protected ActionContainerfindParentContainer()Tries to find the action container for the parent menu.protected ObjectfindParentMenu()Tries to find the parent menu to which this menu has to be added.protected ActionBuildergetActionBuilder()Returns a reference to the currentActionBuilderinstance.protected ActionManagergetActionManager()Convenience method for obtaining a reference to the currentActionManager.ObjectgetContainer()Returns the container maintained by this tag.TextIconDatagetData()Returns the definition data for this menu.protected voidprocess()Executes this tag.protected voidprocessBeforeBody()Executes this tag before its body is processed.voidsetIcon(Object icon)Sets the icon for this menu.voidsetMnemonic(String s)Setter method for the mnemonic attribute.voidsetMnemonicres(String s)Setter method for the mnemonicres attribute.voidsetResgrp(String s)Setter method for the resgrp attribute.voidsetText(String s)Setter method for the text attribute.voidsetTextres(String s)Setter method for the textres attribute.-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.FormBaseTag
canProcess, canProcess, convertToClass, convertToNumberWithUnit, convertToNumberWithUnit, doTag, findContainer, getBuilderData, getBuilderData, getIfName, getResourceText, getResourceText, getUnlessName, setIfName, setUnlessName
-
Methods inherited from class org.apache.commons.jelly.TagSupport
findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, getBody, getBodyText, getBodyText, getContext, getParent, invokeBody, isEscapeText, isTrim, setBody, setContext, setEscapeText, setParent, setTrim, trimBody
-
-
-
-
Method Detail
-
getData
public TextIconData getData()
Returns the definition data for this menu.- Returns:
- the data for this menu
-
getContainer
public Object getContainer()
Returns the container maintained by this tag. This implementation returns the menu object.- Specified by:
getContainerin interfaceActionContainer- Returns:
- the container object
-
setIcon
public void setIcon(Object icon)
Sets the icon for this menu.- Specified by:
setIconin interfaceIconSupport- Parameters:
icon- the icon
-
setText
public void setText(String s)
Setter method for the text attribute.- Parameters:
s- the attribute value
-
setTextres
public void setTextres(String s)
Setter method for the textres attribute.- Parameters:
s- the attribute value
-
setResgrp
public void setResgrp(String s)
Setter method for the resgrp attribute.- Parameters:
s- the attribute value
-
setMnemonic
public void setMnemonic(String s)
Setter method for the mnemonic attribute.- Parameters:
s- the attribute value
-
setMnemonicres
public void setMnemonicres(String s)
Setter method for the mnemonicres attribute.- Parameters:
s- the attribute value
-
addSeparator
public void addSeparator() throws FormActionExceptionAdds a separator to this menu. This task is delegated to the current action manager.- Specified by:
addSeparatorin interfaceActionContainer- Throws:
FormActionException- if an error occurs
-
processBeforeBody
protected void processBeforeBody() throws org.apache.commons.jelly.JellyTagException, FormBuilderExceptionExecutes this tag before its body is processed. This implementation creates the menu object and stores it in an internal member field.- Overrides:
processBeforeBodyin classFormBaseTag- Throws:
org.apache.commons.jelly.JellyTagException- if the tag is not used correctlyFormBuilderException- if an error occurs
-
process
protected void process() throws org.apache.commons.jelly.JellyTagException, FormBuilderExceptionExecutes this tag. Performs further initialization of the menu.- Specified by:
processin classFormBaseTag- Throws:
org.apache.commons.jelly.JellyTagException- if the tag is not used correctlyFormBuilderException- if an error occurs
-
findParentMenu
protected Object findParentMenu() throws org.apache.commons.jelly.JellyTagException
Tries to find the parent menu to which this menu has to be added. This can be either a menu bar or another menu this menu is a sub menu from. If neither a nesting menu bar tag nor a menu tag can be found, an exception will be thrown.- Returns:
- the parent menu
- Throws:
org.apache.commons.jelly.JellyTagException- if no parent can be found
-
findParentContainer
protected ActionContainer findParentContainer()
Tries to find the action container for the parent menu. This tag can occur inside a menu bar tag or a menu tag. If none of these is found, null is returned.- Returns:
- the parent menu container
-
getActionBuilder
protected ActionBuilder getActionBuilder()
Returns a reference to the currentActionBuilderinstance. This instance is expected to be placed in the Jelly context.- Returns:
- the current action builder
-
getActionManager
protected ActionManager getActionManager()
Convenience method for obtaining a reference to the currentActionManager.- Returns:
- the current action manager
-
-