com.vaadin.client.ui
Class AbstractComponentConnector

java.lang.Object
  extended by com.vaadin.client.ui.AbstractConnector
      extended by com.vaadin.client.ui.AbstractComponentConnector
All Implemented Interfaces:
com.google.gwt.event.shared.EventHandler, StateChangeEvent.StateChangeHandler, ComponentConnector, ServerConnector, com.vaadin.shared.Connector, java.io.Serializable
Direct Known Subclasses:
AbstractColorPickerConnector, AbstractFieldConnector, AbstractHasComponentsConnector, BrowserFrameConnector, ButtonConnector, CalendarConnector, ColorPickerGradientConnector, ColorPickerGridConnector, EmbeddedConnector, FlashConnector, ImageConnector, JavaScriptComponentConnector, LabelConnector, LegacyConnector, LinkConnector, MediaBaseConnector, MenuBarConnector, NativeButtonConnector, TreeConnector, UnknownComponentConnector, UploadConnector

public abstract class AbstractComponentConnector
extends AbstractConnector
implements ComponentConnector

See Also:
Serialized Form

Constructor Summary
AbstractComponentConnector()
          Default constructor
 
Method Summary
protected  Widget createWidget()
          Creates and returns the widget for this VPaintableWidget.
 boolean delegateCaptionHandling()
          Return true if parent handles caption, false if the paintable handles the caption itself.
 void flush()
          Called for the active (focused) connector when a situation occurs that the focused connector might have buffered changes which need to be processed before other activity takes place.
protected  Icon getIcon()
          Gets the icon set for this component.
protected  java.lang.String getIconUri()
          Gets the URI of the icon set for this component.
 LayoutManager getLayoutManager()
           
 com.vaadin.shared.AbstractComponentState getState()
          Returns the shared state object for this connector.
 TooltipInfo getTooltipInfo(Element element)
          Gets the tooltip info for the given element.
 Widget getWidget()
          Returns the widget associated with this paintable.
 boolean hasTooltip()
          Check whether there might be a tooltip for this component.
 boolean isReadOnly()
          Deprecated. 
static boolean isRealUpdate(UIDL uidl)
          Deprecated. 
 boolean isRelativeHeight()
          Returns true if the height of this paintable is currently relative.
 boolean isRelativeWidth()
          Returns true if the width of this paintable is currently relative.
 boolean isUndefinedHeight()
          Returns true if the height of this paintable is currently undefined.
 boolean isUndefinedWidth()
          Returns true if the width of this paintable is currently undefined.
 void onStateChanged(StateChangeEvent stateChangeEvent)
          Notifies the event handler that the state has changed.
 void onUnregister()
          Event called when connector has been unregistered.
 void setWidgetEnabled(boolean widgetEnabled)
          Sets the enabled state of the widget associated to this connector.
protected  void setWidgetStyleName(java.lang.String styleName, boolean add)
          This is used to add / remove state related style names from the widget.
protected  void setWidgetStyleNameWithPrefix(java.lang.String prefix, java.lang.String styleName, boolean add)
          Deprecated. This will be removed once styles are no longer added with prefixes.
protected  void updateComponentSize()
          Updates the component size based on the shared state, invoking the layout manager if necessary.
protected  void updateComponentSize(java.lang.String newWidth, java.lang.String newHeight)
          Updates the component size, invoking the layout manager if necessary.
 void updateEnabledState(boolean enabledState)
           
protected  void updateWidgetSize(java.lang.String newWidth, java.lang.String newHeight)
          Updates the DOM size of this connector's widget.
protected  void updateWidgetStyleNames()
          Updates the user defined, read-only and error style names for the widget based the shared state.
 
Methods inherited from class com.vaadin.client.ui.AbstractConnector
addStateChangeHandler, addStateChangeHandler, createState, doInit, ensureHandlerManager, fireEvent, forceStateChange, getChildren, getConnection, getConnectorId, getParent, getResourceUrl, getRpcImplementations, getRpcProxy, getStateType, hasEventListener, init, isEnabled, registerRpc, removeStateChangeHandler, removeStateChangeHandler, setChildren, setParent, unregisterRpc
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.client.ServerConnector
addStateChangeHandler, addStateChangeHandler, doInit, fireEvent, getChildren, getConnection, getParent, getRpcImplementations, hasEventListener, isEnabled, removeStateChangeHandler, removeStateChangeHandler, setChildren, setParent
 
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
 

Constructor Detail

AbstractComponentConnector

public AbstractComponentConnector()
Default constructor

Method Detail

createWidget

protected Widget createWidget()
Creates and returns the widget for this VPaintableWidget. This method should only be called once when initializing the paintable.

You should typically not override this method since the framework by default generates an implementation that uses GWT#create(Class) to create a widget of the same type as returned by the most specific override of getWidget(). If you do override the method, you can't call super.createWidget() since the metadata needed for that implementation is not generated if there's an override of the method.

Returns:
a new widget instance to use for this component connector

getWidget

public Widget getWidget()
Returns the widget associated with this paintable. The widget returned by this method must not changed during the life time of the paintable.

Specified by:
getWidget in interface ComponentConnector
Returns:
The widget associated with this paintable

isRealUpdate

@Deprecated
public static boolean isRealUpdate(UIDL uidl)
Deprecated. 


getState

public com.vaadin.shared.AbstractComponentState getState()
Description copied from class: AbstractConnector
Returns the shared state object for this connector. Override this method to define the shared state type for your connector.

Specified by:
getState in interface ComponentConnector
Specified by:
getState in interface ServerConnector
Overrides:
getState in class AbstractConnector
Returns:
the current shared state (never null)

onStateChanged

public void onStateChanged(StateChangeEvent stateChangeEvent)
Description copied from interface: StateChangeEvent.StateChangeHandler
Notifies the event handler that the state has changed.

Specified by:
onStateChanged in interface StateChangeEvent.StateChangeHandler
Overrides:
onStateChanged in class AbstractConnector
Parameters:
stateChangeEvent - the state change event with details about the change

setWidgetEnabled

public void setWidgetEnabled(boolean widgetEnabled)
Description copied from interface: ComponentConnector
Sets the enabled state of the widget associated to this connector.

Specified by:
setWidgetEnabled in interface ComponentConnector
Parameters:
widgetEnabled - true if the widget should be enabled, false otherwise

updateComponentSize

protected void updateComponentSize()
Updates the component size based on the shared state, invoking the layout manager if necessary.


updateComponentSize

protected void updateComponentSize(java.lang.String newWidth,
                                   java.lang.String newHeight)
Updates the component size, invoking the layout manager if necessary.

Parameters:
newWidth - The new width as a CSS string. Cannot be null.
newHeight - The new height as a CSS string. Cannot be null.

updateWidgetSize

protected void updateWidgetSize(java.lang.String newWidth,
                                java.lang.String newHeight)
Updates the DOM size of this connector's widget.

Parameters:
newWidth - The new width as a CSS string. Cannot be null.
newHeight - The new height as a CSS string. Cannot be null.
Since:
7.1.15

isRelativeHeight

public boolean isRelativeHeight()
Description copied from interface: ComponentConnector
Returns true if the height of this paintable is currently relative. If the height is relative, the actual height of the paintable is a percentage of the size allocated to it by its parent.

Specified by:
isRelativeHeight in interface ComponentConnector
Returns:
true if the width is undefined, else false

isRelativeWidth

public boolean isRelativeWidth()
Description copied from interface: ComponentConnector
Returns true if the width of this paintable is currently relative. If the width is relative, the actual width of the paintable is a percentage of the size allocated to it by its parent.

Specified by:
isRelativeWidth in interface ComponentConnector
Returns:
true if the width is undefined, else false

isUndefinedHeight

public boolean isUndefinedHeight()
Description copied from interface: ComponentConnector
Returns true if the height of this paintable is currently undefined. If the height is undefined, the actual height of the paintable is defined by its contents.

Specified by:
isUndefinedHeight in interface ComponentConnector
Returns:
true if the height is undefined, else false

isUndefinedWidth

public boolean isUndefinedWidth()
Description copied from interface: ComponentConnector
Returns true if the width of this paintable is currently undefined. If the width is undefined, the actual width of the paintable is defined by its contents.

Specified by:
isUndefinedWidth in interface ComponentConnector
Returns:
true if the width is undefined, else false

delegateCaptionHandling

public boolean delegateCaptionHandling()
Description copied from interface: ComponentConnector
Return true if parent handles caption, false if the paintable handles the caption itself.

This should always return true and all components should let the parent handle the caption and use other attributes for internal texts in the component

Specified by:
delegateCaptionHandling in interface ComponentConnector
Returns:
true if caption handling is delegated to the parent, false if parent should not be allowed to render caption

updateWidgetStyleNames

protected void updateWidgetStyleNames()
Updates the user defined, read-only and error style names for the widget based the shared state. User defined style names are prefixed with the primary style name of the widget returned by getWidget()

This method can be overridden to provide additional style names for the component, for example see AbstractFieldConnector.updateWidgetStyleNames()


setWidgetStyleName

protected void setWidgetStyleName(java.lang.String styleName,
                                  boolean add)
This is used to add / remove state related style names from the widget.

Override this method for example if the style name given here should be updated in another widget in addition to the one returned by the getWidget().

Parameters:
styleName - the style name to be added or removed
add - true to add the given style, false to remove it

setWidgetStyleNameWithPrefix

@Deprecated
protected void setWidgetStyleNameWithPrefix(java.lang.String prefix,
                                                       java.lang.String styleName,
                                                       boolean add)
Deprecated. This will be removed once styles are no longer added with prefixes.

This is used to add / remove state related prefixed style names from the widget.

Override this method if the prefixed style name given here should be updated in another widget in addition to the one returned by the Connector's getWidget(), or if the prefix should be different. For example see PopupDateFieldConnector.setWidgetStyleNameWithPrefix(String, String, boolean)

Parameters:
styleName - the style name to be added or removed
add - true to add the given style, false to remove it

isReadOnly

@Deprecated
public boolean isReadOnly()
Deprecated. 

Description copied from interface: ComponentConnector
Checks if the connector is read only.

Specified by:
isReadOnly in interface ComponentConnector
Returns:
true

getLayoutManager

public LayoutManager getLayoutManager()
Specified by:
getLayoutManager in interface ComponentConnector

updateEnabledState

public void updateEnabledState(boolean enabledState)
Specified by:
updateEnabledState in interface ServerConnector
Overrides:
updateEnabledState in class AbstractConnector

onUnregister

public void onUnregister()
Description copied from interface: ServerConnector
Event called when connector has been unregistered.

Specified by:
onUnregister in interface ServerConnector
Overrides:
onUnregister in class AbstractConnector

getTooltipInfo

public TooltipInfo getTooltipInfo(Element element)
Description copied from interface: ComponentConnector
Gets the tooltip info for the given element.

When overriding this method, ComponentConnector.hasTooltip() should also be overridden to return true in all situations where this method might return a non-empty result.

Specified by:
getTooltipInfo in interface ComponentConnector
Parameters:
element - The element to lookup a tooltip for
Returns:
The tooltip for the element or null if no tooltip is defined for this element.

hasTooltip

public boolean hasTooltip()
Description copied from interface: ComponentConnector
Check whether there might be a tooltip for this component. The framework will only add event listeners for automatically handling tooltips (using ComponentConnector.getTooltipInfo(Element)) if this method returns true.

This is only done to optimize performance, so in cases where the status is not known, it's safer to return true so that there will be a tooltip handler even though it might not be needed in all cases.

Specified by:
hasTooltip in interface ComponentConnector
Returns:
true if some part of the component might have a tooltip, otherwise false

getIconUri

protected java.lang.String getIconUri()
Gets the URI of the icon set for this component.

Returns:
the URI of the icon, or null if no icon has been defined.

getIcon

protected Icon getIcon()
Gets the icon set for this component.

Returns:
the icon, or null if no icon has been defined.

flush

public void flush()
Description copied from interface: ComponentConnector
Called for the active (focused) connector when a situation occurs that the focused connector might have buffered changes which need to be processed before other activity takes place.

This is currently called when the user changes the fragment using the back/forward button in the browser and allows the focused field to submit its value to the server before the fragment change event takes place.

Specified by:
flush in interface ComponentConnector


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