org.millstone.base.ui
Interface Component

All Superinterfaces:
java.util.EventListener, Paintable, VariableOwner
All Known Subinterfaces:
ComponentContainer, Layout
All Known Implementing Classes:
AbstractComponent, AbstractComponentContainer, CustomComponent, CustomLayout, GridLayout, OrderedLayout

public interface Component
extends Paintable, VariableOwner

The top-level component interface which must be implemented by all MillStone UI components. It contains the methods the MillStone framework needs to handle the components in a user interface.

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

Nested Class Summary
static class Component.Event
          Superclass of all component originated Events.
static interface Component.Listener
          Listener interface for receiving Component.Events
 
Nested classes inherited from class org.millstone.base.terminal.Paintable
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener
 
Method Summary
 void addListener(Component.Listener listener)
          Registers a new component event listener for this component.
 void attach()
          Notifies the component that it is connected to an application.
 void childRequestedRepaint(java.util.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.
 java.lang.String getCaption()
          Gets the caption of the 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.
 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 removeListener(Component.Listener listener)
          Removes a previously registered component event listener from this component.
 void setEnabled(boolean enabled)
          Enable or disable the 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 interface org.millstone.base.terminal.Paintable
addListener, paint, removeListener, requestRepaint, requestRepaintRequests
 
Methods inherited from interface org.millstone.base.terminal.VariableOwner
changeVariables, dependsOn, getDirectDependencies, removeDirectDependency
 

Method Detail

getStyle

public java.lang.String getStyle()
Gets the look-and-feel style of the component.

Returns:
component's styleValue of property style.

setStyle

public void setStyle(java.lang.String style)
Sets the look-and-feel style of the component. This method will trigger a RepaintRequestEvent. .

Parameters:
style - new style of the component

isEnabled

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

Components should be enabled by default.

Specified by:
isEnabled in interface VariableOwner
Returns:
true if the component is enabled, false if not
See Also:
VariableOwner.isEnabled()

setEnabled

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

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

isImmediate

public boolean isImmediate()

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

Returns:
true if the component is in immediate mode, false if not

isVisible

public boolean isVisible()
Tests if the component is visible or not. Visibility defines if the component is shown in the UI or not. Default is true.

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

setVisible

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

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

getParent

public 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

public 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

public 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

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

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

getCaption

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

Returns:
component's caption String

getIcon

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

getWindow

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

Returns:
parent window of the component or null

getApplication

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

Returns:
parent application of the component or null

attach

public 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() functions 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

public 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

public java.util.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.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.

childRequestedRepaint

public void childRequestedRepaint(java.util.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 - 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.

addListener

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

Parameters:
listener - the new Listener to be registered

removeListener

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

Parameters:
listener - the listener to be removed


Copyright © 2000,2001,2002 IT Mill Ltd. All Rights Reserved.