com.vaadin.client.ui.
Class AbstractComponentConnector
- java.lang.Object
-
- com.vaadin.client.ui.AbstractConnector
-
- com.vaadin.client.ui.AbstractComponentConnector
-
All Implemented Interfaces:
com.google.gwt.event.shared.EventHandler
,StateChangeEvent.StateChangeHandler
,ComponentConnector
,HasWidget
,ServerConnector
,HasErrorIndicator
,Connector
,Serializable
Direct Known Subclasses:
AbstractColorPickerConnector
,AbstractFieldConnector
,AbstractHasComponentsConnector
,BrowserFrameConnector
,ButtonConnector
,ColorPickerGradientConnector
,ColorPickerGridConnector
,EmbeddedConnector
,ImageConnector
,JavaScriptComponentConnector
,LabelConnector
,LegacyConnector
,LinkConnector
,MediaBaseConnector
,MenuBarConnector
,NativeButtonConnector
,UnknownComponentConnector
,UploadConnector
public abstract class AbstractComponentConnector extends AbstractConnector implements HasErrorIndicator
Base class for component connectors.
Author:
Vaadin Ltd
See Also:
-
-
Field Summary
Fields Modifier and Type Field Description protected int
SIGNIFICANT_MOVE_THRESHOLD
Default threshold for determining whether touch move is significant.
-
Constructor Summary
Constructors Constructor Description AbstractComponentConnector()
Default constructor.
-
Method Summary
All Methods Modifier and Type Method Description protected com.google.gwt.user.client.ui.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 String
getIconUri()
Gets the URI of the icon set for this component.
LayoutManager
getLayoutManager()
AbstractComponentState
getState()
Returns the shared state object for this connector.
TooltipInfo
getTooltipInfo(com.google.gwt.dom.client.Element element)
Gets the tooltip info for the given element.
com.google.gwt.user.client.ui.Widget
getWidget()
Returns the widget associated with this paintable.
boolean
hasTooltip()
Check whether there might be a tooltip for this component.
boolean
isErrorIndicatorVisible()
Checks if an error indicator should be shown for the given connector.
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
onDragSourceAttached()
Invoked when a
DragSourceExtensionConnector
has been attached to this component.void
onDragSourceDetached()
Invoked when a
DragSourceExtensionConnector
has been removed from this component.void
onDropTargetAttached()
Invoked when a
DropTargetExtensionConnector
has been attached to this component.void
onDropTargetDetached()
Invoked when a
DropTargetExtensionConnector
has been removed from this component.void
onStateChanged(StateChangeEvent stateChangeEvent)
Notifies the event handler that the state has changed.
void
onUnregister()
Event called when connector has been unregistered.
protected void
registerTouchHandlers()
The new default behavior is for long taps to fire a contextclick event if there's a contextclick listener attached to the component.
protected void
sendContextClickEvent(MouseEventDetails details, com.google.gwt.dom.client.EventTarget eventTarget)
This method sends the context menu event to the server-side.
void
setWidgetEnabled(boolean widgetEnabled)
Sets the enabled state of the widget associated to this connector.
protected void
setWidgetStyleName(String styleName, boolean add)
This is used to add / remove state related style names from the widget.
protected void
setWidgetStyleNameWithPrefix(String prefix, String styleName, boolean add)
Deprecated.
This will be removed once styles are no longer added with prefixes.protected boolean
shouldHandleLongTap()
Checks whether a long tap needs handling.
protected void
unregisterTouchHandlers()
The new default behavior is for long taps to fire a contextclick event if there's a contextclick listener attached to the component.
protected void
updateComponentSize()
Updates the component size based on the shared state, invoking the
layout manager
if necessary.protected void
updateComponentSize(String newWidth, String newHeight)
Updates the component size, invoking the
layout manager
if necessary.void
updateEnabledState(boolean enabledState)
protected void
updateWidgetSize(String newWidth, 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, getTag, hasEventListener, init, isEnabled, registerRpc, removeStateChangeHandler, removeStateChangeHandler, setChildren, setParent, setTag, 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.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.client.ServerConnector
addStateChangeHandler, addStateChangeHandler, doInit, fireEvent, getChildren, getConnection, getParent, getRpcImplementations, getTag, hasEventListener, isEnabled, removeStateChangeHandler, removeStateChangeHandler, setChildren, setParent, setTag
-
-
-
-
Method Detail
-
unregisterTouchHandlers
protected void unregisterTouchHandlers()
The new default behavior is for long taps to fire a contextclick event if there's a contextclick listener attached to the component. If you do not want this in your component, override this with a blank method to get rid of said behavior.
Since:
7.6
-
registerTouchHandlers
protected void registerTouchHandlers()
The new default behavior is for long taps to fire a contextclick event if there's a contextclick listener attached to the component. If you do not want this in your component, override this with a blank method to get rid of said behavior. Some Vaadin Components already handle the long tap as a context menu. This method is unnecessary for those.
Since:
7.6
-
shouldHandleLongTap
protected boolean shouldHandleLongTap()
Checks whether a long tap needs handling.
Returns:
true
if long tap handling is needed,false
otherwise
-
sendContextClickEvent
protected void sendContextClickEvent(MouseEventDetails details, com.google.gwt.dom.client.EventTarget eventTarget)
This method sends the context menu event to the server-side. Can be overridden to provide extra information through an alternative RPC interface.
Parameters:
details
- the mouse event detailseventTarget
- the target of the eventSince:
7.6
-
createWidget
protected com.google.gwt.user.client.ui.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 ofgetWidget()
. If you do override the method, you can't callsuper.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 com.google.gwt.user.client.ui.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.
-
isRealUpdate
@Deprecated public static boolean isRealUpdate(UIDL uidl)
Deprecated.Checks whether the update is 'real' or contains cached information.
Parameters:
uidl
- the UIDL to checkReturns:
true
if doesn't have "cached" attribute,false
otherwise
-
getState
public 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 interfaceComponentConnector
Specified by:
getState
in interfaceServerConnector
Overrides:
getState
in classAbstractConnector
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 interfaceStateChangeEvent.StateChangeHandler
Overrides:
onStateChanged
in classAbstractConnector
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 interfaceComponentConnector
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(String newWidth, 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(String newWidth, 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 interfaceComponentConnector
Returns:
true
if the width is undefined, elsefalse
-
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 interfaceComponentConnector
Returns:
true
if the width is undefined, elsefalse
-
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 interfaceComponentConnector
Returns:
true
if the height is undefined, elsefalse
-
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 interfaceComponentConnector
Returns:
true
if the width is undefined, elsefalse
-
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 interfaceComponentConnector
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
-
setWidgetStyleName
protected void setWidgetStyleName(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 removedadd
-true
to add the given style,false
to remove it
-
setWidgetStyleNameWithPrefix
@Deprecated protected void setWidgetStyleNameWithPrefix(String prefix, 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
'sgetWidget()
, or if the prefix should be different. For example seeTextualDateConnector.setWidgetStyleNameWithPrefix(String, String, boolean)
Parameters:
prefix
- the prefix for the style namestyleName
- the style name to be added or removedadd
-true
to add the given style,false
to remove it
-
getLayoutManager
public LayoutManager getLayoutManager()
Specified by:
getLayoutManager
in interfaceComponentConnector
-
updateEnabledState
public void updateEnabledState(boolean enabledState)
Specified by:
updateEnabledState
in interfaceServerConnector
Overrides:
updateEnabledState
in classAbstractConnector
-
onUnregister
public void onUnregister()
Description copied from interface:
ServerConnector
Event called when connector has been unregistered.
Specified by:
onUnregister
in interfaceServerConnector
Overrides:
onUnregister
in classAbstractConnector
-
getTooltipInfo
public TooltipInfo getTooltipInfo(com.google.gwt.dom.client.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 returntrue
in all situations where this method might return a non-empty result.Specified by:
getTooltipInfo
in interfaceComponentConnector
Parameters:
element
- The element to lookup a tooltip forReturns:
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 interfaceComponentConnector
Returns:
true
if some part of the component might have a tooltip, otherwisefalse
-
getIconUri
protected 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 interfaceComponentConnector
-
isErrorIndicatorVisible
public boolean isErrorIndicatorVisible()
Description copied from interface:
HasErrorIndicator
Checks if an error indicator should be shown for the given connector.
Specified by:
isErrorIndicatorVisible
in interfaceHasErrorIndicator
Returns:
true
to show an indicator,false
otherwise
-
onDragSourceAttached
public void onDragSourceAttached()
Invoked when a
DragSourceExtensionConnector
has been attached to this component.By default, does nothing. If you need to apply some changes to the widget, override this method.
This is a framework internal method, and should not be invoked manually.
Since:
8.1
See Also:
-
onDragSourceDetached
public void onDragSourceDetached()
Invoked when a
DragSourceExtensionConnector
has been removed from this component.By default, does nothing.
This is a framework internal method, and should not be invoked manually.
Since:
8.1
See Also:
-
onDropTargetAttached
public void onDropTargetAttached()
Invoked when a
DropTargetExtensionConnector
has been attached to this component.By default, does nothing. If you need to apply some changes to the widget, override this method.
This is a framework internal method, and should not be invoked manually.
Since:
8.1
See Also:
-
onDropTargetDetached
public void onDropTargetDetached()
Invoked when a
DropTargetExtensionConnector
has been removed from this component.By default, does nothing.
This is a framework internal method, and should not be invoked manually.
Since:
8.1
See Also:
-
-