javax.rad.genui
Class UIComponent<C extends IComponent>

java.lang.Object
  extended by javax.rad.genui.UIResource<C>
      extended by javax.rad.genui.UIComponent<C>
Type Parameters:
C - instance of IComponent
All Implemented Interfaces:
ITranslatable, IComponent, IResource, INamedObject, ITranslator
Direct Known Subclasses:
AbstractControllable, AbstractUIActionComponent, AbstractUITextField, UIContainer, UICustomComponent, UIIcon, UILabel, UISeparator

public abstract class UIComponent<C extends IComponent>
extends UIResource<C>
implements IComponent, ITranslatable, ITranslator

Platform and technology independent component. It is designed for use with AWT, Swing, SWT, JSP, JSF,... .


Field Summary
protected  boolean bTranslate
          whether translate should translate texts.
protected  long lLastTranslationModified
          the time of the last translation modification.
protected  IContainer parent
          the UIParent of this UIComponent.
protected  IPopupMenu popupMenu
          the UIParent of this UICompoennt.
 
Fields inherited from class javax.rad.genui.UIResource
uiResource
 
Constructor Summary
protected UIComponent(C pComponent)
          Creates a new instance of UIComponent.
 
Method Summary
 void addNotify()
          Makes this UIComponent displayable by adding it to an UIContainer.
 void beforeAddNotify(IComponent pParent)
          Invoked before this component is added.
 IImage capture(int iWidth, int iHeight)
          Creates an image/screenshot of the component.
protected  java.lang.String createComponentName()
          Creates a name for this UIComponent.
protected  java.lang.String createComponentNamePrefix()
          Creates a String consisting of the root name (if any) and the upper characters of the simple class name.
 void debug(java.lang.Object... pInfo)
          Logs debug information.
 void doEventKey(UIKeyEvent pKeyEvent)
          Dispatches the given UIKeyEvent to all EventHandlers that have subscribed to the Key of the event.
 void doTriggerPopMenu(UIMouseEvent pMouseEvent)
          Triggers popup menu to be shown.
 boolean equals(java.lang.Object pObject)
          
 void error(java.lang.Object... pInfo)
          Logs error information.
 ComponentHandler<IComponentMovedListener> eventComponentMoved()
          The ComponentHandler for the moved event.
 ComponentHandler<IComponentResizedListener> eventComponentResized()
          The ComponentHandler for the resized event.
 FocusHandler<IFocusGainedListener> eventFocusGained()
          The FocusHandler for the focus gained event.
 FocusHandler<IFocusLostListener> eventFocusLost()
          The FocusHandler for the focus lost event.
 KeyHandler<? super IKeyListener> eventKey(Key pKey)
          The EventHandler for the given Key.
 KeyHandler<IKeyPressedListener> eventKeyPressed()
          The EventHandler for the key pressed event.
 KeyHandler<IKeyReleasedListener> eventKeyReleased()
          The EventHandler for the key released event.
 KeyHandler<IKeyTypedListener> eventKeyTyped()
          The EventHandler for the key typed event.
 MouseHandler<IMouseClickedListener> eventMouseClicked()
          The EventHandler for the mouse clicked event.
 MouseHandler<IMouseEnteredListener> eventMouseEntered()
          The EventHandler for the mouse entered event.
 MouseHandler<IMouseExitedListener> eventMouseExited()
          The EventHandler for the mouse exited event.
 MouseHandler<IMousePressedListener> eventMousePressed()
          The EventHandler for the mouse pressed event.
 MouseHandler<IMouseReleasedListener> eventMouseReleased()
          The EventHandler for the mouse released event.
 IColor getBackground()
          Gets the background color of this component.
 IRectangle getBounds()
          Gets the bounds of this component in the form of a IRectangle object.
 IComponent getComponentUIResource()
          Gets the component which will be added/removed to an UIContainer instead of this component.
protected  TranslationMap getCurrentTranslation()
          Gets the current translation mapping usable for this UIComponent.
 ICursor getCursor()
          Gets the ICursor set in the component.
 java.lang.String getDefaultName()
          Gets the default/generated name for this UIComponent.
 IComponent getEventSource()
          Gets the wanted event source for this component.
protected  java.util.Set<java.lang.String> getExistingNames()
          Gets the Set which contains the already existing UIComponent names under the current root.
 IFactory getFactory()
          Gets the factory that created this NamedObject.
 IFont getFont()
          Gets the font of this component.
 IColor getForeground()
          Gets the foreground color of this component.
 IPoint getLocation()
          Gets the location of this component in the form of a point specifying the component's top-left corner.
protected  IPoint getLocationOffset()
          Gets the component which will be added/removed to an UIContainer instead of this component.
 IPoint getLocationRelativeTo(IComponent pComponent)
          Gets the location relative to the given component.
 IDimension getMaximumSize()
          Gets the maximum size of this component.
 IDimension getMinimumSize()
          Gets the mininimum size of this component.
 java.lang.String getName()
          Gets the name of the object.
 IContainer getParent()
          Gets the parent of this component.
 IPopupMenu getPopupMenu()
          Sets the popup menu that should be displayed by this component.
 IDimension getPreferredSize()
          Gets the preferred size of this component.
 java.lang.Object getResource()
          Gets the original resource corresponding with this wrapper object.
 java.lang.String getRootName()
          Gets the name of the root UIComponent of this UIComponent.
 IDimension getSize()
          Returns the size of this component in the form of a IDimension object.
 Style getStyle()
          Gets the style definition.
 java.lang.Integer getTabIndex()
          Returns the desired tab index.
 java.lang.String getToolTipText()
          Returns the tooltip string that has been set with setToolTipText.
 TranslationMap getTranslation()
          Gets the possible translation mapping.
protected  UIComponent<?> getUIComponent()
          Gets the genui component, thats ui resource is added to the parents ui resource.
 int hashCode()
          
protected static java.lang.String incrementNameIfExists(java.lang.String pName, java.util.Set<java.lang.String> pAlreadyExistingNames, boolean pAppendOne)
          A simple helper method that allows to add a counter to a name until it is unique.
 void info(java.lang.Object... pInfo)
          Logs information.
static void invokeAndWait(java.lang.Object pRunnable, java.lang.String pMethod)
          Causes pRunnable.run() to be executed synchronously on the event dispatching thread.
static void invokeAndWait(java.lang.Runnable pRunnable)
          Causes pRunnable.run() to be executed synchronously on the event dispatching thread.
static java.lang.Thread invokeInThread(java.lang.Object pRunnable, java.lang.String pMethod)
          Causes pRunnable.run() to be executed asynchronously in a new thread.
static java.lang.Thread invokeInThread(java.lang.Runnable pRunnable)
          Causes pRunnable.run() to be executed asynchronously in a new thread.
static void invokeLater(java.lang.Object pObject, java.lang.String pMethod)
          Causes pRunnable.run() to be executed asynchronously on the event dispatching thread.
static void invokeLater(java.lang.Runnable pRunnable)
          Causes pRunnable.run() to be executed asynchronously on the event dispatching thread.
 boolean isBackgroundSet()
          Returns whether the background color has been explicitly set for this Component.
 boolean isBeforeNotified()
          Gets whether this component is notified before it was added.
 boolean isCursorSet()
          Returns whether the cursor has been explicitly set for this Component.
 boolean isEnabled()
          Determines whether this component is enabled.
 boolean isFocusable()
          Returns whether this component can be focused.
 boolean isFontSet()
          Returns whether the font has been explicitly set for this Component.
 boolean isForegroundSet()
          Returns whether the foreground color has been explicitly set for this Component.
 boolean isMaximumSizeSet()
          Returns true if the maximum size has been set to a non-null value otherwise returns false.
 boolean isMinimumSizeSet()
          Returns whether or not setMinimumSize has been invoked with a non-null value.
 boolean isNotified()
          Determines whether this UIComponent is displayable.
 boolean isPreferredSizeSet()
          Returns true if the preferred size has been set to a non-null value otherwise returns false.
protected  boolean isTranslationChanged()
          Gets whether the translation was changed.
 boolean isTranslationEnabled()
          Gets whether the translation is en- or disabled.
 boolean isVisible()
          Determines whether this component should be visible when its parent is visible.
 void removeNotify()
          Makes this UIComponent undisplayable by removing it to an UIContainer.
 void requestFocus()
          Requests that this Component get the input focus, and that this Component's top-level ancestor become the focused Window.
 void setBackground(IColor pBackground)
          Sets the background color of this component.
 void setBounds(int pX, int pY, int pWidth, int pHeight)
          Set the bounds with primitive types.
 void setBounds(IRectangle pBounds)
          Moves and resizes this component to conform to the new bounding rectangle pBounds.
 void setCursor(ICursor pCursor)
          Sets the cursor image to the specified cursor.
protected  void setDefaultName(java.lang.String pDefaultName)
          Sets the default name for this UIComponent.
 void setEnabled(boolean pEnable)
          Enables or disables this component, depending on the value of the parameter pEnable.
 void setEventSource(IComponent pEventSource)
          Sets the wanted event source for this component.
 void setFocusable(boolean pFocusable)
          Sets the focusable state of this component to the specified value.
 void setFont(IFont pFont)
          Sets the IFont of this component.
 void setForeground(IColor pForeground)
          Sets the foreground color of this component.
 void setLocation(int pX, int pY)
          Set the location with primitive types.
 void setLocation(IPoint pLocation)
          Moves this component to a new location.
 void setLocationRelativeTo(IComponent pComponent, IPoint pLocation)
          Sets the location relative to the given component.
 void setMaximumSize(IDimension pMaximumSize)
          Sets the maximum size of this component to a constant value.
 void setMaximumSize(int pWidth, int pHeight)
          Set the maximum size with primitive types.
 void setMinimumSize(IDimension pMinimumSize)
          Sets the minimum size of this component to a constant value.
 void setMinimumSize(int pWidth, int pHeight)
          Set the minimum size with primitive types.
 void setName(java.lang.String pName)
          Sets the name of the object to the specified string.
 void setParent(IContainer pParent)
          Sets the parent of this component.
 void setPopupMenu(IPopupMenu pPopupMenu)
          Sets the popup menu that should be displayed by this component.
 void setPreferredSize(IDimension pPreferredSize)
          Sets the preferred size of this component to a constant value.
 void setPreferredSize(int pWidth, int pHeight)
          Set the preferred size with primitive types.
protected  void setRootName(java.lang.String pRootName)
          Sets the root name to the given one.
 void setSize(IDimension pSize)
          Resizes this component so that it has width d.width and height d.height.
 void setSize(int pWidth, int pHeight)
          Set the size with primitive types.
 void setStyle(Style pStyle)
          Sets the style definition.
 void setTabIndex(java.lang.Integer pTabIndex)
          Sets the desired tab index.
 void setToolTipText(java.lang.String pText)
          Registers the text to display in a tool tip.
 void setTranslation(TranslationMap pTranslation)
          Sets the possible translations.
 void setTranslationEnabled(boolean pEnabled)
          Sets the translation en- or disabled.
protected  void setUIComponent(UIComponent<?> pComponent)
          Sets the genui component, thats ui resource is added to the parents ui resource.
 void setVisible(boolean pVisible)
          Shows or hides this component depending on the value of parameter b.
 java.lang.String translate(java.lang.String pText)
          Translates the given text with the avaliable translation.
 void updateTranslation()
          Notification for updating the translation.
 
Methods inherited from class javax.rad.genui.UIResource
eventResourceChanged, eventResourceChanged, fireResourceChanged, getObject, getObjectNames, getUIResource, hasResourceHandler, putObject, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected IContainer parent
the UIParent of this UIComponent.


popupMenu

protected IPopupMenu popupMenu
the UIParent of this UICompoennt.


lLastTranslationModified

protected long lLastTranslationModified
the time of the last translation modification.


bTranslate

protected boolean bTranslate
whether translate should translate texts.

Constructor Detail

UIComponent

protected UIComponent(C pComponent)
Creates a new instance of UIComponent.

Parameters:
pComponent - the Component.
See Also:
IComponent
Method Detail

getName

public java.lang.String getName()
Gets the name of the object. Implementing classes need to make sure that no name is set during the creation of the component. A unique name (based on the position of the component in the component tree) will be generated and set when the component is added, but only if the name of the component is null.

Specified by:
getName in interface IComponent
Specified by:
getName in interface INamedObject
Returns:
this component's name
See Also:
IComponent.setName(java.lang.String)

setName

public void setName(java.lang.String pName)
Sets the name of the object to the specified string.

Specified by:
setName in interface IComponent
Specified by:
setName in interface INamedObject
Parameters:
pName - the string that is to be this component's name
See Also:
IComponent.getName()

getFactory

public IFactory getFactory()
Gets the factory that created this NamedObject.

Specified by:
getFactory in interface IComponent
Returns:
the factory that created this NamedObject

getPreferredSize

public IDimension getPreferredSize()
Gets the preferred size of this component.

Specified by:
getPreferredSize in interface IComponent
Returns:
an IDimension object indicating this component's preferred size
See Also:
IComponent.getMinimumSize(), LayoutManager

setPreferredSize

public void setPreferredSize(IDimension pPreferredSize)
Sets the preferred size of this component to a constant value. Subsequent calls to getPreferredSize will always return this value. Setting the preferred size to null restores the default behavior.

Specified by:
setPreferredSize in interface IComponent
Parameters:
pPreferredSize - the new preferred size, or null
See Also:
IComponent.getPreferredSize(), IComponent.isPreferredSizeSet()

isPreferredSizeSet

public boolean isPreferredSizeSet()
Returns true if the preferred size has been set to a non-null value otherwise returns false.

Specified by:
isPreferredSizeSet in interface IComponent
Returns:
true if setPreferredSize has been invoked with a non-null value.

getMinimumSize

public IDimension getMinimumSize()
Gets the mininimum size of this component.

Specified by:
getMinimumSize in interface IComponent
Returns:
an IDimension object indicating this component's minimum size
See Also:
IComponent.getPreferredSize(), LayoutManager

setMinimumSize

public void setMinimumSize(IDimension pMinimumSize)
Sets the minimum size of this component to a constant value. Subsequent calls to getMinimumSize will always return this value. Setting the minimum size to null restores the default behavior.

Specified by:
setMinimumSize in interface IComponent
Parameters:
pMinimumSize - the new minimum size of this component
See Also:
IComponent.getMinimumSize(), IComponent.isMinimumSizeSet()

isMinimumSizeSet

public boolean isMinimumSizeSet()
Returns whether or not setMinimumSize has been invoked with a non-null value.

Specified by:
isMinimumSizeSet in interface IComponent
Returns:
true if setMinimumSize has been invoked with a non-null value.

getMaximumSize

public IDimension getMaximumSize()
Gets the maximum size of this component.

Specified by:
getMaximumSize in interface IComponent
Returns:
an IDimension object indicating this component's maximum size
See Also:
IComponent.getMinimumSize(), IComponent.getPreferredSize(), LayoutManager

setMaximumSize

public void setMaximumSize(IDimension pMaximumSize)
Sets the maximum size of this component to a constant value. Subsequent calls to getMaximumSize will always return this value. Setting the maximum size to null restores the default behavior.

Specified by:
setMaximumSize in interface IComponent
Parameters:
pMaximumSize - a IDimension containing the desired maximum allowable size
See Also:
IComponent.getMaximumSize(), IComponent.isMaximumSizeSet()

isMaximumSizeSet

public boolean isMaximumSizeSet()
Returns true if the maximum size has been set to a non-null value otherwise returns false.

Specified by:
isMaximumSizeSet in interface IComponent
Returns:
true if maximumSize is non-null, false otherwise

getBackground

public IColor getBackground()
Gets the background color of this component.

Specified by:
getBackground in interface IComponent
Returns:
this component's background color; if this component does not have a background color, the background color of its parent is returned
See Also:
IComponent.setBackground(javax.rad.ui.IColor)

setBackground

public void setBackground(IColor pBackground)
Sets the background color of this component.

The background color affects each component differently and the parts of the component that are affected by the background color may differ between operating systems.

Specified by:
setBackground in interface IComponent
Parameters:
pBackground - the color to become this component's color; if this parameter is null, then this component will inherit the background color of its parent
See Also:
IComponent.getBackground()

isBackgroundSet

public boolean isBackgroundSet()
Returns whether the background color has been explicitly set for this Component. If this method returns false, this Component is inheriting its background color from an ancestor.

Specified by:
isBackgroundSet in interface IComponent
Returns:
true if the background color has been explicitly set for this Component; false otherwise.

getForeground

public IColor getForeground()
Gets the foreground color of this component.

Specified by:
getForeground in interface IComponent
Returns:
this component's foreground color; if this component does not have a foreground color, the foreground color of its parent is returned
See Also:
IComponent.setForeground(javax.rad.ui.IColor)

setForeground

public void setForeground(IColor pForeground)
Sets the foreground color of this component.

Specified by:
setForeground in interface IComponent
Parameters:
pForeground - the color to become this component's foreground color; if this parameter is null then this component will inherit the foreground color of its parent
See Also:
IComponent.getForeground()

isForegroundSet

public boolean isForegroundSet()
Returns whether the foreground color has been explicitly set for this Component. If this method returns false, this Component is inheriting its foreground color from an ancestor.

Specified by:
isForegroundSet in interface IComponent
Returns:
true if the foreground color has been explicitly set for this Component; false otherwise.

getCursor

public ICursor getCursor()
Gets the ICursor set in the component. If the component does not have a cursor set, the cursor of its parent is returned. If no cursor is set in the entire hierarchy, Cursor.DEFAULT_CURSOR is returned.

Specified by:
getCursor in interface IComponent
Returns:
the ICursor set in the component
See Also:
IComponent.setCursor(javax.rad.ui.ICursor)

setCursor

public void setCursor(ICursor pCursor)
Sets the cursor image to the specified cursor. This cursor image is displayed when the contains method for this component returns true for the current cursor location, and this Component is visible, displayable, and enabled. Setting the cursor of a Container causes that cursor to be displayed within all of the container's subcomponents, except for those that have a non-null cursor.

The method may have no visual effect if the Java platform implementation and/or the native system do not support changing the mouse cursor shape.

Specified by:
setCursor in interface IComponent
Parameters:
pCursor - One of the constants defined by the Cursor class; if this parameter is null then this component will inherit the cursor of its parent
See Also:
IComponent.isEnabled(), IComponent.getCursor(), Toolkit.createCustomCursor(java.awt.Image, java.awt.Point, java.lang.String), ICursor

isCursorSet

public boolean isCursorSet()
Returns whether the cursor has been explicitly set for this Component. If this method returns false, this Component is inheriting its cursor from an ancestor.

Specified by:
isCursorSet in interface IComponent
Returns:
true if the cursor has been explicitly set for this Component; false otherwise.

getFont

public IFont getFont()
Gets the font of this component.

Specified by:
getFont in interface IComponent
Returns:
this component's font; if a font has not been set for this component, the font of its parent is returned
See Also:
IComponent.setFont(javax.rad.ui.IFont)

setFont

public void setFont(IFont pFont)
Sets the IFont of this component.

Specified by:
setFont in interface IComponent
Parameters:
pFont - the IFont to become this component's font; if this parameter is null then this component will inherit the font of its parent
See Also:
IComponent.getFont()

isFontSet

public boolean isFontSet()
Returns whether the font has been explicitly set for this Component. If this method returns false, this Component is inheriting its font from an ancestor.

Specified by:
isFontSet in interface IComponent
Returns:
true if the font has been explicitly set for this Component; false otherwise.

getToolTipText

public java.lang.String getToolTipText()
Returns the tooltip string that has been set with setToolTipText.

Specified by:
getToolTipText in interface IComponent
Returns:
the text of the tool tip
See Also:
IComponent.setToolTipText(String)

setToolTipText

public void setToolTipText(java.lang.String pText)
Registers the text to display in a tool tip. The text displays when the cursor lingers over the component.

Specified by:
setToolTipText in interface IComponent
Parameters:
pText - the string to display; if the text is null, the tool tip is turned off for this component

setFocusable

public void setFocusable(boolean pFocusable)
Sets the focusable state of this component to the specified value.

Specified by:
setFocusable in interface IComponent
Parameters:
pFocusable - indicates whether this Component is focusable

isFocusable

public boolean isFocusable()
Returns whether this component can be focused.

Specified by:
isFocusable in interface IComponent
Returns:
true if this Component is focusable, false otherwise.

getTabIndex

public java.lang.Integer getTabIndex()
Returns the desired tab index. If several editors have the same tab index, or it is null the behaviour is technology dependend.

Specified by:
getTabIndex in interface IComponent
Returns:
the desired tab index.

setTabIndex

public void setTabIndex(java.lang.Integer pTabIndex)
Sets the desired tab index. If several editors have the same tab index, or it is null the behaviour is technology dependend.

Specified by:
setTabIndex in interface IComponent
Parameters:
pTabIndex - the desired tab index.

requestFocus

public void requestFocus()
Requests that this Component get the input focus, and that this Component's top-level ancestor become the focused Window. This component must be displayable, visible, and focusable for the request to be granted. Every effort will be made to honor the request; however, in some cases it may be impossible to do so. Developers must never assume that this Component is the focus owner until this Component receives a FOCUS_GAINED event. If this request is denied because this Component's top-level Window cannot become the focused Window, the request will be remembered and will be granted when the Window is later focused by the user.

This method cannot be used to set the focus owner to no Component at all. Use KeyboardFocusManager.clearGlobalFocusOwner() instead.

Because the focus behavior of this method is platform-dependent, developers are strongly encouraged to use requestFocusInWindow when possible.

Specified by:
requestFocus in interface IComponent

getParent

public IContainer getParent()
Gets the parent of this component.

Specified by:
getParent in interface IComponent
Returns:
the parent container of this component

setParent

public void setParent(IContainer pParent)
Sets the parent of this component.

Specified by:
setParent in interface IComponent
Parameters:
pParent - the parent container of this component

isVisible

public boolean isVisible()
Determines whether this component should be visible when its parent is visible. Components are initially visible, with the exception of top level components such as Frame objects.

Specified by:
isVisible in interface IComponent
Returns:
true if the component is visible, false otherwise
See Also:
IComponent.setVisible(boolean)

setVisible

public void setVisible(boolean pVisible)
Shows or hides this component depending on the value of parameter b.

Specified by:
setVisible in interface IComponent
Parameters:
pVisible - if true, shows this component; otherwise, hides this component
See Also:
IComponent.isVisible()

setEnabled

public void setEnabled(boolean pEnable)
Enables or disables this component, depending on the value of the parameter pEnable. An enabled component can respond to user input and generate events. Components are enabled initially by default.

Specified by:
setEnabled in interface IComponent
Parameters:
pEnable - if true, this component is enabled; otherwise this component is disabled
See Also:
IComponent.isEnabled()

isEnabled

public boolean isEnabled()
Determines whether this component is enabled. An enabled component can respond to user input and generate events. Components are enabled initially by default. A component may be enabled or disabled by calling its setEnabled method.

Specified by:
isEnabled in interface IComponent
Returns:
true if the component is enabled, false otherwise
See Also:
IComponent.setEnabled(boolean)

getLocationRelativeTo

public IPoint getLocationRelativeTo(IComponent pComponent)
Gets the location relative to the given component.

Specified by:
getLocationRelativeTo in interface IComponent
Parameters:
pComponent - the component in relation to which the window's location is determined.
Returns:
the location.

setLocationRelativeTo

public void setLocationRelativeTo(IComponent pComponent,
                                  IPoint pLocation)
Sets the location relative to the given component.

Specified by:
setLocationRelativeTo in interface IComponent
Parameters:
pComponent - the component in relation to which the window's location is determined.
pLocation - the location.

getLocation

public IPoint getLocation()
Gets the location of this component in the form of a point specifying the component's top-left corner. The location will be relative to the parent's coordinate space.

Due to the asynchronous nature of native event handling, this method can return outdated values (for instance, after several calls of setLocation() in rapid succession). For this reason, the recommended method of obtaining a component's position is within java.awt.event.ComponentListener.componentMoved(), which is called after the operating system has finished moving the component.

Specified by:
getLocation in interface IComponent
Returns:
an instance of IPoint representing the top-left corner of the component's bounds in the coordinate space of the component's parent
See Also:
IComponent.setLocation(IPoint)

setLocation

public void setLocation(IPoint pLocation)
Moves this component to a new location. The top-left corner of the new location is specified by point p. Point p is given in the parent's coordinate space.

Specified by:
setLocation in interface IComponent
Parameters:
pLocation - the point defining the top-left corner of the new location, given in the coordinate space of this component's parent
See Also:
IComponent.getLocation(), IComponent.setBounds(IRectangle)

getSize

public IDimension getSize()
Returns the size of this component in the form of a IDimension object. The height field of the IDimension object contains this component's height, and the width field of the IDimension object contains this component's width.

Specified by:
getSize in interface IComponent
Returns:
an IDimension object that indicates the size of this component
See Also:
IComponent.setSize(javax.rad.ui.IDimension)

setSize

public void setSize(IDimension pSize)
Resizes this component so that it has width d.width and height d.height.

Specified by:
setSize in interface IComponent
Parameters:
pSize - the IDimension specifying the new size of this component
See Also:
IComponent.setSize(javax.rad.ui.IDimension), IComponent.setBounds(javax.rad.ui.IRectangle)

getBounds

public IRectangle getBounds()
Gets the bounds of this component in the form of a IRectangle object. The bounds specify this component's width, height, and location relative to its parent.

Specified by:
getBounds in interface IComponent
Returns:
a rectangle indicating this component's bounds
See Also:
IComponent.setBounds(javax.rad.ui.IRectangle), IComponent.getLocation(), IComponent.getSize()

setBounds

public void setBounds(IRectangle pBounds)
Moves and resizes this component to conform to the new bounding rectangle pBounds. This component's new position is specified by pBounds.x and pBounds.y, and its new size is specified by pBounds.width and pBounds.height

Specified by:
setBounds in interface IComponent
Parameters:
pBounds - the new bounding rectangle for this component
See Also:
IComponent.getBounds(), IComponent.setLocation(IPoint), IComponent.setSize(IDimension)

getResource

public java.lang.Object getResource()
Gets the original resource corresponding with this wrapper object.

Specified by:
getResource in interface IResource
Overrides:
getResource in class UIResource<C extends IComponent>
Returns:
the original resource

getEventSource

public IComponent getEventSource()
Gets the wanted event source for this component. This gives wrapper implementations like genui a simple mechanism to control the source of component events.

Specified by:
getEventSource in interface IComponent
Returns:
the event source

setStyle

public void setStyle(Style pStyle)
Sets the style definition. A style can be used to customize a component.

Specified by:
setStyle in interface IComponent
Parameters:
pStyle - the style

getStyle

public Style getStyle()
Gets the style definition.

Specified by:
getStyle in interface IComponent
Returns:
the style definition
See Also:
IComponent.setStyle(Style)

setEventSource

public void setEventSource(IComponent pEventSource)
Sets the wanted event source for this component. This gives wrapper implementations like genui a simple mechanism to control the source of component events.

Specified by:
setEventSource in interface IComponent
Parameters:
pEventSource - the event source

eventMousePressed

public MouseHandler<IMousePressedListener> eventMousePressed()
The EventHandler for the mouse pressed event.

Specified by:
eventMousePressed in interface IComponent
Returns:
the EventHandler for the mouse pressed event.

eventMouseReleased

public MouseHandler<IMouseReleasedListener> eventMouseReleased()
The EventHandler for the mouse released event.

Specified by:
eventMouseReleased in interface IComponent
Returns:
the EventHandler for the mouse released event.

eventMouseClicked

public MouseHandler<IMouseClickedListener> eventMouseClicked()
The EventHandler for the mouse clicked event.

Specified by:
eventMouseClicked in interface IComponent
Returns:
the EventHandler for the mouse clicked event.

eventMouseEntered

public MouseHandler<IMouseEnteredListener> eventMouseEntered()
The EventHandler for the mouse entered event.

Specified by:
eventMouseEntered in interface IComponent
Returns:
the EventHandler for the mouse entered event.

eventMouseExited

public MouseHandler<IMouseExitedListener> eventMouseExited()
The EventHandler for the mouse exited event.

Specified by:
eventMouseExited in interface IComponent
Returns:
the EventHandler for the mouse exited event.

eventKeyPressed

public KeyHandler<IKeyPressedListener> eventKeyPressed()
The EventHandler for the key pressed event.

Specified by:
eventKeyPressed in interface IComponent
Returns:
the EventHandler for the key pressed event.

eventKeyReleased

public KeyHandler<IKeyReleasedListener> eventKeyReleased()
The EventHandler for the key released event.

Specified by:
eventKeyReleased in interface IComponent
Returns:
the EventHandler for the key released event.

eventKeyTyped

public KeyHandler<IKeyTypedListener> eventKeyTyped()
The EventHandler for the key typed event.

Specified by:
eventKeyTyped in interface IComponent
Returns:
the EventHandler for the key typed event.

eventComponentResized

public ComponentHandler<IComponentResizedListener> eventComponentResized()
The ComponentHandler for the resized event.

Specified by:
eventComponentResized in interface IComponent
Returns:
the ComponentHandler for the resized event.

eventComponentMoved

public ComponentHandler<IComponentMovedListener> eventComponentMoved()
The ComponentHandler for the moved event.

Specified by:
eventComponentMoved in interface IComponent
Returns:
the ComponentHandler for the moved event.

eventFocusGained

public FocusHandler<IFocusGainedListener> eventFocusGained()
The FocusHandler for the focus gained event.

Specified by:
eventFocusGained in interface IComponent
Returns:
the FocusHandler for the focus gained event.

eventFocusLost

public FocusHandler<IFocusLostListener> eventFocusLost()
The FocusHandler for the focus lost event.

Specified by:
eventFocusLost in interface IComponent
Returns:
the FocusHandler for the focus lost event.

capture

public IImage capture(int iWidth,
                      int iHeight)
Creates an image/screenshot of the component.

Specified by:
capture in interface IComponent
Parameters:
iWidth - the expected width
iHeight - the expected height
Returns:
the image/screenshot

setTranslation

public void setTranslation(TranslationMap pTranslation)
Sets the possible translations.

Specified by:
setTranslation in interface ITranslatable
Parameters:
pTranslation - the translation mapping

getTranslation

public TranslationMap getTranslation()
Gets the possible translation mapping.

Specified by:
getTranslation in interface ITranslatable
Returns:
the translation mapping

setTranslationEnabled

public void setTranslationEnabled(boolean pEnabled)
Sets the translation en- or disabled.

Specified by:
setTranslationEnabled in interface ITranslatable
Parameters:
pEnabled - true to enable the translation, false to disable

isTranslationEnabled

public boolean isTranslationEnabled()
Gets whether the translation is en- or disabled.

Specified by:
isTranslationEnabled in interface ITranslatable
Returns:
true if translation is performed, false otherwise

equals

public boolean equals(java.lang.Object pObject)

Overrides:
equals in class UIResource<C extends IComponent>

hashCode

public int hashCode()

Overrides:
hashCode in class UIResource<C extends IComponent>

incrementNameIfExists

protected static java.lang.String incrementNameIfExists(java.lang.String pName,
                                                        java.util.Set<java.lang.String> pAlreadyExistingNames,
                                                        boolean pAppendOne)
A simple helper method that allows to add a counter to a name until it is unique. A simple counter will be appended to the given name, which will be incremented as long as the given set does already hold the name. If it doesn't hold the name, that name will be returned. It will not be added to the given set.

Parameters:
pName - the name to increment if necessary.
pAlreadyExistingNames - the Set that holds all names.
pAppendOne - if 1 should be appended to the name or not.
Returns:
the name, if necessary with an appended counter.

getPopupMenu

public IPopupMenu getPopupMenu()
Sets the popup menu that should be displayed by this component.

Returns:
the popup menu.

setPopupMenu

public void setPopupMenu(IPopupMenu pPopupMenu)
Sets the popup menu that should be displayed by this component.

Parameters:
pPopupMenu - the popup menu.

getDefaultName

public java.lang.String getDefaultName()
Gets the default/generated name for this UIComponent. Can return null if addNotify() wasn't called by now.

Returns:
the default/generated name. null if addNotify() hasn't been called by now.

getRootName

public final java.lang.String getRootName()
Gets the name of the root UIComponent of this UIComponent. Returns null if there is none set.

Returns:
the name of the root UIComponent. null if there is none.

doTriggerPopMenu

public void doTriggerPopMenu(UIMouseEvent pMouseEvent)
Triggers popup menu to be shown.

Parameters:
pMouseEvent - the mouse event.

setPreferredSize

public void setPreferredSize(int pWidth,
                             int pHeight)
Set the preferred size with primitive types.

Parameters:
pWidth - the width.
pHeight - the height.

setMinimumSize

public void setMinimumSize(int pWidth,
                           int pHeight)
Set the minimum size with primitive types.

Parameters:
pWidth - the width.
pHeight - the height.

setMaximumSize

public void setMaximumSize(int pWidth,
                           int pHeight)
Set the maximum size with primitive types.

Parameters:
pWidth - the width.
pHeight - the height.

setLocation

public void setLocation(int pX,
                        int pY)
Set the location with primitive types.

Parameters:
pX - the width.
pY - the width.

setSize

public void setSize(int pWidth,
                    int pHeight)
Set the size with primitive types.

Parameters:
pWidth - the width.
pHeight - the height.

setBounds

public void setBounds(int pX,
                      int pY,
                      int pWidth,
                      int pHeight)
Set the bounds with primitive types.

Parameters:
pX - the width.
pY - the width.
pWidth - the width.
pHeight - the height.

getUIComponent

protected UIComponent<?> getUIComponent()
Gets the genui component, thats ui resource is added to the parents ui resource.

Returns:
the genui component, thats ui resource is added to the parents ui resource.

setUIComponent

protected void setUIComponent(UIComponent<?> pComponent)
Sets the genui component, thats ui resource is added to the parents ui resource.

Parameters:
pComponent - the genui component, thats ui resource is added to the parents ui resource.

getComponentUIResource

public IComponent getComponentUIResource()
Gets the component which will be added/removed to an UIContainer instead of this component. Thats needed to create complex Controls. Example Control: an extended Table Control with Toolbar. So a ToolbarPanel with Table inside -> Table is uiResource, ToolbarPanel is the componentUIResource The ToolbarPanel is used for add, so visibility, location, bounds, ... should address the componentUIResource The Table is the control, so focus, enable, font, ... should address the uiResource.

Returns:
the component which should be added/removed

getLocationOffset

protected IPoint getLocationOffset()
Gets the component which will be added/removed to an UIContainer instead of this component. Thats needed to create complex Controls. Example Control: an extended Table Control with Toolbar. So a ToolbarPanel with Table inside -> Table is uiResource, ToolbarPanel is the componentUIResource The ToolbarPanel is used for add, so visibility, location, bounds, ... should address the componentUIResource The Table is the control, so focus, enable, font, ... should address the uiResource.

Returns:
the component which should be added/removed

debug

public void debug(java.lang.Object... pInfo)
Logs debug information.

Parameters:
pInfo - the debug information

info

public void info(java.lang.Object... pInfo)
Logs information.

Parameters:
pInfo - the information

error

public void error(java.lang.Object... pInfo)
Logs error information.

Parameters:
pInfo - the error information

beforeAddNotify

public void beforeAddNotify(IComponent pParent)
Invoked before this component is added.

Parameters:
pParent - the parent

isBeforeNotified

public boolean isBeforeNotified()
Gets whether this component is notified before it was added.

Returns:
true this component is notified, false otherwise

addNotify

public void addNotify()
Makes this UIComponent displayable by adding it to an UIContainer. This method is called internally by the genui and should not be called directly.

See Also:
removeNotify(), isNotified()

isNotified

public boolean isNotified()
Determines whether this UIComponent is displayable. A component is displayable when it is added to an UIContainer.

An UIComponent is made displayable either when it is added to a displayable containment hierarchy or when its containment hierarchy is made displayable. A containment hierarchy is made displayable when its ancestor UIWindow is either packed or made visible.

An UIComponent is made undisplayable either when it is removed from a displayable containment hierarchy or when its containment hierarchy is made undisplayable. A containment hierarchy is made undisplayable when its ancestor UIWindow is disposed.

Returns:
true if the component is displayable, false otherwise
See Also:
UIContainer.add(IComponent, Object, int), UIContainer.remove(int), AbstractWindow.setVisible(boolean), AbstractWindow.pack(), AbstractWindow.dispose()

removeNotify

public void removeNotify()
Makes this UIComponent undisplayable by removing it to an UIContainer.

This method is called by the genui internally and should not be called directly. Code overriding this method should call super.removeNotify as the first line of the overriding method.

See Also:
addNotify(), isNotified()

getCurrentTranslation

protected TranslationMap getCurrentTranslation()
Gets the current translation mapping usable for this UIComponent.

Returns:
the current translation mapping

translate

public java.lang.String translate(java.lang.String pText)
Translates the given text with the avaliable translation. If this component has no translation, then the translation from the parent component will be used.

Specified by:
translate in interface ITranslator
Parameters:
pText - the text to translate
Returns:
the translated text or pText if no translation was found

updateTranslation

public void updateTranslation()
Notification for updating the translation. This method will be called when the UIComponent will be added to a displayable containment hierarchy, when its containment hierarchy is made displayable or the translation table will be changed.

See Also:
setTranslation(TranslationMap), addNotify()

doEventKey

public void doEventKey(UIKeyEvent pKeyEvent)
Dispatches the given UIKeyEvent to all EventHandlers that have subscribed to the Key of the event.

Parameters:
pKeyEvent - the UIKeyEvent to dispatch

eventKey

public KeyHandler<? super IKeyListener> eventKey(Key pKey)
The EventHandler for the given Key.

Parameters:
pKey - the Key whose EventHandler is returned
Returns:
the EventHandler for the given Key

isTranslationChanged

protected boolean isTranslationChanged()
Gets whether the translation was changed.

Returns:
true if translation was changed, false otherwise

invokeLater

public static void invokeLater(java.lang.Runnable pRunnable)
Causes pRunnable.run() to be executed asynchronously on the event dispatching thread. This will happen after all pending events have been processed. This method should be used when an application thread needs to update the GUI.

Parameters:
pRunnable - the asynchronous call
See Also:
invokeAndWait(Runnable)

invokeLater

public static void invokeLater(java.lang.Object pObject,
                               java.lang.String pMethod)
Causes pRunnable.run() to be executed asynchronously on the event dispatching thread. This will happen after all pending events have been processed. This method should be used when an application thread needs to update the GUI.

Parameters:
pObject - the object
pMethod - the asynchronous call
See Also:
invokeAndWait(Runnable)

invokeAndWait

public static void invokeAndWait(java.lang.Runnable pRunnable)
                          throws java.lang.Exception
Causes pRunnable.run() to be executed synchronously on the event dispatching thread. This call blocks until all pending events have been processed and (then) pRunnable.run() returns. This method should be used when an application thread needs to update the GUI.

Parameters:
pRunnable - the call
Throws:
java.lang.Exception - if the call caueses an exception

invokeAndWait

public static void invokeAndWait(java.lang.Object pRunnable,
                                 java.lang.String pMethod)
                          throws java.lang.Exception
Causes pRunnable.run() to be executed synchronously on the event dispatching thread. This call blocks until all pending events have been processed and (then) pRunnable.run() returns. This method should be used when an application thread needs to update the GUI.

Parameters:
pRunnable - the object
pMethod - the call
Throws:
java.lang.Exception - if the call caueses an exception

invokeInThread

public static java.lang.Thread invokeInThread(java.lang.Runnable pRunnable)
Causes pRunnable.run() to be executed asynchronously in a new thread. Action calls and UI Calls in the thread should be synchronized with the event dispatching thread by using invokeLater or invokeAndWait. This gives the IFactory implementation a chance to decide how and when to run the threads.

Parameters:
pRunnable - the call
Returns:
the thread

invokeInThread

public static java.lang.Thread invokeInThread(java.lang.Object pRunnable,
                                              java.lang.String pMethod)
Causes pRunnable.run() to be executed asynchronously in a new thread. Action calls and UI Calls in the thread should be synchronized with the event dispatching thread by using invokeLater or invokeAndWait. This gives the IFactory implementation a chance to decide how and when to run the threads.

Parameters:
pRunnable - the object
pMethod - the call
Returns:
the thread

createComponentName

protected java.lang.String createComponentName()
Creates a name for this UIComponent. The returned name needs to be unique in the current root/workscreen and is ideally, but not necessarily, prefixed with the sRootName, if there is any. Overriding classes should be aware that this method will be called in addNotify() and the returned name will only be assigned to the UIComponent if there isn't already a name set. Also stExistingNames can be used to find out if a name has already been assigned, and sRootName to get the root name. In rare cases stExistingNames and/or sRootName might be null when this method is called.

Returns:
a unique name for this UIComponent.
See Also:
getExistingNames(), getRootName(), incrementNameIfExists(String, Set, boolean)

createComponentNamePrefix

protected java.lang.String createComponentNamePrefix()
Creates a String consisting of the root name (if any) and the upper characters of the simple class name. That String can be used as a prefix if an extending class wants to provide a custom name. Example: Root is a workscreen with the name BookinWorkScreen and the current component is a label, the prefix will be NTWS1_L.

Returns:
the prefix.
See Also:
createComponentName()

getExistingNames

protected final java.util.Set<java.lang.String> getExistingNames()
Gets the Set which contains the already existing UIComponent names under the current root. Might be null if it was not set.

Returns:
the list of already existing names under the current root.

setDefaultName

protected void setDefaultName(java.lang.String pDefaultName)
Sets the default name for this UIComponent.

Parameters:
pDefaultName - the new default name.

setRootName

protected void setRootName(java.lang.String pRootName)
Sets the root name to the given one. This also resets the list of already existing names, making the current UIComponent the effective root for all naming of it's children.

Parameters:
pRootName - the new root name.
See Also:
getExistingNames(), getRootName()


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.