com.extjs.gxt.ui.client.widget
Class Component

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.extjs.gxt.ui.client.widget.Component
All Implemented Interfaces:
Observable, com.google.gwt.user.client.EventListener
Direct Known Subclasses:
BoxComponent, Button, DataListItem, DataViewItem, Document, FramePanel, Header, Item, PagingToolBar, StatusBar, TabItem.HeaderItem, TableItem, ToolItem, TreeItem

public abstract class Component
extends com.google.gwt.user.client.ui.Widget
implements Observable

Base class for GXT components. All subclasses of Component can automatically participate in the standard GXT component lifecycle of creation, attach and detach. They also have automatic support for basic hide/show and enable/disable behavior. Component allows any subclass to be lazy-rendered into any GXT Container. Components added to a GWT Panel will be rendered when inserted. All visual widgets that require rendering into a layout should subclass Component (or BoxComponent if managed box model handling is required).

The following 4 methods inherited from UIObject (setSize, setWidth, setHeight, setPixelSize) have been overridden and do nothing. Any component whose size can change should subclass BoxComponent.

All components are registered and unregistred with the @link ComponentManager when the are attached and detached.

Events:
Enable : ComponentEvent(component)
Fires after the component is enabled.
Disable : ComponentEvent(component)
Fires after the component is disabled.
BeforeHide : ComponentEvent(component)
Fires before the component is hidden. Listeners can set the doit field to false to cancel the action.
BeforeShow : ComponentEvent(component)
Fires before the component is shown. Listeners can set the doit field to false to cancel the action.
Hide : ComponentEvent(component)
Fires after the component is hidden.
Show : ComponentEvent(component)
Fires after the component is shown.
Attach : ComponentEvent(component)
Fires after the component is attached.
Detach : ComponentEvent(component)
Fires after the component is detached.
BeforeRender : ComponentEvent(component)
Fires before the component is rendered. Listeners can set the doit field to false to cancel the action.
Render : ComponentEvent(component)
Fires after the component is rendered.
BrowserEvent : ComponentEvent(component, event)
Fires on any browser event the component receives. Listners will be called prior to any event processing and before onComponentEvent(ComponentEvent) is called. Listeners can set the doit field to false to cancel the processing of the event.
BeforeStateRestore : ComponentEvent(component, state)
Fires before the state of the component is restored. Listeners can set the doit field to false to cancel the action.
StateRestore : ComponentEvent(component, state)
Fires after the state of the component is restored.
StateRestore : ComponentEvent(component, state)
Fires before the state of the component is saved to the configured state provider.
StateSave : ComponentEvent(component, state)
Fires after the state of the component is saved to the configured state provider.

See Also:
ComponentManager

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
Component()
          Creates a new component..
 
Method Summary
 void addListener(int eventType, Listener listener)
          Appends an event handler to this component.
 void addPlugin(ComponentPlugin plugin)
          Adds a component plugin.
 void addStyleName(java.lang.String style)
          Adds a CSS style name to the component's underlying element.
 void addWidgetListener(WidgetListener listener)
          Adds a listener to receive widget events.
 void disable()
          Disable this component.
 void disableEvents(boolean disable)
          True to disable event processing.
 void disableTextSelection(boolean disable)
          Enables and disables text selection for the component.
 El el()
          Returns the component's el instance.
 void enable()
          Enable this component.
 void enableEvents(boolean enable)
          Enables or disables event processing.
 boolean fireEvent(int type)
          Fires an event with the given event type.
 boolean fireEvent(int eventType, BaseEvent be)
          Fires an event.
 boolean fireEvent(int type, ComponentEvent ce)
          Fires the specified event with the given event type.
 El fly(com.google.gwt.user.client.Element elem)
          Returns the global flyweight instance.
 void focus()
          Try to focus this component.
 java.lang.String getBaseStyle()
          Returns the component's base style.
 boolean getBorders()
          Returns the component's border state.
 java.lang.Object getData()
          Deprecated. Use getData(String)
<X> X
getData(java.lang.String key)
          Returns the application defined property for the given name, or null if it has not been set.
 com.google.gwt.user.client.Element getElement()
           
 java.lang.String getId()
          Returns the id of this component.
 java.lang.String getItemId()
          Returns the item id of this component.
 ModelData getModel()
          Returns the component's model.
 java.util.Map<java.lang.String,java.lang.Object> getState()
          Returns the component's state.
 ToolTip getToolTip()
          Returns the component's tool tip.
 void hide()
          Hide this component.
 void hideToolTip()
          Hides the component's tool tip (if one exists).
 boolean isDisabledEvents()
          Returns true if events are disabled.
 boolean isEnabled()
          Returns true if the component is enabled.
 boolean isRendered()
          Returns true if the component is rendered.
 boolean isVisible()
          Returns true if the component is visible.
 void onBrowserEvent(com.google.gwt.user.client.Event event)
          Components delegate event handling to onComponentEvent(ComponentEvent).
 void onComponentEvent(ComponentEvent ce)
          Any events a component receives will be forwarded to this method.
 void recalculate()
          Called when the component is in a LayoutContainer and the container's layout executes.
 void removeAllListeners()
          Removes all listeners.
 void removeFromParent()
           
 void removeListener(int eventType, Listener listener)
          Removes a listener.
 void removeStyleName(java.lang.String style)
          Removes a CSS style name from the component's underlying element.
 void removeWidgetListener(WidgetListener listener)
          Removes a listener.
 void render(com.google.gwt.user.client.Element target)
          Renders the element.
 void render(com.google.gwt.user.client.Element target, int index)
          Renders the element.
 void saveState()
          Saves the component's current state.
 void setBorders(boolean show)
          Adds or removes a border.
 void setData(java.lang.Object data)
          Deprecated. use setData(String, Object)
 void setData(java.lang.String key, java.lang.Object data)
          Sets the application defined property with the given name.
 void setElement(com.google.gwt.user.client.Element elem)
           
 void setEnabled(boolean enabled)
          Convenience function for setting disabled/enabled by boolean.
 void setEnableState(boolean enable)
          Sets whether the component's state is enabled (defaults to true).
 void setHeight(java.lang.String height)
          Overrides UIObject and does nothing.
 void setId(java.lang.String id)
          Sets the component's id.
 void setIntStyleAttribute(java.lang.String attr, int value)
          Sets a style attribute.
 void setItemId(java.lang.String id)
          Sets the component's item id.
 void setPixelSize(int width, int height)
          Overrides UIObject and does nothing.
 void setSize(java.lang.String width, java.lang.String height)
          Overrides UIObject and does nothing.
 void setStyleAttribute(java.lang.String attr, java.lang.String value)
          Sets a style attribute.
 void setStyleName(java.lang.String style)
           
 void setTitle(java.lang.String title)
           
 void setToolTip(java.lang.String text)
          Sets the component's tool tip.
 void setToolTip(ToolTipConfig config)
          Sets the component's tool tip with the given config.
 void setVisible(boolean visible)
          Convenience function to hide or show this component by boolean.
 void setWidth(java.lang.String width)
          Overrides UIObject and does nothing.
 void show()
          Show this component.
 void sinkEvents(int eventBitsToAdd)
           
 java.lang.String toString()
           
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, setStylePrimaryName, setVisible, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Component

public Component()
Creates a new component..

Method Detail

addListener

public void addListener(int eventType,
                        Listener listener)
Appends an event handler to this component.

Specified by:
addListener in interface Observable
Parameters:
eventType - the eventType
listener - the listener to be added

addPlugin

public void addPlugin(ComponentPlugin plugin)
Adds a component plugin.

Parameters:
plugin - the component plugin

addStyleName

public void addStyleName(java.lang.String style)
Adds a CSS style name to the component's underlying element.

Overrides:
addStyleName in class com.google.gwt.user.client.ui.UIObject
Parameters:
style - the CSS style name to add

addWidgetListener

public void addWidgetListener(WidgetListener listener)
Adds a listener to receive widget events.

Parameters:
listener - the listener to be added

disable

public void disable()
Disable this component. Fires the Disable event.


disableEvents

public void disableEvents(boolean disable)
True to disable event processing.

Parameters:
disable - true to disable

disableTextSelection

public void disableTextSelection(boolean disable)
Enables and disables text selection for the component.

Parameters:
disable - true to disable text selection

el

public El el()
Returns the component's el instance.

Returns:
the el instance

enable

public void enable()
Enable this component. Fires the Enable event.


enableEvents

public void enableEvents(boolean enable)
Enables or disables event processing.

Parameters:
enable - the enable state

fireEvent

public boolean fireEvent(int type)
Fires an event with the given event type.

Parameters:
type - the event type
Returns:
false if any listeners return false

fireEvent

public boolean fireEvent(int eventType,
                         BaseEvent be)
Description copied from interface: Observable
Fires an event.

Specified by:
fireEvent in interface Observable
Parameters:
eventType - eventType the event type
be - the base event
Returns:
true if any listeners cancel the event.

fireEvent

public boolean fireEvent(int type,
                         ComponentEvent ce)
Fires the specified event with the given event type.

Parameters:
type - the event type
ce - the base event
Returns:
false if any listeners return false

isDisabledEvents

public boolean isDisabledEvents()
Returns true if events are disabled.

Returns:
true if events disabled

fly

public El fly(com.google.gwt.user.client.Element elem)
Returns the global flyweight instance.

Parameters:
elem - the new wrapped dom element
Returns:
the global flyweight instance

focus

public void focus()
Try to focus this component. Fires the Focus event.


getBaseStyle

public java.lang.String getBaseStyle()
Returns the component's base style.

Returns:
the base style

getBorders

public boolean getBorders()
Returns the component's border state.

Returns:
true if borders are visisble

getData

public java.lang.Object getData()
Deprecated. Use getData(String)

Returns the application defined data associated with the component, or null if it has not been set.

Returns:
the data

getData

public <X> X getData(java.lang.String key)
Returns the application defined property for the given name, or null if it has not been set.

Parameters:
key - the name of the property
Returns:
the value or null if it has not been set

getElement

public com.google.gwt.user.client.Element getElement()
Overrides:
getElement in class com.google.gwt.user.client.ui.UIObject

getId

public java.lang.String getId()
Returns the id of this component. A new id is generated if an id has not been set.

Returns:
the component's id

getItemId

public java.lang.String getItemId()
Returns the item id of this component. Unlike the component's id, the item id does not have to be unique.

Returns:
the component's item id

getModel

public ModelData getModel()
Returns the component's model.

Returns:
the model

getState

public java.util.Map<java.lang.String,java.lang.Object> getState()
Returns the component's state.

Returns:
the state

getToolTip

public ToolTip getToolTip()
Returns the component's tool tip.

Returns:
the tool tip

hide

public void hide()
Hide this component. Fires the BeforeHide event before the component is hidden, the fires the Hide event after the component is hidden.


hideToolTip

public void hideToolTip()
Hides the component's tool tip (if one exists).


isEnabled

public boolean isEnabled()
Returns true if the component is enabled.

Returns:
the enabled state

isRendered

public boolean isRendered()
Returns true if the component is rendered.

Returns:
the rendered state

isVisible

public boolean isVisible()
Returns true if the component is visible.

Overrides:
isVisible in class com.google.gwt.user.client.ui.UIObject

onBrowserEvent

public void onBrowserEvent(com.google.gwt.user.client.Event event)
Components delegate event handling to onComponentEvent(ComponentEvent). Sublcasses should not override.

Specified by:
onBrowserEvent in interface com.google.gwt.user.client.EventListener
Overrides:
onBrowserEvent in class com.google.gwt.user.client.ui.Widget
Parameters:
event - the dom event

onComponentEvent

public void onComponentEvent(ComponentEvent ce)
Any events a component receives will be forwarded to this method. Subclasses should override as needed. The onBrowserEvent(com.google.gwt.user.client.Event) method should not be overridden or modified.

Parameters:
ce - the base event

recalculate

public void recalculate()
Called when the component is in a LayoutContainer and the container's layout executes. This method will not be called on container instances. Default implementation does nothing.


removeAllListeners

public void removeAllListeners()
Removes all listeners.

Specified by:
removeAllListeners in interface Observable

removeFromParent

public void removeFromParent()
Overrides:
removeFromParent in class com.google.gwt.user.client.ui.Widget

removeListener

public void removeListener(int eventType,
                           Listener listener)
Removes a listener.

Specified by:
removeListener in interface Observable
Parameters:
eventType - the event type
listener - the listener to be removed

removeStyleName

public void removeStyleName(java.lang.String style)
Removes a CSS style name from the component's underlying element.

Overrides:
removeStyleName in class com.google.gwt.user.client.ui.UIObject
Parameters:
style - the CSS style name to remove

removeWidgetListener

public void removeWidgetListener(WidgetListener listener)
Removes a listener.

Parameters:
listener - the listener to be removed

render

public void render(com.google.gwt.user.client.Element target)
Renders the element. Typically, this method does not need to be called directly. A component will rendered by its parent if it is a container, or rendered when attached if added to a gwt panel.

Parameters:
target - the element this component should be rendered into

render

public void render(com.google.gwt.user.client.Element target,
                   int index)
Renders the element. Typically, this method does not need to be called directly. A component will rendered by its parent if it is a container, or rendered when attached if added to a gwt panel.

Parameters:
target - the element this component should be rendered into
index - the index within the container before which this component will be inserted (defaults to appending to the end of the container if value is -1)

saveState

public void saveState()
Saves the component's current state.


setBorders

public void setBorders(boolean show)
Adds or removes a border. The style name 'x-border' is added to the widget to display a border.

Parameters:
show - true to display a border

setData

public void setData(java.lang.Object data)
Deprecated. use setData(String, Object)

Sets the application defined component data.

Parameters:
data - the widget data

setData

public void setData(java.lang.String key,
                    java.lang.Object data)
Sets the application defined property with the given name.

Parameters:
key - the name of the property
data - the new value for the property

setElement

public void setElement(com.google.gwt.user.client.Element elem)
Overrides:
setElement in class com.google.gwt.user.client.ui.UIObject

setEnabled

public void setEnabled(boolean enabled)
Convenience function for setting disabled/enabled by boolean.

Parameters:
enabled - the enabled state

setEnableState

public void setEnableState(boolean enable)
Sets whether the component's state is enabled (defaults to true).

Parameters:
enable - true to enable

setHeight

public void setHeight(java.lang.String height)
Overrides UIObject and does nothing.

Overrides:
setHeight in class com.google.gwt.user.client.ui.UIObject

setId

public void setId(java.lang.String id)
Sets the component's id.

Parameters:
id - the new id

setIntStyleAttribute

public void setIntStyleAttribute(java.lang.String attr,
                                 int value)
Sets a style attribute.

Parameters:
attr - the attribute
value - the attribute value

setItemId

public void setItemId(java.lang.String id)
Sets the component's item id.

Parameters:
id - the item id

setPixelSize

public void setPixelSize(int width,
                         int height)
Overrides UIObject and does nothing.

Overrides:
setPixelSize in class com.google.gwt.user.client.ui.UIObject

setSize

public void setSize(java.lang.String width,
                    java.lang.String height)
Overrides UIObject and does nothing.

Overrides:
setSize in class com.google.gwt.user.client.ui.UIObject

setStyleAttribute

public void setStyleAttribute(java.lang.String attr,
                              java.lang.String value)
Sets a style attribute.

Parameters:
attr - the attribute
value - the attribute value

setStyleName

public void setStyleName(java.lang.String style)
Overrides:
setStyleName in class com.google.gwt.user.client.ui.UIObject

setTitle

public void setTitle(java.lang.String title)
Overrides:
setTitle in class com.google.gwt.user.client.ui.UIObject

setToolTip

public void setToolTip(java.lang.String text)
Sets the component's tool tip.

Parameters:
text - the text

setToolTip

public void setToolTip(ToolTipConfig config)
Sets the component's tool tip with the given config.

Parameters:
config - the tool tip config

setVisible

public void setVisible(boolean visible)
Convenience function to hide or show this component by boolean.

Overrides:
setVisible in class com.google.gwt.user.client.ui.UIObject
Parameters:
visible - the visible state

setWidth

public void setWidth(java.lang.String width)
Overrides UIObject and does nothing.

Overrides:
setWidth in class com.google.gwt.user.client.ui.UIObject

show

public void show()
Show this component. Fires the BeforeShow event before the component is made visible, then fires the Show event after the component is visible.


sinkEvents

public void sinkEvents(int eventBitsToAdd)
Overrides:
sinkEvents in class com.google.gwt.user.client.ui.UIObject

toString

public java.lang.String toString()
Overrides:
toString in class com.google.gwt.user.client.ui.UIObject