|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.millstone.base.ui.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
MillStone component. Most components in the MillStone base UI package do
just that.
Nested Class Summary |
Nested classes inherited from class org.millstone.base.ui.Component |
Component.Event, Component.Listener |
Nested classes inherited from class org.millstone.base.terminal.Paintable |
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener |
Constructor Summary | |
AbstractComponent()
Constructs a new Component |
Method Summary | |
void |
addListener(java.lang.Class eventType,
java.lang.Object object,
java.lang.reflect.Method method)
Registers a new listener with the specified activation method to listen events generated by this component. |
void |
addListener(java.lang.Class eventType,
java.lang.Object object,
java.lang.String methodName)
Registers 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)
Add repaint request listener. |
void |
attach()
Notifies the component that it is connected to an application. |
void |
changeVariables(java.lang.Object source,
java.util.Map variables)
Called when one or more variables handled by the implementing class are changed. |
void |
childRequestedRepaint(java.util.Collection alreadyNotified)
The children must call this method when they need repainting. |
void |
dependsOn(VariableOwner depended)
Makes this VariableOwner depend on the given
VariableOwner . |
void |
detach()
Notifies the component that it is detached from the application. |
protected void |
fireComponentEvent()
Emits a component event. |
protected void |
fireEvent(Component.Event event)
Send event to all listeners |
Application |
getApplication()
Gets the component's parent application. |
java.lang.String |
getCaption()
Gets the caption of the component. |
ErrorMessage |
getComponentError()
Gets the component's error message. |
java.lang.String |
getDescription()
Gets the component's description. |
java.util.Set |
getDirectDependencies()
Gets the variable change listeners this VariableOwner
directly depends on. |
ErrorMessage |
getErrorMessage()
Get the error message for this component. |
Resource |
getIcon()
Gets the component's icon. |
java.util.Locale |
getLocale()
Gets the locale of this component. |
Component |
getParent()
Gets the visual parent of the component. |
java.lang.String |
getStyle()
Gets the look-and-feel style of the component. |
abstract java.lang.String |
getTag()
Gets the UIDL tag corresponding to the component. |
Window |
getWindow()
Gets the component's parent window. |
boolean |
isEnabled()
Tests if the component is enabled or not. |
boolean |
isImmediate()
Tests if the component 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 |
removeDirectDependency(VariableOwner depended)
Removes the given component from this component's dependency list. |
void |
removeListener(java.lang.Class eventType,
java.lang.Object target)
Removes all registered listeners matching the given parameters. |
void |
removeListener(java.lang.Class eventType,
java.lang.Object target,
java.lang.reflect.Method method)
Removes one registered listener method. |
void |
removeListener(java.lang.Class eventType,
java.lang.Object target,
java.lang.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)
Remove repaint request listener. |
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(java.lang.String caption)
Sets the component's caption String . |
void |
setComponentError(ErrorMessage componentError)
Sets the component's error message. |
void |
setDescription(java.lang.String description)
Sets the component's description. |
void |
setEnabled(boolean enabled)
Enable or disable the component. |
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(java.util.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 |
setStyle(java.lang.String style)
Sets the look-and-feel style of the component. |
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 java.lang.String getTag()
String
public java.lang.String getStyle()
Component
getStyle
in interface Component
public void setStyle(java.lang.String style)
Component
RepaintRequestEvent
.
.
setStyle
in interface Component
style
- new style of the componentpublic java.lang.String getCaption()
Component
getCaption
in interface Component
String
public void setCaption(java.lang.String caption)
String
. Caption is the
visible name of the component. This method will trigger a
RepaintRequestEvent
.
caption
- new caption String
for the componentpublic java.util.Locale getLocale()
Component
getLocale
in interface Component
public void setLocale(java.util.Locale locale)
locale
- The locale to become this component's locale.public Resource getIcon()
Component
getIcon
in interface Component
null
if it not defined.public void setIcon(Resource icon)
RepaintRequestEvent
.
icon
- the icon to be shown with the component's captionpublic boolean isEnabled()
Component
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.
isEnabled
in interface Component
true
if the component is enabled,
false
if notVariableOwner.isEnabled()
public void setEnabled(boolean enabled)
Component
RepaintRequestEvent
.
setEnabled
in interface Component
enabled
- boolean value specifying if the component should be
enabled after the call or notpublic boolean isImmediate()
Component
Tests if the component is in immediate mode or not. Being in immediate mode means that all changes in the UI to the component are required to be sent back from the terminal immediately when they occur.
Note: Component
does not include a
set-method for the immediateness property. This is because not all
components wish to offer the functionality. Such components are never
in the immediate mode, thus they always return false
in
Component.isImmediate()
.
isImmediate
in interface Component
true
if the component is in immediate mode,
false
if notpublic void setImmediate(boolean immediate)
RepaintRequestEvent
.
immediate
- boolean value specifying if the component should
be in the immediate mode after the call.Component.isImmediate()
public boolean isVisible()
Component
true
.
isVisible
in interface Component
true
if the component is visible in the UI,
false
if notpublic void setVisible(boolean visible)
Component
setVisible
in interface Component
visible
- Boolean value specifying if the component should be
visible after the call or notpublic java.lang.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.
String
public void setDescription(java.lang.String description)
getDescription()
for
more information on what the description is. This method will trigger
a RepaintRequestEvent
.
description
- new description string for the componentpublic Component getParent()
Component
getParent
in interface Component
public 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 Component
parent
- the new parent componentpublic ErrorMessage getErrorMessage()
public ErrorMessage getComponentError()
public void setComponentError(ErrorMessage componentError)
public boolean isReadOnly()
Component
isReadOnly
in interface Component
true
if the component is in read-only mode,
false
if notpublic void setReadOnly(boolean readOnly)
Component
RepaintRequestEvent
.
setReadOnly
in interface Component
readOnly
- boolean value specifying if the component should be
in read-only mode after the call or notpublic Window getWindow()
Component
null
is returned.
getWindow
in interface Component
null
public void attach()
Component
getApplication()
and
getWindow()
functions 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 Component
public 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 Component
public Application getApplication()
Component
null
is returned.
getApplication
in interface Component
null
public void requestRepaintRequests()
Paintable
requestRepaintRequests
in interface Paintable
public final void paint(PaintTarget target) throws PaintException
Paintable
Paints the paintable into a UIDL stream. This method creates the UIDL sequence describing it and outputs it to the given UIDL stream.
It's 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 Paintable
target
- target UIDL stream where the component should paint
itself to
PaintException
- if the paint operation failedpublic 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
- target UIDL stream where the component should paint
itself to
PaintException
- if the operation failedpublic void requestRepaint()
Paintable
requestRepaint
in interface Paintable
public void childRequestedRepaint(java.util.Collection alreadyNotified)
Component
childRequestedRepaint
in interface Component
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.public void addListener(Paintable.RepaintRequestListener listener)
Paintable
addListener
in interface Paintable
listener
- to be addedpublic void removeListener(Paintable.RepaintRequestListener listener)
Paintable
removeListener
in interface Paintable
listener
- to be removedpublic void changeVariables(java.lang.Object source, java.util.Map variables)
VariableOwner
changeVariables
in interface VariableOwner
source
- Source of the variable change. This is the origin of the
event. For example in Web Adapter this is the request.variables
- Mapping from variable names to new variable valuespublic void dependsOn(VariableOwner depended)
VariableOwner
VariableOwner
depend on the given
VariableOwner
. This means that any variable change
events relating to depended
must be sent before any
such events that relate to this object.
dependsOn
in interface VariableOwner
public void removeDirectDependency(VariableOwner depended)
VariableOwner
depended
wdepende direct dependency from the component.
Indirect dependencies are not removed.
removeDirectDependency
in interface VariableOwner
public java.util.Set getDirectDependencies()
VariableOwner
VariableOwner
directly depends on. This list does not contain any indirect
dependencies, for example, if A depends on B and B depends on C,
the dependency list of A does not include C.
getDirectDependencies
in interface VariableOwner
VariableOwner
s this component directly
depend on, null
if this component does not depend on
anybody.public void addListener(java.lang.Class eventType, java.lang.Object object, java.lang.reflect.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 MillStone inheritable event mechanism see the org.millstone.base.event.
addListener
in interface MethodEventSource
eventType
- type of the listened event. Events of this type or
its subclasses activate the listener.object
- the object instance who owns the activation methodmethod
- the activation method
java.lang.IllegalArgumentException
- unless method
has exactly one match in object
public void addListener(java.lang.Class eventType, java.lang.Object object, java.lang.String methodName)
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 MillStone inheritable event mechanism see the org.millstone.base.event.
addListener
in interface MethodEventSource
eventType
- type of the listened event. Events of this type or
its subclasses activate the listener.object
- the object instance who owns the activation methodmethodName
- the name of the activation method
java.lang.IllegalArgumentException
- unless method
has exactly one match in object
public void removeListener(java.lang.Class eventType, java.lang.Object target)
object
's methods that
are registered to listen to events of type eventType
generated by this component.
For more information on the MillStone inheritable event mechanism see the org.millstone.base.event.
removeListener
in interface MethodEventSource
eventType
- exact event type the object
listens totarget
- target object that has registered to listen to events
of type eventType
with one or more methodspublic void removeListener(java.lang.Class eventType, java.lang.Object target, java.lang.reflect.Method method)
For more information on the MillStone inheritable event mechanism see the org.millstone.base.event.
removeListener
in interface MethodEventSource
eventType
- exact event type the object
listens totarget
- target object that has registered to listen to events
of type eventType
with one or more methodsmethod
- the method owned by target
that's
registered to listen to events of type eventType
public void removeListener(java.lang.Class eventType, java.lang.Object target, java.lang.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 MillStone inheritable event mechanism see the org.millstone.base.event.
removeListener
in interface MethodEventSource
eventType
- exact event type the object
listens totarget
- target object that has registered to listen to events
of type eventType
with one or more methodsmethodName
- name of the method owned by target
that's registered to listen to events of type eventType
protected void fireEvent(Component.Event event)
event
- Event to be sent to all listenerspublic void addListener(Component.Listener listener)
Component
addListener
in interface Component
listener
- the new Listener to be registeredpublic void removeListener(Component.Listener listener)
Component
removeListener
in interface Component
listener
- the listener to be removedprotected void fireComponentEvent()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |