com.vaadin.terminal.gwt.client
Class ComponentState

java.lang.Object
  extended by com.vaadin.terminal.gwt.client.communication.SharedState
      extended by com.vaadin.terminal.gwt.client.ComponentState
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AbstractFieldState, AbstractLayoutState, AbstractMediaState, AbstractSplitPanelState, ButtonState, JavaScriptComponentState, LabelState, PanelState, RootState

public class ComponentState
extends SharedState

Default shared state implementation for UI components. State classes of concrete components should extend this class.

Since:
7.0
See Also:
Serialized Form

Constructor Summary
ComponentState()
           
 
Method Summary
 void addRegisteredEventListener(String eventListenerId)
          Adds an event listener id.
 String getCaption()
          Gets the caption of the component (typically shown by the containing layout).
 String getDebugId()
          Gets the debug id for the component.
 String getDescription()
          Gets the description of the component (typically shown as tooltip).
 String getErrorMessage()
          Returns the current error message for the component.
 String getHeight()
          Returns the component height as set by the server.
 URLReference getIcon()
           
 Set<String> getRegisteredEventListeners()
          Gets the identifiers for the event listeners that have been registered for the component (using an event id)
 List<String> getStyles()
          Gets the style names for the component.
 String getWidth()
          Returns the component width as set by the server.
 boolean hasDescription()
          Returns true if the component has a description.
 boolean hasStyles()
          Returns true if the component has user-defined styles.
 boolean isImmediate()
          Returns true if the component is in immediate mode.
 boolean isReadOnly()
          Returns true if the component is in read-only mode.
 boolean isUndefinedHeight()
          Returns true if the component height is undefined, false if defined (absolute or relative).
 boolean isUndefinedWidth()
          Returns true if the component width is undefined, false if defined (absolute or relative).
 boolean isVisible()
          Returns the visibility state of the component.
 void removeRegisteredEventListener(String eventIdentifier)
          Removes an event listener id.
 void setCaption(String caption)
          Sets the caption of the component (typically shown by the containing layout).
 void setDebugId(String debugId)
          Sets the debug id for the component.
 void setDescription(String description)
          Sets the description of the component (typically shown as tooltip).
 void setErrorMessage(String errorMessage)
          Sets the current error message for the component.
 void setHeight(String height)
          Sets the height of the component in the server format.
 void setIcon(URLReference icon)
           
 void setImmediate(boolean immediate)
          Sets or resets the immediate mode for a component.
 void setReadOnly(boolean readOnly)
          Sets or resets the read-only mode for a component.
 void setRegisteredEventListeners(Set<String> registeredEventListeners)
          Sets the identifiers for the event listeners that have been registered for the component (using an event id)
 void setStyles(List<String> styles)
          Sets the style names for the component.
 void setVisible(boolean visible)
          Sets the visibility state of the component.
 void setWidth(String width)
          Sets the width of the component in the server format.
 
Methods inherited from class com.vaadin.terminal.gwt.client.communication.SharedState
isEnabled, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentState

public ComponentState()
Method Detail

getHeight

public String getHeight()
Returns the component height as set by the server. Can be relative (containing the percent sign) or absolute, or empty string for undefined height.

Returns:
component height as defined by the server, not null

setHeight

public void setHeight(String height)
Sets the height of the component in the server format. Can be relative (containing the percent sign) or absolute, or null or empty string for undefined height.

Parameters:
height - component height

isUndefinedHeight

public boolean isUndefinedHeight()
Returns true if the component height is undefined, false if defined (absolute or relative).

Returns:
true if component height is undefined

getWidth

public String getWidth()
Returns the component width as set by the server. Can be relative (containing the percent sign) or absolute, or empty string for undefined height.

Returns:
component width as defined by the server, not null

setWidth

public void setWidth(String width)
Sets the width of the component in the server format. Can be relative (containing the percent sign) or absolute, or null or empty string for undefined width.

Parameters:
width - component width

isUndefinedWidth

public boolean isUndefinedWidth()
Returns true if the component width is undefined, false if defined (absolute or relative).

Returns:
true if component width is undefined

isReadOnly

public boolean isReadOnly()
Returns true if the component is in read-only mode.

Returns:
true if the component is in read-only mode
See Also:
Component.isReadOnly()

setReadOnly

public void setReadOnly(boolean readOnly)
Sets or resets the read-only mode for a component.

Parameters:
readOnly - new mode for the component
See Also:
com.vaadin.ui.Component#setReadOnly()

isImmediate

public boolean isImmediate()
Returns true if the component is in immediate mode.

Returns:
true if the component is in immediate mode
See Also:
VariableOwner.isImmediate()

setImmediate

public void setImmediate(boolean immediate)
Sets or resets the immediate mode for a component.

Parameters:
immediate - new mode for the component
See Also:
com.vaadin.terminal.VariableOwner#setImmediate()

hasStyles

public boolean hasStyles()
Returns true if the component has user-defined styles.

Returns:
true if the component has user-defined styles

getDescription

public String getDescription()
Gets the description of the component (typically shown as tooltip).

Returns:
component description (not null, can be empty string)
See Also:
AbstractComponent.getDescription()

setDescription

public void setDescription(String description)
Sets the description of the component (typically shown as tooltip).

Parameters:
description - new component description (can be null)
See Also:
AbstractComponent.setDescription(String)

hasDescription

public boolean hasDescription()
Returns true if the component has a description.

Returns:
true if the component has a description

getCaption

public String getCaption()
Gets the caption of the component (typically shown by the containing layout).

Returns:
component caption - can be null (no caption) or empty string (reserve space for an empty caption)
See Also:
Component.getCaption()

setCaption

public void setCaption(String caption)
Sets the caption of the component (typically shown by the containing layout).

Parameters:
caption - new component caption - can be null (no caption) or empty string (reserve space for an empty caption)
See Also:
Component.setCaption(String)

isVisible

public boolean isVisible()
Returns the visibility state of the component. Note that this state is related to the component only, not its parent. This might differ from what Component.isVisible() returns as this takes the hierarchy into account.

Returns:
The visibility state.

setVisible

public void setVisible(boolean visible)
Sets the visibility state of the component.

Parameters:
visible - The new visibility state.

getIcon

public URLReference getIcon()

setIcon

public void setIcon(URLReference icon)

getStyles

public List<String> getStyles()
Gets the style names for the component.

Returns:
A List of style names or null if no styles have been set.

setStyles

public void setStyles(List<String> styles)
Sets the style names for the component.

Parameters:
styles - A list containing style names

getDebugId

public String getDebugId()
Gets the debug id for the component. The debugId is added as DOM id for the component.

Returns:
The debug id for the component or null if not set

setDebugId

public void setDebugId(String debugId)
Sets the debug id for the component. The debugId is added as DOM id for the component.

Parameters:
debugId - The new debugId for the component or null for no debug id

getRegisteredEventListeners

public Set<String> getRegisteredEventListeners()
Gets the identifiers for the event listeners that have been registered for the component (using an event id)

Returns:
A set of event identifiers or null if no identifiers have been registered

setRegisteredEventListeners

public void setRegisteredEventListeners(Set<String> registeredEventListeners)
Sets the identifiers for the event listeners that have been registered for the component (using an event id)

Parameters:
registeredEventListeners - The new set of identifiers or null if no identifiers have been registered

addRegisteredEventListener

public void addRegisteredEventListener(String eventListenerId)
Adds an event listener id.

Parameters:
eventListenerId - The event identifier to add

removeRegisteredEventListener

public void removeRegisteredEventListener(String eventIdentifier)
Removes an event listener id.

Parameters:
eventListenerId - The event identifier to remove

getErrorMessage

public String getErrorMessage()
Returns the current error message for the component.

Returns:
HTML formatted error message to show for the component or null if none

setErrorMessage

public void setErrorMessage(String errorMessage)
Sets the current error message for the component. TODO this could use an object with more details about the error

Parameters:
errorMessage - HTML formatted error message to show for the component or null for none


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.