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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intSIGNIFICANT_MOVE_THRESHOLDDefault threshold for determining whether touch move is significant.
-
Constructor Summary
Constructors Constructor Description AbstractComponentConnector()Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected com.google.gwt.user.client.ui.WidgetcreateWidget()Creates and returns the widget for this VPaintableWidget.booleandelegateCaptionHandling()Return true if parent handles caption, false if the paintable handles the caption itself.voidflush()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 IcongetIcon()Gets the icon set for this component.protected StringgetIconUri()Gets the URI of the icon set for this component.LayoutManagergetLayoutManager()AbstractComponentStategetState()Returns the shared state object for this connector.TooltipInfogetTooltipInfo(com.google.gwt.dom.client.Element element)Gets the tooltip info for the given element.com.google.gwt.user.client.ui.WidgetgetWidget()Returns the widget associated with this paintable.booleanhasTooltip()Check whether there might be a tooltip for this component.booleanisErrorIndicatorVisible()Checks if an error indicator should be shown for the given connector.static booleanisRealUpdate(UIDL uidl)Deprecated.booleanisRelativeHeight()Returnstrueif the height of this paintable is currently relative.booleanisRelativeWidth()Returnstrueif the width of this paintable is currently relative.booleanisUndefinedHeight()Returnstrueif the height of this paintable is currently undefined.booleanisUndefinedWidth()Returnstrueif the width of this paintable is currently undefined.voidonDragSourceAttached()Invoked when aDragSourceExtensionConnectorhas been attached to this component.voidonDragSourceDetached()Invoked when aDragSourceExtensionConnectorhas been removed from this component.voidonDropTargetAttached()Invoked when aDropTargetExtensionConnectorhas been attached to this component.voidonDropTargetDetached()Invoked when aDropTargetExtensionConnectorhas been removed from this component.voidonStateChanged(StateChangeEvent stateChangeEvent)Notifies the event handler that the state has changed.voidonUnregister()Event called when connector has been unregistered.protected voidregisterTouchHandlers()The new default behavior is for long taps to fire a contextclick event if there's a contextclick listener attached to the component.protected voidsendContextClickEvent(MouseEventDetails details, com.google.gwt.dom.client.EventTarget eventTarget)This method sends the context menu event to the server-side.voidsetWidgetEnabled(boolean widgetEnabled)Sets the enabled state of the widget associated to this connector.protected voidsetWidgetStyleName(String styleName, boolean add)This is used to add / remove state related style names from the widget.protected voidsetWidgetStyleNameWithPrefix(String prefix, String styleName, boolean add)Deprecated.This will be removed once styles are no longer added with prefixes.protected booleanshouldHandleLongTap()Checks whether a long tap needs handling.protected voidunregisterTouchHandlers()The new default behavior is for long taps to fire a contextclick event if there's a contextclick listener attached to the component.protected voidupdateComponentSize()Updates the component size based on the shared state, invoking thelayout managerif necessary.protected voidupdateComponentSize(String newWidth, String newHeight)Updates the component size, invoking thelayout managerif necessary.voidupdateEnabledState(boolean enabledState)protected voidupdateWidgetSize(String newWidth, String newHeight)Updates the DOM size of this connector'swidget.protected voidupdateWidgetStyleNames()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:
trueif long tap handling is needed,falseotherwise
-
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 event- Since:
- 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 check- Returns:
trueif doesn't have "cached" attribute,falseotherwise
-
getState
public AbstractComponentState getState()
Description copied from class:AbstractConnectorReturns the shared state object for this connector. Override this method to define the shared state type for your connector.- Specified by:
getStatein interfaceComponentConnector- Specified by:
getStatein interfaceServerConnector- Overrides:
getStatein classAbstractConnector- Returns:
- the current shared state (never null)
-
onStateChanged
public void onStateChanged(StateChangeEvent stateChangeEvent)
Description copied from interface:StateChangeEvent.StateChangeHandlerNotifies the event handler that the state has changed.- Specified by:
onStateChangedin interfaceStateChangeEvent.StateChangeHandler- Overrides:
onStateChangedin classAbstractConnector- Parameters:
stateChangeEvent- the state change event with details about the change
-
setWidgetEnabled
public void setWidgetEnabled(boolean widgetEnabled)
Description copied from interface:ComponentConnectorSets the enabled state of the widget associated to this connector.- Specified by:
setWidgetEnabledin 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 thelayout managerif necessary.
-
updateComponentSize
protected void updateComponentSize(String newWidth, String newHeight)
Updates the component size, invoking thelayout managerif 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'swidget.- 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:ComponentConnectorReturnstrueif 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:
isRelativeHeightin interfaceComponentConnector- Returns:
trueif the width is undefined, elsefalse
-
isRelativeWidth
public boolean isRelativeWidth()
Description copied from interface:ComponentConnectorReturnstrueif 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:
isRelativeWidthin interfaceComponentConnector- Returns:
trueif the width is undefined, elsefalse
-
isUndefinedHeight
public boolean isUndefinedHeight()
Description copied from interface:ComponentConnectorReturnstrueif 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:
isUndefinedHeightin interfaceComponentConnector- Returns:
trueif the height is undefined, elsefalse
-
isUndefinedWidth
public boolean isUndefinedWidth()
Description copied from interface:ComponentConnectorReturnstrueif 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:
isUndefinedWidthin interfaceComponentConnector- Returns:
trueif the width is undefined, elsefalse
-
delegateCaptionHandling
public boolean delegateCaptionHandling()
Description copied from interface:ComponentConnectorReturn 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:
delegateCaptionHandlingin 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 bygetWidget()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-trueto add the given style,falseto 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-trueto add the given style,falseto remove it
-
getLayoutManager
public LayoutManager getLayoutManager()
- Specified by:
getLayoutManagerin interfaceComponentConnector
-
updateEnabledState
public void updateEnabledState(boolean enabledState)
- Specified by:
updateEnabledStatein interfaceServerConnector- Overrides:
updateEnabledStatein classAbstractConnector
-
onUnregister
public void onUnregister()
Description copied from interface:ServerConnectorEvent called when connector has been unregistered.- Specified by:
onUnregisterin interfaceServerConnector- Overrides:
onUnregisterin classAbstractConnector
-
getTooltipInfo
public TooltipInfo getTooltipInfo(com.google.gwt.dom.client.Element element)
Description copied from interface:ComponentConnectorGets the tooltip info for the given element.When overriding this method,
ComponentConnector.hasTooltip()should also be overridden to returntruein all situations where this method might return a non-empty result.- Specified by:
getTooltipInfoin interfaceComponentConnector- 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:ComponentConnectorCheck whether there might be a tooltip for this component. The framework will only add event listeners for automatically handling tooltips (usingComponentConnector.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
trueso that there will be a tooltip handler even though it might not be needed in all cases.- Specified by:
hasTooltipin interfaceComponentConnector- Returns:
trueif 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
nullif no icon has been defined.
-
getIcon
protected Icon getIcon()
Gets the icon set for this component.- Returns:
- the icon, or
nullif no icon has been defined.
-
flush
public void flush()
Description copied from interface:ComponentConnectorCalled 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:
flushin interfaceComponentConnector
-
isErrorIndicatorVisible
public boolean isErrorIndicatorVisible()
Description copied from interface:HasErrorIndicatorChecks if an error indicator should be shown for the given connector.- Specified by:
isErrorIndicatorVisiblein interfaceHasErrorIndicator- Returns:
trueto show an indicator,falseotherwise
-
onDragSourceAttached
public void onDragSourceAttached()
Invoked when aDragSourceExtensionConnectorhas 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()
-
onDragSourceDetached
public void onDragSourceDetached()
Invoked when aDragSourceExtensionConnectorhas 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:
onDragSourceAttached()
-
onDropTargetAttached
public void onDropTargetAttached()
Invoked when aDropTargetExtensionConnectorhas 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()
-
onDropTargetDetached
public void onDropTargetDetached()
Invoked when aDropTargetExtensionConnectorhas 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()
-
-