|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.itmill.toolkit.ui.AbstractComponent
public abstract class AbstractComponent
An abstract class that defines default implementation for the
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.
| Nested Class Summary | |
|---|---|
static interface |
AbstractComponent.ComponentErrorEvent
|
static interface |
AbstractComponent.ComponentErrorHandler
|
| 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 |
|---|
| 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, UNITS_ROWS |
| Constructor Summary | |
|---|---|
AbstractComponent()
Constructs a new Component. |
|
| Method Summary | |
|---|---|
void |
addListener(Class eventType,
Object object,
Method method)
Registers a new listener with the specified activation method to listen events generated by this component. |
void |
addListener(Class eventType,
Object object,
String methodName)
Convenience method for registering a new listener with the specified activation method to listen events generated by this component. |
void |
addListener(Component.Listener listener)
Registers a new component event listener for this component. |
void |
addListener(Paintable.RepaintRequestListener listener)
Adds repaint request listener. |
void |
addStyleName(String style)
Adds style name to component. |
void |
attach()
Notifies the component that it is connected to an application. |
void |
changeVariables(Object source,
Map variables)
Called when one or more variables handled by the implementing class are changed. |
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. |
protected void |
fireComponentErrorEvent()
Emits the component error event. |
protected void |
fireComponentEvent()
Emits the component event. |
protected void |
fireEvent(Component.Event event)
Sends the event to all listeners. |
Application |
getApplication()
Gets the component's parent application. |
String |
getCaption()
Gets the caption of the component. |
ErrorMessage |
getComponentError()
Gets the component's error message. |
Object |
getData()
Gets the application specific data. |
String |
getDebugId()
Get's currently set debug identifier |
String |
getDescription()
Gets the component's description. |
AbstractComponent.ComponentErrorHandler |
getErrorHandler()
Gets the error handler for the component. |
ErrorMessage |
getErrorMessage()
Gets the error message for this component. |
int |
getHeight()
Gets the height of the object. |
int |
getHeightUnits()
Gets the height property units. |
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 |
getStyle()
Deprecated. Use getStyleName() instead; renamed for consistency and to indicate that "style" should not be used to switch client side implementation, only to style the component. |
String |
getStyleName()
Gets style for component. |
abstract String |
getTag()
Gets the UIDL tag corresponding to the component. |
int |
getWidth()
Gets the width of the object. |
int |
getWidthUnits()
Gets the width property units. |
Window |
getWindow()
Gets the component's parent window. |
boolean |
handleError(AbstractComponent.ComponentErrorEvent error)
Handle the component error event. |
boolean |
isEnabled()
Tests if the component is enabled or not. |
boolean |
isImmediate()
Tests if the variable owner is in immediate mode or not. |
boolean |
isReadOnly()
Tests if the component is in read-only mode. |
boolean |
isVisible()
Tests if the component is visible or not. |
void |
paint(PaintTarget target)
Paints the Paintable into a UIDL stream. |
void |
paintContent(PaintTarget target)
Paints any needed component-specific things to the given UIDL stream. |
void |
removeListener(Class eventType,
Object target)
Removes all registered listeners matching the given parameters. |
void |
removeListener(Class eventType,
Object target,
Method method)
Removes one registered listener method. |
void |
removeListener(Class eventType,
Object target,
String methodName)
Removes one registered listener method. |
void |
removeListener(Component.Listener listener)
Removes a previously registered component event listener from this component. |
void |
removeListener(Paintable.RepaintRequestListener listener)
Removes repaint request listener. |
void |
removeStyleName(String style)
Removes given style name from component. |
void |
requestRepaint()
Requests that the paintable should be repainted as soon as possible. |
void |
requestRepaintRequests()
Request sending of repaint events on any further visible changes. |
void |
setCaption(String caption)
Sets the component's caption String. |
void |
setComponentError(ErrorMessage componentError)
Sets the component's error message. |
void |
setData(Object data)
Sets the data object, that can be used for any application specific data. |
void |
setDebugId(String id)
Adds an unique id for component that get's transferred to terminal for testing purposes. |
void |
setDescription(String description)
Sets the component's description. |
void |
setEnabled(boolean enabled)
Enables or disables the component. |
void |
setErrorHandler(AbstractComponent.ComponentErrorHandler errorHandler)
Sets the error handler for the component. |
void |
setHeight(int height)
Deprecated. Error-prone; consider using {link setHeight(String)
or {link setHeight(int, int) instead. |
void |
setHeight(int height,
int unit)
|
void |
setHeight(String height)
Sets the height of the component using String presentation. |
void |
setHeightUnits(int unit)
Sets the height property units. |
void |
setIcon(Resource icon)
Sets the component's icon. |
void |
setImmediate(boolean immediate)
Sets the component's immediate mode to the specified status. |
void |
setLocale(Locale locale)
Sets the locale of this component. |
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 |
setSizeFull()
Sets the size to 100% x 100%. |
void |
setSizeUndefined()
Clears any size settings. |
void |
setStyle(String style)
Deprecated. Use setStyleName() instead; renamed for consistency and to indicate that "style" should not be used to switch client side implementation, only to style the component. |
void |
setStyleName(String style)
Sets and replaces all previous style names of the component. |
void |
setWidth(int width)
Deprecated. Error-prone; consider using {link setWidth(String)
or {link setWidth(int, int) instead. |
void |
setWidth(int width,
int unit)
|
void |
setWidth(String width)
Sets the width of the component using String presentation. |
void |
setWidthUnits(int unit)
Sets the width property units. |
void |
setVisible(boolean visible)
Sets the components visibility status. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractComponent()
| Method Detail |
|---|
public abstract String getTag()
Stringpublic void setDebugId(String id)
Paintable
setDebugId in interface Paintableid - A short (< 20 chars) alphanumeric idpublic String getDebugId()
Paintable
getDebugId in interface Paintablepublic String getStyle()
public void setStyle(String style)
RepaintRequestEvent.
style - the new style of the component.public String getStyleName()
Component
getStyleName in interface Componentpublic void setStyleName(String style)
ComponentRepaintRequestEvent.
setStyleName in interface Componentstyle - the new style of the component.public void addStyleName(String style)
ComponentRepaintRequestEvent.
addStyleName in interface Componentstyle - the new style to be added to the componentpublic void removeStyleName(String style)
Component
removeStyleName in interface Componentstyle - the style to be removedpublic String getCaption()
Component
getCaption in interface ComponentString.public void setCaption(String caption)
String. Caption is the
visible name of the component. This method will trigger a
RepaintRequestEvent.
setCaption in interface Componentcaption - the new caption String for the component.public Locale getLocale()
Component
getLocale in interface ComponentLocale.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.public void setLocale(Locale locale)
locale - the locale to become this component's locale.public Resource getIcon()
Component
getIcon in interface Componentnull if it not defined.public void setIcon(Resource icon)
RepaintRequestEvent.
setIcon in interface Componenticon - the icon to be shown with the component's caption.public boolean isEnabled()
ComponentTests 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.
isEnabled in interface VariableOwnerisEnabled in interface Componenttrue if the component, and it's parent, is enabled
false otherwise.VariableOwner.isEnabled()public void setEnabled(boolean enabled)
ComponentRepaintRequestEvent.
Note that after enabling a component, 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.
setEnabled in interface Componentenabled - the boolean value specifying if the component should be
enabled after the call or notpublic boolean isImmediate()
VariableOwnerTests if the variable owner is in immediate mode or not. Being in immediate mode means that all variable changes are required to be sent back from the terminal immediately when they occur.
Note: VariableOwner does not include a
set- method for the immediateness property. This is because not all
VariableOwners wish to offer the functionality. Such VariableOwners are
never in the immediate mode, thus they always return false
in VariableOwner.isImmediate().
isImmediate in interface VariableOwnertrue if the component is in immediate mode,
false if not.public void setImmediate(boolean immediate)
RepaintRequestEvent.
immediate - the boolean value specifying if the component should be in
the immediate mode after the call.VariableOwner.isImmediate()public boolean isVisible()
Componenttrue.
isVisible in interface Componenttrue if the component is visible in the UI,
false if notpublic void setVisible(boolean visible)
Component
setVisible in interface Componentvisible - the Boolean value specifying if the component should be
visible after the call or not.public String getDescription()
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 |
|
These tags may be nested.
Stringpublic void setDescription(String description)
getDescription() for more
information on what the description is. This method will trigger a
RepaintRequestEvent.
description - the new description string for the component.public Component getParent()
Component
getParent in interface Componentpublic void setParent(Component parent)
Component
This method calls automatically Component.attach() if the parent is
attached to a window (or is itself a window}, and Component.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.
setParent in interface Componentparent - the new parent component.public ErrorMessage getErrorMessage()
public ErrorMessage getComponentError()
public void setComponentError(ErrorMessage componentError)
componentError - the new ErrorMessage of the component.public boolean isReadOnly()
Component
isReadOnly in interface Componenttrue if the component is in read-only mode,
false if not.public void setReadOnly(boolean readOnly)
ComponentRepaintRequestEvent.
setReadOnly in interface ComponentreadOnly - the boolean value specifying if the component should be in
read-only mode after the call or not.public Window getWindow()
Componentnull is returned.
getWindow in interface Componentnull.public void attach()
Component
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 Component.setParent(Component) if the parent
is already in the application. If the parent is not in the application,
it must call the Component.attach() for all its children when it will be
added to the application.
attach in interface Componentpublic void detach()
Component
The Component.getApplication() and Component.getWindow() methods might
return null after this method is called.
The caller of this method is Component.setParent(Component) if the parent
is in the application. When the parent is detached from the application
it is its response to call Component.detach() for all the children and to
detach itself from the terminal.
detach in interface Componentpublic Application getApplication()
Componentnull is returned.
getApplication in interface Componentnull.public void requestRepaintRequests()
PaintableThis method is normally used only by the terminals to note paintables about implicit repaints (painting the component without actually invoking paint method).
requestRepaintRequests in interface Paintable
public final void paint(PaintTarget target)
throws PaintException
PaintablePaints the Paintable into a UIDL stream. This method creates the UIDL sequence describing it and outputs it to the given UIDL stream.
It is called when the contents of the component should be painted in response to the component first being shown or having been altered so that its visual representation is changed.
paint in interface Paintabletarget - the target UIDL stream where the component should paint
itself to.
PaintException - if the paint operation failed.
public void paintContent(PaintTarget target)
throws PaintException
paint(PaintTarget) method handles all general
attributes common to all components, and it calls this method to paint
any component-specific attributes to the UIDL stream.
target - the target UIDL stream where the component should paint
itself to
PaintException - if the paint operation failed.public void requestRepaint()
Paintable
requestRepaint in interface Paintablepublic void childRequestedRepaint(Collection alreadyNotified)
Component
childRequestedRepaint in interface ComponentalreadyNotified - 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.public void addListener(Paintable.RepaintRequestListener listener)
Paintable
addListener in interface Paintablelistener - the listener to be added.public void removeListener(Paintable.RepaintRequestListener listener)
Paintable
removeListener in interface Paintablelistener - the listener to be removed.
public void changeVariables(Object source,
Map variables)
VariableOwner
changeVariables in interface VariableOwnersource - 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.
public void addListener(Class eventType,
Object object,
Method method)
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 in interface MethodEventSourceeventType - the 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.
public void addListener(Class eventType,
Object object,
String methodName)
Convenience method for registering 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.
Note: Using this method is discouraged because it cannot be checked
during compilation. Use addListener(Class, Object, Method) or
addListener(com.itmill.toolkit.ui.Component.Listener) instead.
addListener in interface MethodEventSourceeventType - the 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.
public void removeListener(Class eventType,
Object target)
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 in interface MethodEventSourceeventType - the exact event type the object listens to.target - the target object that has registered to listen to events
of type eventType with one or more methods.
public void removeListener(Class eventType,
Object target,
Method method)
For more information on the inheritable event mechanism see the
com.itmill.toolkit.event package
documentation.
removeListener in interface MethodEventSourceeventType - the 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.
public void removeListener(Class eventType,
Object target,
String methodName)
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 in interface MethodEventSourceeventType - the exact event type the object listens to.target - the target object that has registered to listen to events
of type eventType with one or more methods.methodName - the name of the method owned by target
that's registered to listen to events of type
eventType.protected void fireEvent(Component.Event event)
event - the Event to be sent to all listeners.public void addListener(Component.Listener listener)
Component
addListener in interface Componentlistener - the new Listener to be registered.public void removeListener(Component.Listener listener)
Component
removeListener in interface Componentlistener - the listener to be removed.protected void fireComponentEvent()
protected void fireComponentErrorEvent()
public void setData(Object data)
data - the Application specific data.public Object getData()
setData(Object).
public int getHeight()
Sizeable
getHeight in interface Sizeablepublic int getHeightUnits()
Sizeable
getHeightUnits in interface Sizeablepublic int getWidth()
Sizeable
getWidth in interface Sizeablepublic int getWidthUnits()
Sizeable
getWidthUnits in interface Sizeablepublic void setHeight(int height)
setHeight(String)
or {link setHeight(int, int) instead.
setHeight in interface Sizeableheight - the height of the object in units specified by heightUnits
property.{@link Sizeable#setHeight(int)},
{@link Sizeable#setHeight(String)},
{@link Sizeable#setHeightUnits(int)}public void setHeightUnits(int unit)
Sizeable
setHeightUnits in interface Sizeableunit - the units used in height property.
public void setHeight(int height,
int unit)
public void setSizeFull()
Sizeable
setSizeFull in interface Sizeablepublic void setSizeUndefined()
Sizeable
setSizeUndefined in interface Sizeablepublic void setWidth(int width)
setWidth(String)
or {link setWidth(int, int) instead.
setWidth in interface Sizeablewidth - the width of the object in units specified by widthUnits
property.{@link Sizeable#setWidth(int)},
{@link Sizeable#setWidth(String)},
{@link Sizeable#setWidthUnits(int)}public void setWidthUnits(int unit)
Sizeable
setWidthUnits in interface Sizeableunit - the units used in width property.
public void setWidth(int width,
int unit)
public void setWidth(String width)
Sizeable
setWidth in interface Sizeablewidth - in CSS style string representationpublic void setHeight(String height)
Sizeable
setHeight in interface Sizeableheight - in CSS style string representationpublic AbstractComponent.ComponentErrorHandler getErrorHandler()
public void setErrorHandler(AbstractComponent.ComponentErrorHandler errorHandler)
errorHandler - AbstractField specific error handlerpublic boolean handleError(AbstractComponent.ComponentErrorEvent error)
error - Error event to handle
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||