Class WindowBaseTag

  • 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 the WindowManager 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 and initWindow() 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, the ESCAPE key has no special meaning. The handling of the ESCAPE key is useful especially for dialogs where pressing ESCAPE 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
    • Constructor Detail

      • WindowBaseTag

        protected WindowBaseTag()
        Creates a new instance of WindowBaseTag.
    • 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 interface WindowData
        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 interface WindowData
        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 interface WindowData
        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 interface WindowData
        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 interface WindowData
        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 interface WindowData
        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 interface WindowData
        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 interface IconSupport
        Parameters:
        icon - the icon of this window
      • isResizable

        public boolean isResizable()
        Returns the resizable flag.
        Specified by:
        isResizable in interface WindowData
        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 interface WindowData
        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 interface WindowData
        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 interface WindowData
        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 interface WindowData
        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 interface WindowData
        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 interface WindowData
        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 interface WindowData
        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 the ESCAPE key.
        Parameters:
        closeOnEsc - the close on escape flag
      • getComponentBuilderData

        public ComponentBuilderData getComponentBuilderData()
        Returns the current ComponentBuilderData object. This object is easily available to all tag handler classes.
        Specified by:
        getComponentBuilderData in interface WindowData
        Returns:
        the current ComponentBuilderData object
      • process

        protected void process()
                        throws org.apache.commons.jelly.JellyTagException,
                               FormBuilderException
        Executes this tag. Calls #createComponent(ComponentManager) for the second time with the boolean parameter 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 class SimpleComponentTag
        Throws:
        org.apache.commons.jelly.JellyTagException - if a script related error occurs
        FormBuilderException - 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 abstract createWindow() and initWindow() methods and takes care for storing the new window in the builder data instance.
        Specified by:
        createContainer in class ContainerTag
        Parameters:
        manager - the component manager (ignored)
        create - the create flag
        components - a collection with the container's children
        Returns:
        the new container object (the window's root container)
        Throws:
        FormBuilderException - if an error occurs
        org.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 class ComponentBaseTag
        Parameters:
        name - the name of this component
        comp - 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 manager
        data - 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 the createWindow() 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 manager
        data - the window builder data
        wnd - the window to be initialized
        Returns:
        the fully initialized window
        Throws:
        WindowBuilderException - if an error occurs