Package io.jmix.ui.component.impl
Class AbstractComponent<T extends com.vaadin.ui.Component>
java.lang.Object
io.jmix.ui.component.impl.AbstractComponent<T>
- All Implemented Interfaces:
AttachNotifier
,Component
,Component.BelongToFrame
,Component.HasCaption
,Component.HasDescription
,Component.HasIcon
,Component.HasXmlDescriptor
,Component.Wrapper
,HasContextHelp
,HasDebugId
,HasHtmlCaption
,HasHtmlDescription
,HasHtmlSanitizer
- Direct Known Subclasses:
AbstractActionsHolderComponent
,AbstractBox
,AbstractDataGrid
,AbstractOrderedLayout
,AbstractPagination
,AbstractResourceView
,AbstractValueComponent
,AbstractViewComponent
,AccordionImpl
,AppMenuImpl
,AppWorkAreaImpl
,BpmnModelerImpl
,BpmnViewerImpl
,ButtonImpl
,CalendarImpl
,CapsLockIndicatorImpl
,ChartImpl
,CustomChartImpl
,FileMultiUploadFieldImpl
,FormImpl
,GeoMapImpl
,GrapesJsHtmlEditorImpl
,GridLayoutImpl
,GroupBoxImpl
,HtmlBoxLayoutImpl
,JavaScriptComponentImpl
,LinkImpl
,LogoutButtonImpl
,NewWindowButtonImpl
,OutcomesPanelImpl
,PivotTableImpl
,PopupButtonImpl
,PopupViewImpl
,ResponsiveGridLayoutImpl
,ScrollBoxLayoutImpl
,SideMenuImpl
,SplitPanelImpl
,StockChartImpl
,TabSheetImpl
,TimeZoneIndicatorImpl
,TreeImpl
,UserActionsButtonImpl
,WebdavDocumentLinkImpl
public abstract class AbstractComponent<T extends com.vaadin.ui.Component>
extends Object
implements Component, Component.Wrapper, Component.HasXmlDescriptor, Component.BelongToFrame, Component.HasIcon, Component.HasCaption, HasDebugId, HasContextHelp, HasHtmlCaption, HasHtmlDescription, AttachNotifier, HasHtmlSanitizer
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jmix.ui.component.Component
Component.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper
Nested classes/interfaces inherited from interface io.jmix.ui.component.HasContextHelp
HasContextHelp.ContextHelpIconClickEvent
-
Field Summary
Modifier and TypeFieldDescriptionprotected Component.Alignment
protected org.springframework.context.ApplicationContext
protected T
protected Consumer<HasContextHelp.ContextHelpIconClickEvent>
protected com.vaadin.shared.Registration
protected boolean
protected org.dom4j.Element
protected Frame
protected Boolean
protected String
static final String
protected String
protected Component
Fields inherited from interface io.jmix.ui.component.Component
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddAttachListener
(Consumer<AttachEvent> listener) Registers a new attached listener.addDetachListener
(Consumer<DetachEvent> listener) Registers a new detached listener.void
addStyleName
(String styleName) Adds one or more style names to this component.protected void
void
attached()
Notifies all listeners that component has been attached.void
detached()
Notifies all listeners that component has been detached.com.vaadin.ui.Component
protected EventHub
getFrame()
float
Get component height inComponent.getHeightSizeUnit()
Gets the height property units.protected HtmlSanitizer
getIcon()
Get icon source: "font-icon:ADD", "icons/myicon.png", "theme://createIcon", etc.protected String
getIconName
(Icons.Icon icon) protected com.vaadin.server.Resource
getIconResource
(String icon) getId()
Component ID as defined inid
attributeStyles implementation is client-type-specific.protected UiComponentProperties
protected UiProperties
float
getWidth()
Get component width inComponent.getWidthSizeUnit()
Gets the width property units.org.dom4j.Element
protected boolean
hasSubscriptions
(Class<?> eventClass) protected boolean
boolean
boolean
boolean
boolean
boolean
Is the component enabled?
Note that this method only returns the status of the component and does not take parents into account.boolean
boolean
boolean
Is the component responsive?boolean
Is the component visible?
A component is visible only if all its parents are also visible.boolean
protected void
onContextHelpIconClick
(com.vaadin.ui.Component.HasContextHelp.ContextHelpIconClickEvent e) protected <E> void
void
removeStyleName
(String styleName) Removes one or more style names from component.protected String
void
setAlignment
(Component.Alignment alignment) void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
setCaption
(String caption) Sets the component's caption.void
setCaptionAsHtml
(boolean captionAsHtml) Sets whether the caption is rendered as HTML.void
Sets a context help icon click handler.void
setContextHelpText
(String contextHelpText) Sets context help text.void
setContextHelpTextHtmlEnabled
(boolean enabled) Defines if context help text can be presented as HTML.void
setDebugId
(String id) INTERNAL.void
setDescription
(String description) Sets the component's description.void
setDescriptionAsHtml
(boolean descriptionAsHtml) Sets whether the description is rendered as HTML.void
setEnabled
(boolean enabled) Sets the component enabled state.void
void
Set component height inComponent.getHeightSizeUnit()
void
setHtmlSanitizerEnabled
(boolean htmlSanitizerEnabled) Sets whether html sanitizer is enabled or not.void
Set an icon by its source: "font-icon:ADD", "icons/myicon.png", "theme://createIcon", etc.void
setIconFromSet
(Icons.Icon icon) Set an icon from an icon set.void
Set component IDvoid
INTERNAL.
ComponentContainer.add(Component)
is normally used for adding components to a parent and the used method will call this method implicitly.void
setResponsive
(boolean responsive) Sets component to be responsive by width and height.void
setStyleName
(String name) Sets one or more style names of the component, replacing any previous styles.protected void
setValidationError
(String errorMessage) void
setVisible
(boolean visible) Sets visibility value for the component.void
Set component width inComponent.getWidthSizeUnit()
}void
setXmlDescriptor
(org.dom4j.Element element) protected <E> boolean
unsubscribe
(Class<E> eventType, Consumer<E> listener) <X> X
Get client specific component instance.<X> X
unwrapComposition
(Class<X> internalCompositionClass) Get the outmost external container of client specific component instance.<X> X
unwrapCompositionOrNull
(Class<X> internalCompositionClass) Get the outmost external container of client specific component instance.<X> X
unwrapOrNull
(Class<X> internalComponentClass) Get client specific component instance.<X> void
withUnwrapped
(Class<X> internalComponentClass, Consumer<X> action) Performs the givenaction
with underlying component if it can be casted to the giveninternalComponentClass
.<X> void
withUnwrappedComposition
(Class<X> internalCompositionClass, Consumer<X> action) Get the outmost external container of client specific component instance and performs the givenaction
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.jmix.ui.component.Component
setHeightAuto, setHeightFull, setSizeAuto, setSizeFull, setWidthAuto, setWidthFull
-
Field Details
-
ICON_STYLE
- See Also:
-
id
-
component
-
element
protected org.dom4j.Element element -
frame
-
parent
-
alignment
-
icon
-
descriptionAsHtml
protected boolean descriptionAsHtml -
htmlSanitizerEnabled
-
contextHelpIconClickHandler
-
contextHelpIconClickListener
protected com.vaadin.shared.Registration contextHelpIconClickListener -
applicationContext
protected org.springframework.context.ApplicationContext applicationContext
-
-
Constructor Details
-
AbstractComponent
public AbstractComponent()
-
-
Method Details
-
setApplicationContext
@Autowired public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) -
getEventHub
-
publish
-
hasSubscriptions
-
unsubscribe
-
getFrame
- Specified by:
getFrame
in interfaceComponent.BelongToFrame
-
setFrame
- Specified by:
setFrame
in interfaceComponent.BelongToFrame
-
isResponsive
public boolean isResponsive()Description copied from interface:Component
Is the component responsive?- Specified by:
isResponsive
in interfaceComponent
- Returns:
- true if the component applies conditional CSS rules for width / height sizes.
-
setResponsive
public void setResponsive(boolean responsive) Description copied from interface:Component
Sets component to be responsive by width and height.
If responsive flag is true then you can use conditional CSS rules that respond to size changes in the browser. You can set specific rules using "width-range" or "height-range" properties in CSS files.- Specified by:
setResponsive
in interfaceComponent
- Parameters:
responsive
- responsive flag
-
getId
Description copied from interface:Component
Component ID as defined inid
attribute -
setId
Description copied from interface:Component
Set component ID -
assignDebugId
protected void assignDebugId() -
getParent
-
setParent
Description copied from interface:Component
INTERNAL.
ComponentContainer.add(Component)
is normally used for adding components to a parent and the used method will call this method implicitly. -
isAttached
public boolean isAttached()- Specified by:
isAttached
in interfaceAttachNotifier
- Returns:
- whether a component is attached to a window
-
attached
public void attached()Description copied from interface:AttachNotifier
Notifies all listeners that component has been attached.- Specified by:
attached
in interfaceAttachNotifier
-
detached
public void detached()Description copied from interface:AttachNotifier
Notifies all listeners that component has been detached.- Specified by:
detached
in interfaceAttachNotifier
-
addAttachListener
Description copied from interface:AttachNotifier
Registers a new attached listener.- Specified by:
addAttachListener
in interfaceAttachNotifier
- Parameters:
listener
- a listener to add- Returns:
- a registration object for removing an event listener added to a source
-
addDetachListener
Description copied from interface:AttachNotifier
Registers a new detached listener.- Specified by:
addDetachListener
in interfaceAttachNotifier
- Parameters:
listener
- a listener to add- Returns:
- a registration object for removing an event listener added to a source
-
getDebugId
- Specified by:
getDebugId
in interfaceHasDebugId
-
setDebugId
Description copied from interface:HasDebugId
INTERNAL. Managed by debug Id system.- Specified by:
setDebugId
in interfaceHasDebugId
-
getStyleName
Description copied from interface:Component
Styles implementation is client-type-specific.- Specified by:
getStyleName
in interfaceComponent
- Returns:
- current style name.
-
setStyleName
Description copied from interface:Component
Sets one or more style names of the component, replacing any previous styles. Multiple styles can be specified as a space-separated list of style names. Styles implementation is client-type-specific.- Specified by:
setStyleName
in interfaceComponent
- Parameters:
name
- one or more style names separated by space.
-
addStyleName
Description copied from interface:Component
Adds one or more style names to this component. Multiple styles can be specified as a space-separated list of style names.- Specified by:
addStyleName
in interfaceComponent
- Parameters:
styleName
- one or more style names separated by space.
-
removeStyleName
Description copied from interface:Component
Removes one or more style names from component. Multiple styles can be specified as a space-separated list of style names.- Specified by:
removeStyleName
in interfaceComponent
- Parameters:
styleName
- one or more style names separated by space.
-
isEnabled
public boolean isEnabled()Description copied from interface:Component
Is the component enabled?
Note that this method only returns the status of the component and does not take parents into account. Even though this method returns true the component can be disabled to the user if a parent is disabled. -
isEnabledRecursive
public boolean isEnabledRecursive()- Specified by:
isEnabledRecursive
in interfaceComponent
- Returns:
- true if the component and all its parent components are enabled
-
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:Component
Sets the component enabled state.
The user can not interact with disabled components, which are shown with a style that indicates the status. Components are enabled by default.- Specified by:
setEnabled
in interfaceComponent
- Parameters:
enabled
- enabled flag
-
isVisible
public boolean isVisible()Description copied from interface:Component
Is the component visible?
A component is visible only if all its parents are also visible. This is not checked by this method though, so even if this method returns true, the component can be hidden from the user because a parent is set to invisible. -
isVisibleRecursive
public boolean isVisibleRecursive()- Specified by:
isVisibleRecursive
in interfaceComponent
- Returns:
- true if the component and all its parent components are visible
-
setVisible
public void setVisible(boolean visible) Description copied from interface:Component
Sets visibility value for the component.
Visible components are drawn in the user interface, while invisible ones are not. The effect is not a cosmetic CSS change - no information about an invisible component will be sent to the client. The effect is thus the same as removing the component from its parent.- Specified by:
setVisible
in interfaceComponent
- Parameters:
visible
- visible flag
-
getIcon
Description copied from interface:Component.HasIcon
Get icon source: "font-icon:ADD", "icons/myicon.png", "theme://createIcon", etc.- Specified by:
getIcon
in interfaceComponent.HasIcon
-
getCaption
- Specified by:
getCaption
in interfaceComponent.HasCaption
- Returns:
- the caption of the component
-
setCaption
Description copied from interface:Component.HasCaption
Sets the component's caption.- Specified by:
setCaption
in interfaceComponent.HasCaption
- Parameters:
caption
- the new component's caption
-
isCaptionAsHtml
public boolean isCaptionAsHtml()- Specified by:
isCaptionAsHtml
in interfaceHasHtmlCaption
- Returns:
true
if the caption is rendered as HTML,false
if rendered as plain text
-
setCaptionAsHtml
public void setCaptionAsHtml(boolean captionAsHtml) Description copied from interface:HasHtmlCaption
Sets whether the caption is rendered as HTML.- Specified by:
setCaptionAsHtml
in interfaceHasHtmlCaption
- Parameters:
captionAsHtml
-true
if the caption is rendered as HTML,false
if rendered as plain text- See Also:
-
getDescription
- Specified by:
getDescription
in interfaceComponent.HasDescription
- Returns:
- the components description, used in tooltips
-
setDescription
Description copied from interface:Component.HasDescription
Sets the component's description.- Specified by:
setDescription
in interfaceComponent.HasDescription
- Parameters:
description
- the new description to set
-
isDescriptionAsHtml
public boolean isDescriptionAsHtml()- Specified by:
isDescriptionAsHtml
in interfaceHasHtmlDescription
- Returns:
true
if the description is rendered as HTML,false
if rendered as plain text
-
setDescriptionAsHtml
public void setDescriptionAsHtml(boolean descriptionAsHtml) Description copied from interface:HasHtmlDescription
Sets whether the description is rendered as HTML.- Specified by:
setDescriptionAsHtml
in interfaceHasHtmlDescription
- Parameters:
descriptionAsHtml
-true
if the description is rendered as HTML,false
if rendered as plain text- See Also:
-
setIcon
Description copied from interface:Component.HasIcon
Set an icon by its source: "font-icon:ADD", "icons/myicon.png", "theme://createIcon", etc.- Specified by:
setIcon
in interfaceComponent.HasIcon
-
setIconFromSet
Description copied from interface:Component.HasIcon
Set an icon from an icon set.- Specified by:
setIconFromSet
in interfaceComponent.HasIcon
-
getIconResource
-
getIconName
-
getHeight
public float getHeight()Description copied from interface:Component
Get component height inComponent.getHeightSizeUnit()
-
getHeightSizeUnit
Description copied from interface:Component
Gets the height property units.- Specified by:
getHeightSizeUnit
in interfaceComponent
- Returns:
- units used in height property.
-
setHeight
Description copied from interface:Component
Set component height inComponent.getHeightSizeUnit()
-
getWidth
public float getWidth()Description copied from interface:Component
Get component width inComponent.getWidthSizeUnit()
-
getWidthSizeUnit
Description copied from interface:Component
Gets the width property units.- Specified by:
getWidthSizeUnit
in interfaceComponent
- Returns:
- units used in the width property.
-
setWidth
Description copied from interface:Component
Set component width inComponent.getWidthSizeUnit()
} -
getAlignment
- Specified by:
getAlignment
in interfaceComponent
-
setAlignment
- Specified by:
setAlignment
in interfaceComponent
-
getComponent
- Specified by:
getComponent
in interfaceComponent.Wrapper
-
getComposition
public com.vaadin.ui.Component getComposition()- Specified by:
getComposition
in interfaceComponent.Wrapper
-
getXmlDescriptor
@Nullable public org.dom4j.Element getXmlDescriptor()- Specified by:
getXmlDescriptor
in interfaceComponent.HasXmlDescriptor
-
setXmlDescriptor
public void setXmlDescriptor(@Nullable org.dom4j.Element element) - Specified by:
setXmlDescriptor
in interfaceComponent.HasXmlDescriptor
-
getContextHelpText
- Specified by:
getContextHelpText
in interfaceHasContextHelp
- Returns:
- context help text
-
setContextHelpText
Description copied from interface:HasContextHelp
Sets context help text. If set, then a special icon will be added for a field.- Specified by:
setContextHelpText
in interfaceHasContextHelp
- Parameters:
contextHelpText
- context help text to be set
-
isContextHelpTextHtmlEnabled
public boolean isContextHelpTextHtmlEnabled()- Specified by:
isContextHelpTextHtmlEnabled
in interfaceHasContextHelp
- Returns:
- true if field accepts context help text in HTML format, false otherwise
-
setContextHelpTextHtmlEnabled
public void setContextHelpTextHtmlEnabled(boolean enabled) Description copied from interface:HasContextHelp
Defines if context help text can be presented as HTML.- Specified by:
setContextHelpTextHtmlEnabled
in interfaceHasContextHelp
- Parameters:
enabled
- true if field accepts context help text in HTML format, false otherwise
-
getContextHelpIconClickHandler
@Nullable public Consumer<HasContextHelp.ContextHelpIconClickEvent> getContextHelpIconClickHandler()- Specified by:
getContextHelpIconClickHandler
in interfaceHasContextHelp
- Returns:
- a context help icon click handler
-
setContextHelpIconClickHandler
public void setContextHelpIconClickHandler(@Nullable Consumer<HasContextHelp.ContextHelpIconClickEvent> handler) Description copied from interface:HasContextHelp
Sets a context help icon click handler. If set, then a special icon will be added for a field. Click handler has priority over context help text, i.e. no tooltip with context help text will be shown if click listener is set.- Specified by:
setContextHelpIconClickHandler
in interfaceHasContextHelp
- Parameters:
handler
- the handler to set
-
onContextHelpIconClick
protected void onContextHelpIconClick(com.vaadin.ui.Component.HasContextHelp.ContextHelpIconClickEvent e) -
unwrap
Description copied from interface:Component
Get client specific component instance. Can be used in client module to simplify invocation of underlying API.
Example:com.vaadin.ui.TextField vTextField = textField.unwrap(com.vaadin.ui.TextField.class);
-
unwrapOrNull
Description copied from interface:Component
Get client specific component instance. Can be used in client module to simplify invocation of underlying API.
Returnsnull
if underlying component cannot be casted to the giveninternalComponentClass
. Example:com.vaadin.ui.TextField vTextField = textField.unwrapOrNull(com.vaadin.ui.TextField.class);
- Specified by:
unwrapOrNull
in interfaceComponent
- Type Parameters:
X
- type of internal class- Parameters:
internalComponentClass
- class of underlying component implementation based on Vaadin or Swing- Returns:
- internal client specific component or null if it cannot be casted to given class
-
withUnwrapped
Description copied from interface:Component
Performs the givenaction
with underlying component if it can be casted to the giveninternalComponentClass
. Example:textField.withUnwrapped(com.vaadin.ui.TextField.class, vTextField -> { // do something });
- Specified by:
withUnwrapped
in interfaceComponent
- Type Parameters:
X
- type of internal class- Parameters:
internalComponentClass
- class of underlying component implementation based on Vaadin or Swingaction
- action to perform if underlying component can be casted to given class
-
unwrapComposition
Description copied from interface:Component
Get the outmost external container of client specific component instance. Can be used in client module to simplify invocation of underlying API.
Example:com.vaadin.ui.Layout vLayout = table.unwrapComposition(com.vaadin.ui.Layout.class);
- Specified by:
unwrapComposition
in interfaceComponent
- Type Parameters:
X
- type of internal class- Parameters:
internalCompositionClass
- class of underlying composition implementation based on Vaadin or Swing- Returns:
- internal client specific component
-
unwrapCompositionOrNull
Description copied from interface:Component
Get the outmost external container of client specific component instance. Can be used in client module to simplify invocation of underlying API.
Returns null if composition cannot be casted to giveninternalCompositionClass
. Example:com.vaadin.ui.Layout vLayout = table.unwrapCompositionOrNull(com.vaadin.ui.Layout.class);
- Specified by:
unwrapCompositionOrNull
in interfaceComponent
- Type Parameters:
X
- type of internal class- Parameters:
internalCompositionClass
- class of underlying composition implementation based on Vaadin or Swing- Returns:
- internal client specific component or null if cannot be casted to given class
-
withUnwrappedComposition
Description copied from interface:Component
Get the outmost external container of client specific component instance and performs the givenaction
.
Can be used in client module to simplify invocation of underlying API.
Example:table.withUnwrappedComposition(com.vaadin.ui.Layout.class, vLayout -> { // do something });
- Specified by:
withUnwrappedComposition
in interfaceComponent
- Type Parameters:
X
- type of internal class- Parameters:
internalCompositionClass
- class of underlying composition implementation based on Vaadin or Swingaction
- to perform if underlying composition can be casted to given class
-
hasValidationError
protected boolean hasValidationError() -
setValidationError
-
isHtmlSanitizerEnabled
public boolean isHtmlSanitizerEnabled()- Specified by:
isHtmlSanitizerEnabled
in interfaceHasHtmlSanitizer
- Returns:
- html sanitizer is enabled
-
setHtmlSanitizerEnabled
public void setHtmlSanitizerEnabled(boolean htmlSanitizerEnabled) Description copied from interface:HasHtmlSanitizer
Sets whether html sanitizer is enabled or not.- Specified by:
setHtmlSanitizerEnabled
in interfaceHasHtmlSanitizer
- Parameters:
htmlSanitizerEnabled
- specifies whether html sanitizer is enabled
-
sanitize
-
getUiProperties
-
getUiComponentProperties
-
getHtmlSanitizer
-