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
WindowData
interface used by theWindowManager
to 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 ESCAPE
key. If set to true, the window is then closed automatically. Otherwise, theESCAPE
key has no special meaning. The handling of theESCAPE
key is useful especially for dialogs where pressingESCAPE
usually 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 protected
WindowBaseTag()
Creates a new instance ofWindowBaseTag
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Object
createContainer(ComponentManager manager, boolean create, Collection<Object[]> components)
Creates the window container.protected abstract Window
createWindow(WindowManager manager, WindowBuilderData data)
Creates the window represented by the given data object using the current window manager.protected Object
fetchMenuBar(String name)
Tries to obtain the menu bar with the given name.ComponentBuilderData
getComponentBuilderData()
Returns the currentComponentBuilderData
object.Object
getController()
Returns the controller object of this window.int
getHeight()
Returns the height of the new window.Object
getIcon()
Returns the icon for this window.Object
getMenuBar()
Returns the menu bar of this window.String
getTitle()
Returns the window's title, no matter how it was defined.int
getWidth()
Returns the width of the new window.Window
getWindow()
Returns the window created by this tag.int
getXPos()
Returns the x coordinate of the new window.int
getYPos()
Returns the y coordinate of the new window.protected abstract Window
initWindow(WindowManager manager, WindowBuilderData data, Window wnd)
Initializes the window that was created by thecreateWindow()
method.protected void
insertComponent(String name, Object comp)
Inserts the newly created component to its parent container.boolean
isAutoClose()
Returns the auto-close flag.boolean
isCenter()
Returns a flag whether the new window should be centered on the screen.boolean
isClosable()
Returns the closable flag.boolean
isCloseOnEsc()
Returns the close on escape flag.boolean
isIconifiable()
Returns the iconifiable flag.boolean
isMaximizable()
Returns the maximizable flag.boolean
isResizable()
Returns the resizable flag.protected void
process()
Executes this tag.void
setAutoClose(boolean autoClose)
Sets the auto-close flag.void
setCenter(boolean f)
Setter method of the center attribute.void
setClosable(boolean f)
Setter method of the closable attribute.void
setCloseOnEsc(boolean closeOnEsc)
Sets the close on escape flag.void
setController(Object ctrl)
Sets the controller of this window.void
setHeight(int v)
Setter method of the height attribute.void
setIcon(Object icon)
Allows to set this window's icon.void
setIconifiable(boolean f)
Setter method of the iconifiable attribute.void
setMaximizable(boolean f)
Setter method of the maximizable attribute.void
setMenu(String s)
Setter method of the menu attribute.void
setResgrp(String s)
Setter method of the resgrp attribute.void
setResizable(boolean f)
Setter method of the resizable attribute.void
setTitle(String s)
Setter method of the title attribute.void
setTitleres(String s)
Setter method of the titleres attribute.void
setWidth(int v)
Setter method of the width attribute.void
setXpos(int v)
Setter method for the xpos attribute.void
setYpos(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:
getXPos
in 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:
getYPos
in 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:
getWidth
in 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:
getHeight
in 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:
isCenter
in 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:
getTitle
in 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:
getIcon
in 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:
setIcon
in interfaceIconSupport
- Parameters:
icon
- the icon of this window
-
isResizable
public boolean isResizable()
Returns the resizable flag.- Specified by:
isResizable
in 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:
isMaximizable
in 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:
isIconifiable
in 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:
isClosable
in 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:
getMenuBar
in 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:
getController
in 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:
isAutoClose
in 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:
isCloseOnEsc
in interfaceWindowData
- Returns:
- a flag whether the window should be closed if
ESCAPE
is pressed
-
setCloseOnEsc
public void setCloseOnEsc(boolean closeOnEsc)
Sets the close on escape flag. This flag controls the window's reaction on pressing theESCAPE
key.- Parameters:
closeOnEsc
- the close on escape flag
-
getComponentBuilderData
public ComponentBuilderData getComponentBuilderData()
Returns the currentComponentBuilderData
object. This object is easily available to all tag handler classes.- Specified by:
getComponentBuilderData
in interfaceWindowData
- Returns:
- the current
ComponentBuilderData
object
-
process
protected void process() throws org.apache.commons.jelly.JellyTagException, FormBuilderException
Executes this tag. Calls
for the second time with the boolean parameter#createComponent(ComponentManager)
create
set 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:
process
in 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:
createContainer
in 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:
insertComponent
in 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
-
-