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 text
With this attribute the menu's text can directly be set. yes textres
Defines the resource ID for the menu's text. The real text is resolved using the current resource manager and the current locale. yes resgrp
Specifies 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 textres
attribute. If undefined, the form builder's default resource group will be used.yes mnemonic
Here a mnemonic for this menu can be specified. yes mnemonicres
This 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 void
addSeparator()
Adds a separator to this menu.protected ActionContainer
findParentContainer()
Tries to find the action container for the parent menu.protected Object
findParentMenu()
Tries to find the parent menu to which this menu has to be added.protected ActionBuilder
getActionBuilder()
Returns a reference to the currentActionBuilder
instance.protected ActionManager
getActionManager()
Convenience method for obtaining a reference to the currentActionManager
.Object
getContainer()
Returns the container maintained by this tag.TextIconData
getData()
Returns the definition data for this menu.protected void
process()
Executes this tag.protected void
processBeforeBody()
Executes this tag before its body is processed.void
setIcon(Object icon)
Sets the icon for this menu.void
setMnemonic(String s)
Setter method for the mnemonic attribute.void
setMnemonicres(String s)
Setter method for the mnemonicres attribute.void
setResgrp(String s)
Setter method for the resgrp attribute.void
setText(String s)
Setter method for the text attribute.void
setTextres(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:
getContainer
in interfaceActionContainer
- Returns:
- the container object
-
setIcon
public void setIcon(Object icon)
Sets the icon for this menu.- Specified by:
setIcon
in 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 FormActionException
Adds a separator to this menu. This task is delegated to the current action manager.- Specified by:
addSeparator
in interfaceActionContainer
- Throws:
FormActionException
- if an error occurs
-
processBeforeBody
protected void processBeforeBody() throws org.apache.commons.jelly.JellyTagException, FormBuilderException
Executes this tag before its body is processed. This implementation creates the menu object and stores it in an internal member field.- Overrides:
processBeforeBody
in 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, FormBuilderException
Executes this tag. Performs further initialization of the menu.- Specified by:
process
in 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 currentActionBuilder
instance. 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
-
-