Class AbstractComponent

An abstract class that defines default implementation for the com.itmill.toolkit.ui.Component interface. Basic UI components that are not derived from an external component can inherit this class to easily qualify as a IT Mill Toolkit component. Most components in the toolkit do just that.

Synopsis

Since

3.0

Inheritance Path.  java.lang.Object-> com.itmill.toolkit.ui.AbstractComponent

AbstractComponent()

Constructs a new Component

addListener(Class, Object, Method)

Parameters

eventType

type of the listened event. Events of this type or its subclasses activate the listener.

object

the object instance who owns the activation method

method

the activation method

Exceptions

java.lang.IllegalArgumentException

unless method has exactly one match in object

Registers a new listener with the specified activation method to listen events generated by this component. If the activation method does not have any arguments the event object will not be passed to it when it's called.

For more information on the inheritable event mechanism see the com.itmill.toolkit.event package documentation .

addListener(Class, Object, String)

Parameters

eventType

type of the listened event. Events of this type or its subclasses activate the listener.

object

the object instance who owns the activation method

methodName

the name of the activation method

Exceptions

java.lang.IllegalArgumentException

unless method has exactly one match in object

Registers a new listener with the specified activation method to listen events generated by this component. If the activation method does not have any arguments the event object will not be passed to it when it's called.

This version of addListener gets the name of the activation method as a parameter. The actual method is reflected from object , and unless exactly one match is found, java.lang.IllegalArgumentException is thrown.

For more information on the inheritable event mechanism see the com.itmill.toolkit.event package documentation .

addListener(Component.Listener)

Parameters

listener

the new Listener to be registered

Description copied from interface: addListener

Registers a new component event listener for this component.

attach()

Description copied from interface: 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() functions might return null before this method is called.

The caller of this method is setParent(com.itmill.toolkit.ui.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.

childRequestedRepaint(Collection)

Parameters

alreadyNotified

A 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.

Description copied from interface: childRequestedRepaint

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.

detach()

Description copied from interface: 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(com.itmill.toolkit.ui.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.

getApplication()

Parameters

return

parent application of the component or null

Description copied from interface: getApplication

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

getCaption()

Parameters

return

component's caption String

Description copied from interface: getCaption

Gets the caption of the component. Caption is the visible name of the component.

getComponentError()

Parameters

return

component's error message

Link

Terminal.ErrorMessage#ErrorMessage(String, int)

Gets the component's error message.

getData()

Parameters

return

Application specific data set with setData function.

Since

3.1

Gets application specific data.

getDescription()

Parameters

return

component's description String

Gets the component's description. The description can be used to briefly describe the state of the component to the user. The description string may contain certain XML tags:

Tag

Description

Example

<b>

bold

bold text

<i>

italic

italic text

<u>

underlined

underlined text

<br>

linebreak

N/A

<ul>

<li>item1

<li>item1

</ul>

item list

  • item1

  • item2

These tags may be nested.

getErrorMessage()

Parameters

return

ErrorMessage containing the description of the error state of the component or null, if the component contains no errors. Extending classes should override this method if they support other error message types such as validation errors or buffering errors. The returned error message contains information about all the errors.

Get the error message for this component.

getIcon()

Parameters

return

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

Description copied from interface: getIcon

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

getLocale()

Parameters

return

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.getDefautl(). 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.

Description copied from interface: getLocale

Gets the locale of this component.

getParent()

Parameters

return

the parent component

Description copied from interface: getParent

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

getStyle()

Parameters

return

component's styleValue of property style.

Description copied from interface: getStyle

Gets the look-and-feel style of the component.

getTag()

Parameters

return

component's UIDL tag as String

Gets the UIDL tag corresponding to the component.

getWindow()

Parameters

return

parent window of the component or null

Description copied from interface: getWindow

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

isEnabled()

Parameters

return

true if the component is enabled, false if not

Description copied from interface: 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.

Components should be enabled by default.

isReadOnly()

Parameters

return

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

Description copied from interface: isReadOnly

Tests if the component is in read-only mode.

isVisible()

Parameters

return

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

Description copied from interface: isVisible

Tests if the component is visible or not. Visibility defines if the component is shown in the UI or not. Default is true .

paintContent(PaintTarget)

Parameters

target

target UIDL stream where the component should paint itself to

Exceptions

PaintException

if the operation failed

Paints any needed component-specific things to the given UIDL stream. The more general com.itmill.toolkit.ui.AbstractComponent method handles all general attributes common to all components, and it calls this method to paint any component-specific attributes to the UIDL stream.

removeListener(Class, Object)

Parameters

eventType

exact event type the object listens to

target

target object that has registered to listen to events of type eventType with one or more methods

Removes all registered listeners matching the given parameters. Since this method receives the event type and the listener object as parameters, it will unregister all object 's methods that are registered to listen to events of type eventType generated by this component.

For more information on the inheritable event mechanism see the com.itmill.toolkit.event package documentation .

removeListener(Class, Object, Method)

Parameters

eventType

exact event type the object listens to

target

target object that has registered to listen to events of type eventType with one or more methods

method

the method owned by target that's registered to listen to events of type eventType

Removes one registered listener method. The given method owned by the given object will no longer be called when the specified events are generated by this component.

For more information on the inheritable event mechanism see the com.itmill.toolkit.event package documentation .

removeListener(Class, Object, String)

Parameters

eventType

exact event type the object listens to

target

target object that has registered to listen to events of type eventType with one or more methods

methodName

name of the method owned by target that's registered to listen to events of type eventType

Removes one registered listener method. The given method owned by the given object will no longer be called when the specified events are generated by this component.

This version of removeListener gets the name of the activation method as a parameter. The actual method is reflected from target , and unless exactly one match is found, java.lang.IllegalArgumentException is thrown.

For more information on the inheritable event mechanism see the com.itmill.toolkit.event package documentation .

removeListener(Component.Listener)

Parameters

listener

the listener to be removed

Description copied from interface: removeListener

Removes a previously registered component event listener from this component.

setCaption(String)

Parameters

caption

new caption String for the component

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

setComponentError(ErrorMessage)

Parameters

errorMessage

new ErrorMessage of the component

Link

Component.ErrorMessage#ErrorMessage(String, int)

Sets the component's error message. The message may contain certain XML tags, for more information see

setData(Object)

Parameters

data

Application specific data.

Since

3.1

Sets application specific data object.

setDescription(String)

Parameters

description

new description string for the component

Sets the component's description. See getDescription() for more information on what the description is. This method will trigger a RepaintRequestEvent .

setEnabled(boolean)

Parameters

enabled

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

Description copied from interface: setEnabled

Enable or disable the component. Being enabled means that the component can be edited. This method will trigger a RepaintRequestEvent .

setIcon(Resource)

Parameters

icon

the icon to be shown with the component's caption

Sets the component's icon. This method will trigger a RepaintRequestEvent .

setImmediate(boolean)

Parameters

immediate

boolean value specifying if the component should be in the immediate mode after the call.

See Also
isImmediate()

Sets the component's immediate mode to the specified status. This method will trigger a RepaintRequestEvent .

setLocale(Locale)

Parameters

locale

The locale to become this component's locale.

Sets the locale of this component.

setParent(Component)

Parameters

parent

the new parent component

Description copied from interface: setParent

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 addComponent(com.itmill.toolkit.ui.Component) method is used to add components to container, which call this method implicitly.

setReadOnly(boolean)

Parameters

readOnly

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

Description copied from interface: setReadOnly

Sets the component's to read-only mode to the specified state. This method will trigger a RepaintRequestEvent .

setStyle(String)

Parameters

style

new style of the component

Description copied from interface: setStyle

Sets the look-and-feel style of the component. This method will trigger a RepaintRequestEvent . .

setVisible(boolean)

Parameters

visible

Boolean value specifying if the component should be visible after the call or not

Description copied from interface: setVisible

Sets the components visibility status. Visibility defines if the component is shown in the UI or not.