Class WindowBaseTag
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- All Implemented Interfaces:
Composite,ConditionalTag,IconSupport,WindowData,org.apache.commons.jelly.Tag
- Direct Known Subclasses:
DialogTag,FrameTag,InternalFrameTag
public abstract class WindowBaseTag extends ContainerTag implements WindowData, IconSupport
A base class for all tag handler classes that create windows.
This class provides common functionality for all tag handler classes that allow the definition of different windows. Especially it implements the
WindowDatainterface used by theWindowManagerto access the windows' properties and defines corresponding setter methods. The handling of the newly created window is also already implemented.Concrete sub classes must implement two methods:
createWindow()for creating the window andinitWindow()for its initialization. Both methods get passed all necessary information.The following table lists all attributes supported by this tag handler base class. They are available in all derived tag classes, too:
Attribute Description Optional xpos Defines the x coordinate of the new window. yes ypos Defines the y coordinate of the new window. yes width Defines the window's width. If no width is provided, the window will be packed, i.e. sized to its minimum width and height. yes height Defines the window's height. yes center If this boolean attribute is set to true, the window will be centered on the screen. The coordinates will be ignored then. yes title Allows to specify the window's title directly. yes titleres With this attribute a resource ID for the window's title can be specified. yes resgrp Allows to specify a resource group for the title. If this is not defined, the builder's default resource group will be used. yes closable A flag indicating whether the new window can be closed. Default is true. yes iconifiable A flag indicating whether the new window can be iconified. Default is true. yes maximizable A flag indicating whether the new window can be maximized. Default is true. yes resizable A flag indicating whether the new window can be resized. Default is true. yes autoClose This boolean attribute controls the window's behavior when the user clicks on the close icon in the window's title bar. If set to true (which is the default), the window is then closed automatically. If set to false, nothing happens. In this case the developer is responsible for registering an event listener which reacts on the window closing event and invokes the close operation manually. yes closeOnEsc This boolean attribute controls the window's behavior when the user presses the ESCAPEkey. If set to true, the window is then closed automatically. Otherwise, theESCAPEkey has no special meaning. The handling of theESCAPEkey is useful especially for dialogs where pressingESCAPEusually means that the user wants to cancel editing. The default value of this attribute depends on the window type: it is true for dialog windows and false otherwise.yes menu With this attribute the window's menu bar can be specified. The attribute's value must match the name of a menu bar that has previously been definied using a <menubar>tag.yes - Version:
- $Id: WindowBaseTag.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Field Summary
-
Fields inherited from class org.apache.commons.jelly.TagSupport
body, context, hasTrimmed, parent, shouldTrim
-
Fields inherited from interface net.sf.jguiraffe.gui.builder.window.WindowData
UNDEFINED
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedWindowBaseTag()Creates a new instance ofWindowBaseTag.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected ObjectcreateContainer(ComponentManager manager, boolean create, Collection<Object[]> components)Creates the window container.protected abstract WindowcreateWindow(WindowManager manager, WindowBuilderData data)Creates the window represented by the given data object using the current window manager.protected ObjectfetchMenuBar(String name)Tries to obtain the menu bar with the given name.ComponentBuilderDatagetComponentBuilderData()Returns the currentComponentBuilderDataobject.ObjectgetController()Returns the controller object of this window.intgetHeight()Returns the height of the new window.ObjectgetIcon()Returns the icon for this window.ObjectgetMenuBar()Returns the menu bar of this window.StringgetTitle()Returns the window's title, no matter how it was defined.intgetWidth()Returns the width of the new window.WindowgetWindow()Returns the window created by this tag.intgetXPos()Returns the x coordinate of the new window.intgetYPos()Returns the y coordinate of the new window.protected abstract WindowinitWindow(WindowManager manager, WindowBuilderData data, Window wnd)Initializes the window that was created by thecreateWindow()method.protected voidinsertComponent(String name, Object comp)Inserts the newly created component to its parent container.booleanisAutoClose()Returns the auto-close flag.booleanisCenter()Returns a flag whether the new window should be centered on the screen.booleanisClosable()Returns the closable flag.booleanisCloseOnEsc()Returns the close on escape flag.booleanisIconifiable()Returns the iconifiable flag.booleanisMaximizable()Returns the maximizable flag.booleanisResizable()Returns the resizable flag.protected voidprocess()Executes this tag.voidsetAutoClose(boolean autoClose)Sets the auto-close flag.voidsetCenter(boolean f)Setter method of the center attribute.voidsetClosable(boolean f)Setter method of the closable attribute.voidsetCloseOnEsc(boolean closeOnEsc)Sets the close on escape flag.voidsetController(Object ctrl)Sets the controller of this window.voidsetHeight(int v)Setter method of the height attribute.voidsetIcon(Object icon)Allows to set this window's icon.voidsetIconifiable(boolean f)Setter method of the iconifiable attribute.voidsetMaximizable(boolean f)Setter method of the maximizable attribute.voidsetMenu(String s)Setter method of the menu attribute.voidsetResgrp(String s)Setter method of the resgrp attribute.voidsetResizable(boolean f)Setter method of the resizable attribute.voidsetTitle(String s)Setter method of the title attribute.voidsetTitleres(String s)Setter method of the titleres attribute.voidsetWidth(int v)Setter method of the width attribute.voidsetXpos(int v)Setter method for the xpos attribute.voidsetYpos(int v)Setter method for the ypos attribute.-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.ContainerTag
addComponent, addComponents, createComponent, getComposite, getContainer, getLayout, processBeforeBody, setComposite, setLayout
-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.SimpleComponentTag
getComponent
-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.ComponentBaseTag
getBackColor, getBackgroundColor, getConstraints, getFont, getFontRef, getForeColor, getForegroundColor, getName, getToolTipData, setBackColor, setConstraints, setFont, setFontRef, setForeColor, setName, setTooltip, setTooltipres, setTooltipresgrp
-
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
-
getWindow
public Window getWindow()
Returns the window created by this tag.- Returns:
- the window
-
getXPos
public int getXPos()
Returns the x coordinate of the new window.- Specified by:
getXPosin interfaceWindowData- Returns:
- the window's x coordinate
-
setXpos
public void setXpos(int v)
Setter method for the xpos attribute.- Parameters:
v- the attribute value
-
getYPos
public int getYPos()
Returns the y coordinate of the new window.- Specified by:
getYPosin interfaceWindowData- Returns:
- the window's y coordinate
-
setYpos
public void setYpos(int v)
Setter method for the ypos attribute.- Parameters:
v- the attribute's value
-
getWidth
public int getWidth()
Returns the width of the new window.- Specified by:
getWidthin interfaceWindowData- Returns:
- the window's width
-
setWidth
public void setWidth(int v)
Setter method of the width attribute.- Parameters:
v- the attribute's value
-
getHeight
public int getHeight()
Returns the height of the new window.- Specified by:
getHeightin interfaceWindowData- Returns:
- the window's height
-
setHeight
public void setHeight(int v)
Setter method of the height attribute.- Parameters:
v- the attribute's value
-
isCenter
public boolean isCenter()
Returns a flag whether the new window should be centered on the screen.- Specified by:
isCenterin interfaceWindowData- Returns:
- the center flag
-
setCenter
public void setCenter(boolean f)
Setter method of the center attribute.- Parameters:
f- the attribute's value
-
getTitle
public String getTitle()
Returns the window's title, no matter how it was defined.- Specified by:
getTitlein interfaceWindowData- Returns:
- the window's title
-
setTitle
public void setTitle(String s)
Setter method of the title attribute.- Parameters:
s- the attribute's value
-
setTitleres
public void setTitleres(String s)
Setter method of the titleres attribute.- Parameters:
s- the attribute's value
-
setResgrp
public void setResgrp(String s)
Setter method of the resgrp attribute.- Parameters:
s- the attribute's value
-
getIcon
public Object getIcon()
Returns the icon for this window.- Specified by:
getIconin interfaceWindowData- Returns:
- the window's icon
-
setIcon
public void setIcon(Object icon)
Allows to set this window's icon. This method can be invoked by<icon>tags in the body of this tag.- Specified by:
setIconin interfaceIconSupport- Parameters:
icon- the icon of this window
-
isResizable
public boolean isResizable()
Returns the resizable flag.- Specified by:
isResizablein interfaceWindowData- Returns:
- the resizable flag
-
setResizable
public void setResizable(boolean f)
Setter method of the resizable attribute.- Parameters:
f- the attribute's value
-
isMaximizable
public boolean isMaximizable()
Returns the maximizable flag.- Specified by:
isMaximizablein interfaceWindowData- Returns:
- the maximizable flag
-
setMaximizable
public void setMaximizable(boolean f)
Setter method of the maximizable attribute.- Parameters:
f- the attribute's value
-
isIconifiable
public boolean isIconifiable()
Returns the iconifiable flag.- Specified by:
isIconifiablein interfaceWindowData- Returns:
- the iconifiable flag
-
setIconifiable
public void setIconifiable(boolean f)
Setter method of the iconifiable attribute.- Parameters:
f- the attribute's value
-
isClosable
public boolean isClosable()
Returns the closable flag.- Specified by:
isClosablein interfaceWindowData- Returns:
- the closable flag
-
setClosable
public void setClosable(boolean f)
Setter method of the closable attribute.- Parameters:
f- the attribute's value
-
getMenuBar
public Object getMenuBar()
Returns the menu bar of this window.- Specified by:
getMenuBarin interfaceWindowData- Returns:
- this window's menu bar
-
setMenu
public void setMenu(String s)
Setter method of the menu attribute.- Parameters:
s- the attribute's value
-
getController
public Object getController()
Returns the controller object of this window.- Specified by:
getControllerin interfaceWindowData- Returns:
- the window's controller
-
setController
public void setController(Object ctrl)
Sets the controller of this window. This method can be called by tags in the body of this tag.- Parameters:
ctrl- the controller
-
isAutoClose
public boolean isAutoClose()
Returns the auto-close flag.- Specified by:
isAutoClosein interfaceWindowData- Returns:
- the auto-close flag
-
setAutoClose
public void setAutoClose(boolean autoClose)
Sets the auto-close flag.- Parameters:
autoClose- the auto-close flag
-
isCloseOnEsc
public boolean isCloseOnEsc()
Returns the close on escape flag.- Specified by:
isCloseOnEscin interfaceWindowData- Returns:
- a flag whether the window should be closed if
ESCAPEis pressed
-
setCloseOnEsc
public void setCloseOnEsc(boolean closeOnEsc)
Sets the close on escape flag. This flag controls the window's reaction on pressing theESCAPEkey.- Parameters:
closeOnEsc- the close on escape flag
-
getComponentBuilderData
public ComponentBuilderData getComponentBuilderData()
Returns the currentComponentBuilderDataobject. This object is easily available to all tag handler classes.- Specified by:
getComponentBuilderDatain interfaceWindowData- Returns:
- the current
ComponentBuilderDataobject
-
process
protected void process() throws org.apache.commons.jelly.JellyTagException, FormBuilderExceptionExecutes this tag. Callsfor the second time with the boolean parameter#createComponent(ComponentManager)createset to false . The new component is then added to the nesting container element. This implementation ensures that the name of the default button is reset after processing of the tag's body.- Overrides:
processin classSimpleComponentTag- Throws:
org.apache.commons.jelly.JellyTagException- if a script related error occursFormBuilderException- if an error occurs
-
createContainer
protected Object createContainer(ComponentManager manager, boolean create, Collection<Object[]> components) throws FormBuilderException, org.apache.commons.jelly.JellyTagException
Creates the window container. This implementation performs all necessary steps for creating and initializing a window. It mainly calls the abstractcreateWindow()andinitWindow()methods and takes care for storing the new window in the builder data instance.- Specified by:
createContainerin classContainerTag- Parameters:
manager- the component manager (ignored)create- the create flagcomponents- a collection with the container's children- Returns:
- the new container object (the window's root container)
- Throws:
FormBuilderException- if an error occursorg.apache.commons.jelly.JellyTagException- if the tag is incorrectly used
-
insertComponent
protected void insertComponent(String name, Object comp)
Inserts the newly created component to its parent container. This implementation is left empty. Windows must not be added to any root container. Probably there is no root container at all when a window is created.- Overrides:
insertComponentin classComponentBaseTag- Parameters:
name- the name of this componentcomp- the new component
-
fetchMenuBar
protected Object fetchMenuBar(String name) throws WindowBuilderException
Tries to obtain the menu bar with the given name. This implementation searches the Jelly context for a variable with this name.- Parameters:
name- the name of the menu bar- Returns:
- the menu bar as an object
- Throws:
WindowBuilderException- if the window cannot be obtained
-
createWindow
protected abstract Window createWindow(WindowManager manager, WindowBuilderData data) throws WindowBuilderException
Creates the window represented by the given data object using the current window manager. This method must be defined by concrete sub classes to call the correct method of the window manager, according to the window's type.- Parameters:
manager- a reference to the current window managerdata- the window builder data- Returns:
- the newly created window
- Throws:
WindowBuilderException- if the window cannot be created
-
initWindow
protected abstract Window initWindow(WindowManager manager, WindowBuilderData data, Window wnd) throws WindowBuilderException
Initializes the window that was created by thecreateWindow()method. This method is invoked after all properties of the window have been set (i.e. after the tag's body have been executed). Thus, a complete initialization can now be performed.- Parameters:
manager- the current window managerdata- the window builder datawnd- the window to be initialized- Returns:
- the fully initialized window
- Throws:
WindowBuilderException- if an error occurs
-
-