Custom component provides simple implementation of Component interface for creation of new UI components by composition of existing components.
The component is used by inheriting the CustomComponent class and setting composite root inside the Custom component. The composite root itself can contain more components, but their interfaces are hidden from the users.
Construct new custom component.
The component is implemented by wrapping the methods of the composition root component given as parameter. The composition root must be set before the component can be used.
Parameters
compositionRoot
The root of the composition component tree.
Construct new custom component.
The component is implemented by wrapping the methods of the composition root component given as parameter. The composition root must not be null and can not be changed after the composition.
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.
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.
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.
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.
Parameters
parent application of the component or
null
Gets the component's parent application. If the component does not
yet belong to a application
null
is returned.
The caption of the custom component is by default the the caption of the root component, or null if the root is not set
Parameters
String
Gets the component type. The component type is textual type of the component. This is included in the UIDL as component tag attribute. If the component type is null (default), the component tag is not included in the UIDL at all. Returns the componentType.
The icon of the custom component is by default the the icon of the root component, or null if the root is not set
The icon of the custom component is by default the the locale of the parent or null if the parent is not set.
Parameters
the parent component
Gets the visual parent of the component. The components can be nested but one component can have only one parent.
Custom component does not implement custom styles by default and this function returns null.
Parameters
parent window of the component or
null
Gets the component's parent window. If the component does not yet
belong to a window
null
is returned.
Custom component is by default in the non-immediate mode. The immediateness of the custom component is defined by the components it is composed of.
Parameters
true
if the component is visible in the UI,
false
if not
Tests if the component is visible or not. Visibility defines if the
component is shown in the UI or not. Default is
true
.
Custom component does not implement any component events by default
Parameters
componentType
The componentType to set
Sets the component type. The component type is textual type of the component. This is included in the UIDL as component tag attribute. If the component type is null (default), the component tag is not included in the UIDL at all.
Parameters
parent
the new parent component
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.
Parameters
visible
Boolean value specifying if the component should be visible after the call or not
Sets the components visibility status. Visibility defines if the component is shown in the UI or not.