com.itmill.toolkit.ui
Class Window

java.lang.Object
  extended by com.itmill.toolkit.terminal.Identifiable
      extended by com.itmill.toolkit.ui.AbstractComponent
          extended by com.itmill.toolkit.ui.AbstractComponentContainer
              extended by com.itmill.toolkit.ui.Panel
                  extended by com.itmill.toolkit.ui.Window
All Implemented Interfaces:
MethodEventSource, Paintable, ParameterHandler, Scrollable, Sizeable, URIHandler, VariableOwner, Component, ComponentContainer, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachListener, EventListener
Direct Known Subclasses:
DebugWindow, FrameWindow

public class Window
extends Panel
implements URIHandler, ParameterHandler

Application window component.

Since:
3.0
Version:
4.1.4
Author:
IT Mill Ltd.

Nested Class Summary
 class Window.CloseEvent
           
static interface Window.CloseListener
           
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.terminal.URIHandler
URIHandler.ErrorEvent
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.terminal.ParameterHandler
ParameterHandler.ErrorEvent
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.ComponentContainer
ComponentContainer.ComponentAttachEvent, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachEvent, ComponentContainer.ComponentDetachListener
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.terminal.Paintable
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener
 
Field Summary
static int BORDER_DEFAULT
          Window with default borders.
static int BORDER_MINIMAL
          Window with only minimal border.
static int BORDER_NONE
          Window with no border.
 
Fields inherited from interface com.itmill.toolkit.terminal.Sizeable
UNIT_SYMBOLS, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS, UNITS_ROWS
 
Constructor Summary
Window()
          Creates a new empty unnamed window with default layout.
Window(String caption)
          Creates a new empty window with default layout.
Window(String caption, Layout layout)
          Creates a new window.
 
Method Summary
 void addListener(Window.CloseListener listener)
          Adds the listener.
 void addParameterHandler(ParameterHandler handler)
          Adds the new parameter handler to this window.
 void addURIHandler(URIHandler handler)
          Adds the new URI handler to this window.
 void changeVariables(Object source, Map variables)
          Called when one or more variables handled by the implementing class are changed.
protected  void fireClose()
           
 Application getApplication()
          Gets the application instance of the component.
 int getBorder()
          Returns the border.
static Component.Focusable getFocusableById(long focusableId)
          Maps the focusable id back to focusable component.
 Component.Focusable getFocusedComponent()
          Gets the currently focused component in this window.
 String getName()
          Gets the unique name of the window that indentifies it on the terminal.
static long getNewFocusableId(Component.Focusable focusable)
          Gets an id for focusable component.
 Component getParent()
          Getter for property parent.
 int getPositionX()
          Gets the distance of Window left border in pixels from left border of the containing (main window).
 int getPositionY()
          Gets the distance of Window top border in pixels from top border of the containing (main window).
 String getTag()
          Gets the component UIDL tag.
 Terminal getTerminal()
          Gets the terminal type.
 String getTheme()
          Gets the theme for this window.
 URL getURL()
          Returns the full url of the window, this returns window specific url even for the main window.
 Window getWindow()
          Gets the window of the component.
 void handleParameters(Map parameters)
           Handles the given parameters.
 DownloadStream handleURI(URL context, String relativeUri)
          Handles uri recursively.
 void open(Resource resource)
          Opens the given resource in this window.
 void open(Resource resource, String windowName)
          Opens the given resource in named terminal window.
 void open(Resource resource, String windowName, int width, int height, int border)
          Opens the given resource in named terminal window with given size and border properties.
 void paintContent(PaintTarget target)
          Paints the content of this component.
static void removeFocusableId(long focusableId)
          Releases the focusable component id when not used anymore.
 void removeListener(Window.CloseListener listener)
          Removes the listener.
 void removeParameterHandler(ParameterHandler handler)
          Removes the given URI handler from this window.
 void removeURIHandler(URIHandler handler)
          Removes the given URI handler from this window.
 void setApplication(Application application)
          Sets the application this window is connected to.
 void setBorder(int border)
          Sets the border.
 void setFocusedComponent(Component.Focusable focusable)
          Sets the currently focused component in this window.
 void setHeightUnits(int units)
          Window only supports pixels as unit.
 void setName(String name)
          Sets the name.
 void setParent(Component parent)
          Setter for property parent.
 void setPositionX(int positionX)
          Sets the distance of Window left border in pixels from left border of the containing (main window).
 void setPositionY(int positionY)
          Sets the distance of Window top border in pixels from top border of the containing (main window).
 void setTerminal(Terminal type)
          Sets the terminal type.
 void setTheme(String theme)
          Sets the theme for this window.
 void setWidthUnits(int units)
          Window only supports pixels as unit.
 
Methods inherited from class com.itmill.toolkit.ui.Panel
addComponent, attach, componentAttachedToContainer, componentDetachedFromContainer, detach, getComponentIterator, getHeight, getHeightUnits, getLayout, getScrollOffsetX, getScrollOffsetY, getWidth, getWidthUnits, isScrollable, removeAllComponents, removeComponent, replaceComponent, setHeight, setLayout, setScrollable, setScrollOffsetX, setScrollOffsetY, setWidth
 
Methods inherited from class com.itmill.toolkit.ui.AbstractComponentContainer
addListener, addListener, fireComponentAttachEvent, fireComponentDetachEvent, moveComponentsFrom, removeListener, removeListener
 
Methods inherited from class com.itmill.toolkit.ui.AbstractComponent
addListener, addListener, addListener, addListener, childRequestedRepaint, dependsOn, fireComponentErrorEvent, fireComponentEvent, fireEvent, getCaption, getComponentError, getData, getDescription, getDirectDependencies, getErrorMessage, getIcon, getLocale, getStyle, isEnabled, isImmediate, isReadOnly, isVisible, paint, removeDirectDependency, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDescription, setEnabled, setIcon, setImmediate, setLocale, setReadOnly, setStyle, setVisible
 
Methods inherited from class com.itmill.toolkit.terminal.Identifiable
getDebugId, getUIID, setDebugId, setUIID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.itmill.toolkit.ui.Component
addListener, childRequestedRepaint, getCaption, getIcon, getLocale, getStyle, isEnabled, isReadOnly, isVisible, removeListener, setEnabled, setReadOnly, setStyle, setVisible
 
Methods inherited from interface com.itmill.toolkit.terminal.Paintable
addListener, paint, removeListener, requestRepaint, requestRepaintRequests
 
Methods inherited from interface com.itmill.toolkit.terminal.VariableOwner
dependsOn, getDirectDependencies, isImmediate, removeDirectDependency
 

Field Detail

BORDER_NONE

public static final int BORDER_NONE
Window with no border.

See Also:
Constant Field Values

BORDER_MINIMAL

public static final int BORDER_MINIMAL
Window with only minimal border.

See Also:
Constant Field Values

BORDER_DEFAULT

public static final int BORDER_DEFAULT
Window with default borders.

See Also:
Constant Field Values
Constructor Detail

Window

public Window()
Creates a new empty unnamed window with default layout.

To show the window in application, it must be added to application with Application.addWindow method.

The windows are scrollable by default.

Parameters:
caption - the Title of the window.

Window

public Window(String caption)
Creates a new empty window with default layout.

To show the window in application, it must be added to application with Application.addWindow method.

The windows are scrollable by default.

Parameters:
caption - the Title of the window.

Window

public Window(String caption,
              Layout layout)
Creates a new window.

To show the window in application, it must be added to application with Application.addWindow method.

The windows are scrollable by default.

Parameters:
caption - the Title of the window.
layout - the Layout of the window.
Method Detail

getTerminal

public Terminal getTerminal()
Gets the terminal type.

Returns:
the Value of property terminal.

getWindow

public final Window getWindow()
Gets the window of the component. Returns the window where this component belongs to. If the component does not yet belong to a window the returns null.

Specified by:
getWindow in interface Component
Overrides:
getWindow in class AbstractComponent
Returns:
the parent window of the component.

getApplication

public final Application getApplication()
Gets the application instance of the component. Returns the application where this component belongs to. If the component does not yet belong to a application the returns null.

Specified by:
getApplication in interface Component
Overrides:
getApplication in class AbstractComponent
Returns:
the parent application of the component.

getParent

public final Component getParent()
Getter for property parent. Parent is the visual parent of a component. Each component can belong to only one ComponentContainer at time.

Specified by:
getParent in interface Component
Overrides:
getParent in class AbstractComponent
Returns:
the Value of property parent.

setParent

public void setParent(Component parent)
Setter for property parent. Parent is the visual parent of a component. This is mostly called by containers add method. Setting parent is not allowed for the window, and thus this call should newer be called.

Specified by:
setParent in interface Component
Overrides:
setParent in class AbstractComponent
Parameters:
parent - the New value of property parent.

getTag

public String getTag()
Gets the component UIDL tag.

Overrides:
getTag in class Panel
Returns:
the Component UIDL tag as string.

addURIHandler

public void addURIHandler(URIHandler handler)
Adds the new URI handler to this window.

Parameters:
handler - the URI handler to add.

removeURIHandler

public void removeURIHandler(URIHandler handler)
Removes the given URI handler from this window.

Parameters:
handler - the URI handler to remove.

handleURI

public DownloadStream handleURI(URL context,
                                String relativeUri)
Handles uri recursively.

Specified by:
handleURI in interface URIHandler
Parameters:
context -
relativeUri -
Returns:
the download stream object.

addParameterHandler

public void addParameterHandler(ParameterHandler handler)
Adds the new parameter handler to this window.

Parameters:
handler - the parameter handler to add.

removeParameterHandler

public void removeParameterHandler(ParameterHandler handler)
Removes the given URI handler from this window.

Parameters:
handler - the parameter handler to remove.

handleParameters

public void handleParameters(Map parameters)
Description copied from interface: ParameterHandler

Handles the given parameters. The parameters are given as inmodifieable name to value map. All parameters names are of type: String. All the parameter values are arrays of strings.

Specified by:
handleParameters in interface ParameterHandler
Parameters:
parameters - the Inmodifiable name to value[] mapping.

getTheme

public String getTheme()
Gets the theme for this window.

Returns:
the Name of the theme used in window. If the theme for this individual window is not explicitly set, the application theme is used instead. If application is not assigned the terminal.getDefaultTheme is used. If terminal is not set, null is returned

setTheme

public void setTheme(String theme)
Sets the theme for this window.

Parameters:
theme - the New theme for this window. Null implies the default theme.

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Paints the content of this component.

Overrides:
paintContent in class Panel
Parameters:
event - the Paint Event.
Throws:
PaintException - if the paint operation failed.

open

public void open(Resource resource)
Opens the given resource in this window.

Parameters:
resource -

open

public void open(Resource resource,
                 String windowName)
Opens the given resource in named terminal window. Empty or null window name results the resource to be opened in this window.

Parameters:
resource - the resource.
windowName - the name of the window.

open

public void open(Resource resource,
                 String windowName,
                 int width,
                 int height,
                 int border)
Opens the given resource in named terminal window with given size and border properties. Empty or null window name results the resource to be opened in this window.

Parameters:
resource -
windowName -
width -
height -
border -

getURL

public URL getURL()
Returns the full url of the window, this returns window specific url even for the main window.

Returns:
the URL of the window.

getName

public String getName()
Gets the unique name of the window that indentifies it on the terminal.

Returns:
the Name of the Window.

getBorder

public int getBorder()
Returns the border.

Returns:
the border.

setBorder

public void setBorder(int border)
Sets the border.

Parameters:
border - the border to set.

setApplication

public void setApplication(Application application)
Sets the application this window is connected to.

This method should not be invoked directly. Instead the Application.addWindow(Window) method should be used to add the window to an application and Application.removeWindow(Window) method for removing the window from the applicion. These methods call this method implicitly.

The method invokes Component.attach() and Component.detach() methods when necessary.

Parameters:
application - the application to set.

setName

public void setName(String name)
Sets the name.

The name of the window must be unique inside the application. Also the name may only contain the following characters: a-z, A-Z and 0-9.

If the name is null, the the window is given name automatically when it is added to an application.

Parameters:
name - the name to set.

setTerminal

public void setTerminal(Terminal type)
Sets the terminal type. The terminal type is set by the the terminal adapter and may change from time to time.

Parameters:
type - the terminal type to set.

setHeightUnits

public void setHeightUnits(int units)
Window only supports pixels as unit.

Specified by:
setHeightUnits in interface Sizeable
Overrides:
setHeightUnits in class Panel
Parameters:
units - the units used in height property.
See Also:
Sizeable.getHeightUnits()

setWidthUnits

public void setWidthUnits(int units)
Window only supports pixels as unit.

Specified by:
setWidthUnits in interface Sizeable
Overrides:
setWidthUnits in class Panel
Parameters:
units - the units used in width property.
See Also:
Sizeable.getWidthUnits()

changeVariables

public void changeVariables(Object source,
                            Map variables)
Called when one or more variables handled by the implementing class are changed.

Specified by:
changeVariables in interface VariableOwner
Overrides:
changeVariables in class Panel
Parameters:
source - the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.
variables - the Mapping from variable names to new variable values.
See Also:
VariableOwner.changeVariables(java.lang.Object, java.util.Map)

getFocusedComponent

public Component.Focusable getFocusedComponent()
Gets the currently focused component in this window.

Returns:
the Focused component or null if none is focused.

setFocusedComponent

public void setFocusedComponent(Component.Focusable focusable)
Sets the currently focused component in this window.

Parameters:
focusable - the Focused component or null if none is focused.

getNewFocusableId

public static long getNewFocusableId(Component.Focusable focusable)
Gets an id for focusable component.

Parameters:
focusable - the focused component.

getFocusableById

public static Component.Focusable getFocusableById(long focusableId)
Maps the focusable id back to focusable component.

Parameters:
focusableId - the Focused Id.
Returns:
the focusable Id.

removeFocusableId

public static void removeFocusableId(long focusableId)
Releases the focusable component id when not used anymore.

Parameters:
focusableId - the focusable Id to remove.

getPositionX

public int getPositionX()
Gets the distance of Window left border in pixels from left border of the containing (main window).

Returns:
the Distance of Window left border in pixels from left border of the containing (main window). or -1 if unspecified.
Since:
4.0.0

setPositionX

public void setPositionX(int positionX)
Sets the distance of Window left border in pixels from left border of the containing (main window).

Parameters:
positionX - the Distance of Window left border in pixels from left border of the containing (main window). or -1 if unspecified.
Since:
4.0.0

getPositionY

public int getPositionY()
Gets the distance of Window top border in pixels from top border of the containing (main window).

Returns:
Distance of Window top border in pixels from top border of the containing (main window). or -1 if unspecified .
Since:
4.0.0

setPositionY

public void setPositionY(int positionY)
Sets the distance of Window top border in pixels from top border of the containing (main window).

Parameters:
positionY - the Distance of Window top border in pixels from top border of the containing (main window). or -1 if unspecified
Since:
4.0.0

addListener

public void addListener(Window.CloseListener listener)
Adds the listener.

Parameters:
listener - the listener to add.

removeListener

public void removeListener(Window.CloseListener listener)
Removes the listener.

Parameters:
listener - the listener to remove.

fireClose

protected void fireClose()


Copyright © 2000-2008 IT Mill Ltd. All Rights Reserved.