com.itmill.toolkit.ui
Interface Component

All Superinterfaces:
EventListener, Paintable, Sizeable, VariableOwner
All Known Subinterfaces:
Component.Focusable, ComponentContainer, Field, Layout
All Known Implementing Classes:
AbstractComponent, AbstractComponentContainer, AbstractField, AbstractLayout, AbstractOrderedLayout, AbstractSelect, Accordion, Button, CheckBox, ComboBox, CustomComponent, CustomLayout, DateField, Embedded, ExpandLayout, Form, FormLayout, GridLayout, HorizontalLayout, InlineDateField, Label, Link, ListSelect, LoginForm, MenuBar, NativeSelect, OptionGroup, OrderedLayout, Panel, PopupDateField, PopupView, ProgressIndicator, RichTextArea, Select, Slider, SplitPanel, Table, TabSheet, TextField, Tree, TwinColSelect, Upload, UriFragmentUtility, VerticalLayout, Window

public interface Component
extends Paintable, VariableOwner, Sizeable

The top-level component interface which must be implemented by all UI components that use IT Mill Toolkit.

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

Nested Class Summary
static class Component.ErrorEvent
          Class of all component originated ErrorEvents.
static interface Component.ErrorListener
          Listener interface for receiving Component.Errorss.
static class Component.Event
          Superclass of all component originated Events.
static interface Component.Focusable
          Interface implemented by components which can obtain input focus.
static interface Component.Listener
          Listener interface for receiving Component.Events.
 
Nested classes/interfaces inherited from interface com.itmill.toolkit.terminal.Paintable
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener
 
Field Summary
 
Fields inherited from interface com.itmill.toolkit.terminal.Sizeable
SIZE_UNDEFINED, UNIT_SYMBOLS, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
Method Summary
 void addListener(Component.Listener listener)
          Registers a new component event listener for this component.
 void addStyleName(String style)
          Adds style name to component.
 void attach()
           Notifies the component that it is connected to an application.
 void childRequestedRepaint(Collection alreadyNotified)
          The children must call this method when they need repainting.
 void detach()
          Notifies the component that it is detached from the application.
 Application getApplication()
          Gets the component's parent application.
 String getCaption()
          Gets the caption of the component.
 Resource getIcon()
          Gets the component's icon.
 Locale getLocale()
          Gets the locale of this component.
 Component getParent()
          Gets the visual parent of the component.
 String getStyleName()
          Gets style for component.
 Window getWindow()
          Gets the component's parent window.
 boolean isEnabled()
           Tests if the component is enabled or not.
 boolean isReadOnly()
          Tests if the component is in read-only mode.
 boolean isVisible()
          Tests the components visibility.
 void removeListener(Component.Listener listener)
          Removes a previously registered component event listener from this component.
 void removeStyleName(String style)
          Removes given style name from component.
 void setCaption(String caption)
          Sets the component's caption String.
 void setEnabled(boolean enabled)
          Enables or disables the component.
 void setIcon(Resource icon)
          Sets the component's icon.
 void setParent(Component parent)
          Sets the component's parent component.
 void setReadOnly(boolean readOnly)
          Sets the component's to read-only mode to the specified state.
 void setStyleName(String style)
          Sets and replaces all previous style names of the component.
 void setVisible(boolean visible)
          Sets this components visibility status.
 
Methods inherited from interface com.itmill.toolkit.terminal.Paintable
addListener, getDebugId, paint, removeListener, requestRepaint, requestRepaintRequests, setDebugId
 
Methods inherited from interface com.itmill.toolkit.terminal.VariableOwner
changeVariables, isImmediate
 
Methods inherited from interface com.itmill.toolkit.terminal.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeight, setHeightUnits, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidth, setWidthUnits
 

Method Detail

getStyleName

String getStyleName()
Gets style for component. Multiple styles are joined with spaces.

Returns:
the component's styleValue of property style.

setStyleName

void setStyleName(String style)
Sets and replaces all previous style names of the component. This method will trigger a RepaintRequestEvent.

Parameters:
style - the new style of the component.

addStyleName

void addStyleName(String style)
Adds style name to component. Handling additional style names is terminal specific, but in web browser environment they will most likely become CSS classes as given on server side. This method will trigger a RepaintRequestEvent.

Parameters:
style - the new style to be added to the component

removeStyleName

void removeStyleName(String style)
Removes given style name from component.

Parameters:
style - the style to be removed

isEnabled

boolean isEnabled()

Tests if the component is enabled or not. All the variable change events are blocked from disabled components. Also the component should visually indicate that it is disabled (by shading the component for example). All hidden (isVisible() == false) components must return false.

Note The component is considered disabled if it's parent is disabled.

Components should be enabled by default.

Specified by:
isEnabled in interface VariableOwner
Returns:
true if the component, and it's parent, is enabled false otherwise.
See Also:
VariableOwner.isEnabled()

setEnabled

void setEnabled(boolean enabled)
Enables or disables the component. Being enabled means that the component can be edited. This method will trigger a RepaintRequestEvent.

Note that after enabling a component, isEnabled() might still return false if the parent is disabled.

Also note that if the component contains child-components, it should recursively call requestRepaint() for all descendant components.

Parameters:
enabled - the boolean value specifying if the component should be enabled after the call or not

isVisible

boolean isVisible()
Tests the components visibility. Visibility defines if the component is drawn when updating UI. Default is true.

Note that to return true, this component and all its parents must be visible.

Also note that this method does not check if component is attached and shown to user. Component and all its parents may be visible, but not necessary attached to application. To test if component will be drawn, check its visibility and that getApplication() does not return null.

Returns:
true if the component is visible in the UI, false if not

setVisible

void setVisible(boolean visible)
Sets this components visibility status. Visibility defines if the component is shown in the UI or not.

Note that to be shown in UI this component and all its parents must be visible.

Parameters:
visible - the boolean value specifying if the component should be visible after the call or not.

getParent

Component getParent()
Gets the visual parent of the component. The components can be nested but one component can have only one parent.

Returns:
the parent component.

setParent

void setParent(Component parent)
Sets the component's parent component.

This method calls automatically attach() if the parent is attached to a window (or is itself a window}, and detach() if parent is set null, but the component was in the application.

This method is rarely called directly. Instead the ComponentContainer.addComponent(Component) method is used to add components to container, which call this method implicitly.

Parameters:
parent - the new parent component.

isReadOnly

boolean isReadOnly()
Tests if the component is in read-only mode.

Returns:
true if the component is in read-only mode, false if not.

setReadOnly

void setReadOnly(boolean readOnly)
Sets the component's to read-only mode to the specified state. This method will trigger a RepaintRequestEvent.

Parameters:
readOnly - the boolean value specifying if the component should be in read-only mode after the call or not.

getCaption

String getCaption()
Gets the caption of the component. Caption is the visible name of the component.

Returns:
the component's caption String.

setCaption

void setCaption(String caption)
Sets the component's caption String. Caption is the visible name of the component. This method will trigger a RepaintRequestEvent.

Parameters:
caption - the new caption String for the component.

getIcon

Resource getIcon()
Gets the component's icon. A component may have a graphical icon associated with it, this method retrieves it if it is defined.

Returns:
the component's icon or null if it not defined.

setIcon

void setIcon(Resource icon)
Sets the component's icon. This method will trigger a RepaintRequestEvent.

Parameters:
icon - the icon to be shown with the component's caption.

getWindow

Window getWindow()
Gets the component's parent window. If the component does not yet belong to a window null is returned.

Returns:
the parent window of the component or null.

getApplication

Application getApplication()
Gets the component's parent application. If the component does not yet belong to a application null is returned.

Returns:
the parent application of the component or null.

attach

void attach()

Notifies the component that it is connected to an application. This method is always called before the component is first time painted and is suitable to be extended. The getApplication and getWindow methods might return null before this method is called.

The caller of this method is setParent(Component) if the parent is already in the application. If the parent is not in the application, it must call the attach() for all its children when it will be added to the application.


detach

void detach()
Notifies the component that it is detached from the application.

The getApplication() and getWindow() methods might return null after this method is called.

The caller of this method is setParent(Component) if the parent is in the application. When the parent is detached from the application it is its response to call detach() for all the children and to detach itself from the terminal.


getLocale

Locale getLocale()
Gets the locale of this component.

Returns:
This component's locale. If this component does not have a locale, the locale of its parent is returned. Eventually locale of application is returned. If application does not have its own locale the locale is determined by Locale.getDefautlt. Returns null if the component does not have its own locale and has not yet been added to a containment hierarchy such that the locale can be determined from the containing parent.

childRequestedRepaint

void childRequestedRepaint(Collection alreadyNotified)
The children must call this method when they need repainting. The call must be made event in the case the children sent the repaint request themselves.

Parameters:
alreadyNotified - the collection of repaint request listeners that have been already notified by the child. This component should not renotify the listed listeners again. The container given as parameter must be modifiable as the component might modify it and pass it forwards. Null parameter is interpreted as empty collection.

addListener

void addListener(Component.Listener listener)
Registers a new component event listener for this component.

Parameters:
listener - the new Listener to be registered.

removeListener

void removeListener(Component.Listener listener)
Removes a previously registered component event listener from this component.

Parameters:
listener - the listener to be removed.


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