org.xulux.api.gui
Interface IWidget


public interface IWidget

The IWidget interface.

Version:
$Id: $
Author:
Martin van den Bemt

Method Summary
 void addChildWidget(IWidget widget)
          Doesn't do anything by default.
 void addDependency(java.lang.String widgetName)
           
 void addPropertyHandler(java.lang.String name, java.lang.String phases, IPropertyHandler propertyHandler)
          Add a propertyHandler
 void addXuluxListener(IXuluxListener listener)
          Add a xuluxlistener to the widget.
 boolean canBeRootWidget()
          Specifies if this widget can be a root widget, which means it can live on it's own without any parent.
 boolean canContainChildren()
           
 boolean canContainValue()
           
 void clear()
          Clears the field
 void destroy()
          Destroy a widget.
 void focus()
          Set the focus to this widget
 java.util.List getChildWidgets()
           
 java.util.List getDependencies()
          Get dependencies (dependend widgets ??)
 java.lang.String getField()
           
 java.lang.Object getGuiValue()
           
 java.lang.String getName()
           
 java.lang.Object getNativeWidget()
           
 IWidget getParent()
           
 IPart getPart()
           
 java.lang.String getPrefix()
           
 java.lang.Object getPreviousValue()
           
 java.util.Map getProperties()
          You can not use this HashMap to change properties, since it is a clone.
 java.lang.String getProperty(java.lang.String key)
          Return the specified property.
 IPropertyHandler getPropertyHandler(java.lang.String name)
           
 java.util.Map getPropertyHandlers()
           
 java.lang.String getProvider()
           
 IWidgetRectangle getRectangle()
           
 java.util.List getRules()
           
 java.lang.Object getValue()
           
 IWidgetInitializer getWidgetInitializer()
           
 java.lang.String getWidgetType()
           
 void handleProperties(java.lang.String phase)
          Handle the properties of a specific phase.
 void ignoreUse(boolean ignoreUse)
          Set if the use should be ignored.
 void initialize()
          Initializes the widget, based on the current settings
 boolean isEnabled()
          Is the widget disabled ?
 boolean isRefreshing()
          Specifies if the widget is currently refreshing.
 boolean isRequired()
           
 boolean isValidValue()
           
 boolean isValueEmpty()
           
 boolean isVisible()
          Is the widget hidden
 void refresh()
          refreshes the widget.
 void registerRule(IRule rule)
          Registers a rule in the widget and sets the owner if the rule extends Rule
 void setAutoRefresh(boolean autoRefresh)
          Specify if the widget should autorefresh when a property changes.
 void setContainerWidgetHandler(IContainerWidgetHandler containerWidgetHandler)
          Set the container widget handler for the widget
 void setEnabled(boolean enable)
          No state change should take place if the widget is already in a certain state.
 void setField(java.lang.String field)
          Sets the field.
 void setLazyProperty(java.lang.String key, java.lang.Object value)
          Set the property to the specified value or when value is null clear the property if it exists.
 void setName(java.lang.String name)
          Set the name of the widget
 void setParent(IWidget parent)
          Sets the parent of this widget.
 void setPart(IPart part)
          Set the applicationPart
 void setPosition(int x, int y)
          sets the position of the current widget (on the parent..)
 void setPrefix(java.lang.String prefix)
          Set the widget prefix
 void setProperty(java.lang.String key, java.lang.Object value)
          Set a property and refresh the widget if it is initialized.
 void setProvider(java.lang.String provider)
          Set the dataprovider for this widget
 void setRootWidget(boolean isRootWidget)
          Specifies if this widget is a part rootWidget
 void setSize(int width, int height)
          Sets the size of the current widget
 void setValue(java.lang.Object value)
          Set the value
 void setVisible(boolean visible)
          Set the component visible or invisible
 void setWidgetInitializer(IWidgetInitializer initializer)
          Set the widgetInitializer
 void setWidgetType(java.lang.String type)
           
 void updateWidget(IWidget widget)
          Updates the widget because another widget has been updated.
 

Method Detail

getProperty

java.lang.String getProperty(java.lang.String key)
Return the specified property. Use this method or do a getProperties().get(key.toLowerCase()); , since all keys are stored in lowercase.

Parameters:
key - the property to get. This is case insensitive.
Returns:
the value found or null when no value is found

getChildWidgets

java.util.List getChildWidgets()
Returns:
the list of childwidgets. Defaults to null

getNativeWidget

java.lang.Object getNativeWidget()

destroy

void destroy()
Destroy a widget. Frees up all resources taken by it.


initialize

void initialize()
Initializes the widget, based on the current settings


isValueEmpty

boolean isValueEmpty()
Returns:
if the GUI value of the current field is empty or not.

canContainValue

boolean canContainValue()
Returns:
if the widget CAN contain a value

focus

void focus()
Set the focus to this widget


getGuiValue

java.lang.Object getGuiValue()
Returns:
the value from the native widget

canContainChildren

boolean canContainChildren()
Returns:
if the widget can contain children or not

getPart

IPart getPart()
Returns:
the part

getName

java.lang.String getName()
Returns:
the name of the widget

setName

void setName(java.lang.String name)
Set the name of the widget

Parameters:
name -

getRules

java.util.List getRules()
Returns:
a list with the rules for that widget

setParent

void setParent(IWidget parent)
Sets the parent of this widget.

Parameters:
parent -

getParent

IWidget getParent()
Returns:
the parent widget or null when there is no parent.

canBeRootWidget

boolean canBeRootWidget()
Specifies if this widget can be a root widget, which means it can live on it's own without any parent. Returns false by default, so you have to override it when it can (normally only windows can though)

Returns:
true when it can

getValue

java.lang.Object getValue()
Returns:
the value associated with this widget

getProvider

java.lang.String getProvider()
Returns:
the provider name for this widget. If the provider is not set, it will return the provider of the part. If the provider name is none, it will return null.

getField

java.lang.String getField()
Returns:
the field.

updateWidget

void updateWidget(IWidget widget)
Updates the widget because another widget has been updated.

Parameters:
widget -

setValue

void setValue(java.lang.Object value)
Set the value

Parameters:
value - the value to set

getPreviousValue

java.lang.Object getPreviousValue()
Returns:
the previous value of the widget

refresh

void refresh()
refreshes the widget. By default this method uses propertyhandlers for refreshing the widget. The previous way of doing a refresh was to add all code to the implemented refresh method. If setProperty can find a propertyhandler, it will use that and call the empty method.


setPart

void setPart(IPart part)
Set the applicationPart

Parameters:
part -

clear

void clear()
Clears the field


addChildWidget

void addChildWidget(IWidget widget)
Doesn't do anything by default. Override this when there canHaveChildren returns true.


setRootWidget

void setRootWidget(boolean isRootWidget)
Specifies if this widget is a part rootWidget

Parameters:
isRootWidget -

registerRule

void registerRule(IRule rule)
Registers a rule in the widget and sets the owner if the rule extends Rule

Parameters:
rule -

getWidgetType

java.lang.String getWidgetType()
Returns:
- the widgetType as defined in GuiDefaults.xml

setLazyProperty

void setLazyProperty(java.lang.String key,
                     java.lang.Object value)
Set the property to the specified value or when value is null clear the property if it exists. It will do nothing when the value it currently knows is the same as the value passed in. If the key is null, it will return immidiately

Parameters:
key - case insensitive value
value - case insensitive value

isRefreshing

boolean isRefreshing()
Specifies if the widget is currently refreshing. Check this to prevent infinite loops when another field is calling this widget again.

Returns:
true when currently refreshing and false when not

setEnabled

void setEnabled(boolean enable)
No state change should take place if the widget is already in a certain state.

Parameters:
enable - false disables it, true, enables it

ignoreUse

void ignoreUse(boolean ignoreUse)
Set if the use should be ignored. Defaults to false.

Parameters:
ignoreUse -

addXuluxListener

void addXuluxListener(IXuluxListener listener)
Add a xuluxlistener to the widget.

Parameters:
listener -

setProperty

void setProperty(java.lang.String key,
                 java.lang.Object value)
Set a property and refresh the widget if it is initialized.

Parameters:
key - the key
value - the object

isEnabled

boolean isEnabled()
Is the widget disabled ?


isVisible

boolean isVisible()
Is the widget hidden


setVisible

void setVisible(boolean visible)
Set the component visible or invisible

Parameters:
visible -

getRectangle

IWidgetRectangle getRectangle()
Returns:
the rectangle for the widget, never null.

setSize

void setSize(int width,
             int height)
Sets the size of the current widget

Parameters:
width - - the width of the widget
height - - the height of the widget

setPosition

void setPosition(int x,
                 int y)
sets the position of the current widget (on the parent..)

Parameters:
x - - the x position on the parant
y - - the y position on the parent

setField

void setField(java.lang.String field)
Sets the field.

Parameters:
field - The field to set

setProvider

void setProvider(java.lang.String provider)
Set the dataprovider for this widget

Parameters:
provider - the provider name for this widget

getProperties

java.util.Map getProperties()
You can not use this HashMap to change properties, since it is a clone. You need to use setProperty for that.

Returns:
the HashMap with the properties

getWidgetInitializer

IWidgetInitializer getWidgetInitializer()
Returns:
the widget initializer.

isRequired

boolean isRequired()
Returns:
if the field is a required field

isValidValue

boolean isValidValue()
Returns:
if the widget contains a validvalue

setPrefix

void setPrefix(java.lang.String prefix)
Set the widget prefix

Parameters:
prefix - the prefix

getPrefix

java.lang.String getPrefix()
Returns:
the prefix or null if there isn't one.

getDependencies

java.util.List getDependencies()
Get dependencies (dependend widgets ??)

Returns:

addDependency

void addDependency(java.lang.String widgetName)

setWidgetType

void setWidgetType(java.lang.String type)

addPropertyHandler

void addPropertyHandler(java.lang.String name,
                        java.lang.String phases,
                        IPropertyHandler propertyHandler)
Add a propertyHandler

Parameters:
name - the name (will overwrite a handler with the same name!
phases - the phase this property is needed in, or comma delimited list of phases.
propertyHandler - the propertyhandler to add.

getPropertyHandler

IPropertyHandler getPropertyHandler(java.lang.String name)
Parameters:
name - the name of the property
Returns:
the propertyhandler associated with the name

getPropertyHandlers

java.util.Map getPropertyHandlers()
Returns:
the instance of the map that contains the property handlers for this widget or null when no propertyhandlers are registered

setWidgetInitializer

void setWidgetInitializer(IWidgetInitializer initializer)
Set the widgetInitializer

Parameters:
initializer - the initializer

setContainerWidgetHandler

void setContainerWidgetHandler(IContainerWidgetHandler containerWidgetHandler)
Set the container widget handler for the widget

Parameters:
containerWidgetHandler - the containerwidgethandler instance.

handleProperties

void handleProperties(java.lang.String phase)
Handle the properties of a specific phase.

Parameters:
phase - the phase to handle the properties for.

setAutoRefresh

void setAutoRefresh(boolean autoRefresh)
Specify if the widget should autorefresh when a property changes. Should default to false

Parameters:
autoRefresh -


Copyright © 2002-2007 Martin van den Bemt. All Rights Reserved.