public class CompositeComponent<T extends Component> extends java.lang.Object implements Component, Component.BelongToFrame, AttachNotifier, HasDebugId, HasHtmlSanitizer
| Modifier and Type | Class and Description |
|---|---|
static class |
CompositeComponent.CreateEvent
An Event that is fired right before the composite component instance is returned
by
UiComponents bean. |
Component.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper| Modifier and Type | Field and Description |
|---|---|
protected org.springframework.context.ApplicationContext |
applicationContext |
protected Frame |
frame |
protected java.lang.String |
id |
protected java.lang.String |
prefixId |
protected T |
root |
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE| Constructor and Description |
|---|
CompositeComponent() |
| Modifier and Type | Method and Description |
|---|---|
io.jmix.core.common.event.Subscription |
addAttachListener(java.util.function.Consumer<AttachEvent> listener)
Registers a new attached listener.
|
protected io.jmix.core.common.event.Subscription |
addCreateListener(java.util.function.Consumer<CompositeComponent.CreateEvent> listener)
Registers a new
CompositeComponent.CreateEvent listener. |
io.jmix.core.common.event.Subscription |
addDetachListener(java.util.function.Consumer<DetachEvent> listener)
Registers a new detached listener.
|
void |
addStyleName(java.lang.String styleName)
Adds one or more style names to this component.
|
protected void |
assignDebugId() |
void |
attached()
Notifies all listeners that component has been attached.
|
void |
detached()
Notifies all listeners that component has been detached.
|
protected void |
disableEventListeners() |
protected void |
enableEventListeners() |
Component.Alignment |
getAlignment() |
T |
getComposition()
Returns the root component that represents the component tree of the composite component.
|
protected T |
getCompositionOrNull()
Returns the root component that represents the component tree of the composite component.
|
java.lang.String |
getDebugId() |
protected io.jmix.core.common.event.EventHub |
getEventHub() |
Frame |
getFrame() |
protected java.lang.String |
getFullId(java.lang.String id) |
float |
getHeight()
Get component height in
Component.getHeightSizeUnit() |
SizeUnit |
getHeightSizeUnit()
Gets the height property units.
|
java.lang.String |
getId()
Component ID as defined in
id attribute |
protected <C> C |
getInnerComponent(java.lang.String id)
Returns an inner component belonging to the whole components tree below this composition.
|
protected <C> java.util.Optional<C> |
getInnerComponentOptional(java.lang.String id)
Returns an inner component belonging to the whole components tree below this composition.
|
Component |
getParent() |
protected java.lang.String |
getPrefixId() |
java.lang.String |
getStyleName()
Styles implementation is client-type-specific.
|
protected java.util.List<org.springframework.context.ApplicationListener> |
getUiEventListeners() |
float |
getWidth()
Get component width in
Component.getWidthSizeUnit() |
SizeUnit |
getWidthSizeUnit()
Gets the width property units.
|
protected boolean |
hasSubscriptions(java.lang.Class<?> eventClass) |
boolean |
isAttached() |
boolean |
isEnabled()
Is the component enabled?
Note that this method only returns the status of the component and does not take parents into account. |
boolean |
isEnabledRecursive() |
boolean |
isHtmlSanitizerEnabled() |
boolean |
isResponsive()
Is the component responsive?
|
boolean |
isVisible()
Is the component visible?
A component is visible only if all its parents are also visible. |
boolean |
isVisibleRecursive() |
protected <E> void |
publish(java.lang.Class<E> eventType,
E event) |
void |
removeStyleName(java.lang.String styleName)
Removes one or more style names from component.
|
void |
setAlignment(Component.Alignment alignment) |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
protected void |
setComposition(T composition)
Sets the root component that represents the component hierarchy of the composite component.
|
void |
setDebugId(java.lang.String id)
INTERNAL.
|
void |
setEnabled(boolean enabled)
Sets the component enabled state.
|
void |
setFrame(Frame frame) |
void |
setHeight(java.lang.String height)
Set component height in
Component.getHeightSizeUnit() |
void |
setHtmlSanitizerEnabled(boolean htmlSanitizerEnabled)
Sets whether html sanitizer is enabled or not.
|
void |
setId(java.lang.String id)
Set component ID
|
void |
setParent(Component parent)
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(java.lang.String styleName)
Sets one or more style names of the component, replacing any
previous styles.
|
protected void |
setUiEventListeners(java.util.List<org.springframework.context.ApplicationListener> uiEventListeners) |
void |
setVisible(boolean visible)
Sets visibility value for the component.
|
void |
setWidth(java.lang.String width)
Set component width in
Component.getWidthSizeUnit()} |
protected <E> boolean |
unsubscribe(java.lang.Class<E> eventType,
java.util.function.Consumer<E> listener) |
<X> X |
unwrap(java.lang.Class<X> internalComponentClass)
Get client specific component instance.
|
<X> X |
unwrapComposition(java.lang.Class<X> internalCompositionClass)
Get the outmost external container of client specific component instance.
|
<X> X |
unwrapCompositionOrNull(java.lang.Class<X> internalCompositionClass)
Get the outmost external container of client specific component instance.
|
<X> X |
unwrapOrNull(java.lang.Class<X> internalComponentClass)
Get client specific component instance.
|
protected void |
updateComponentIds(T composition) |
protected void |
updateIdIfNeeded(Component component) |
<X> void |
withUnwrapped(java.lang.Class<X> internalComponentClass,
java.util.function.Consumer<X> action)
Performs the given
action with underlying component if it can be casted to the given
internalComponentClass. |
<X> void |
withUnwrappedComposition(java.lang.Class<X> internalCompositionClass,
java.util.function.Consumer<X> action)
Get the outmost external container of client specific component instance and performs the given
action. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsetHeightAuto, setHeightFull, setSizeAuto, setSizeFull, setWidthAuto, setWidthFullprotected java.lang.String id
protected Frame frame
protected java.lang.String prefixId
protected org.springframework.context.ApplicationContext applicationContext
@Autowired public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
protected io.jmix.core.common.event.EventHub getEventHub()
protected <E> void publish(java.lang.Class<E> eventType,
E event)
protected boolean hasSubscriptions(java.lang.Class<?> eventClass)
protected <E> boolean unsubscribe(java.lang.Class<E> eventType,
java.util.function.Consumer<E> listener)
public T getComposition()
@Nullable protected T getCompositionOrNull()
null if not yet initializedgetComposition()protected <C> C getInnerComponent(java.lang.String id)
id - the id of a componentjava.lang.IllegalArgumentException - if no component is found with given idjava.lang.IllegalStateException - if the root component can't contain inner componentsgetInnerComponentOptional(String)protected <C> java.util.Optional<C> getInnerComponentOptional(java.lang.String id)
id - the id of a componentnull if no component is foundjava.lang.IllegalStateException - if the root component can't contain inner componentsgetInnerComponent(String)protected void setComposition(T composition)
composition - a component to set as the rootjava.lang.IllegalStateException - if the root component is already setprotected void updateComponentIds(T composition)
protected void updateIdIfNeeded(Component component)
protected java.lang.String getFullId(java.lang.String id)
protected java.lang.String getPrefixId()
@Nullable public java.lang.String getId()
Componentid attributepublic void setId(@Nullable
java.lang.String id)
Componentprotected void assignDebugId()
@Nullable public java.lang.String getDebugId()
getDebugId in interface HasDebugIdpublic void setDebugId(@Nullable
java.lang.String id)
HasDebugIdsetDebugId in interface HasDebugId@Nullable public Component getParent()
public void setParent(@Nullable
Component parent)
ComponentComponentContainer.add(Component) is normally used for adding components
to a parent and the used method will call this method implicitly.public boolean isAttached()
isAttached in interface AttachNotifierpublic void attached()
AttachNotifierattached in interface AttachNotifierpublic void detached()
AttachNotifierdetached in interface AttachNotifierpublic io.jmix.core.common.event.Subscription addAttachListener(java.util.function.Consumer<AttachEvent> listener)
AttachNotifieraddAttachListener in interface AttachNotifierlistener - a listener to addpublic io.jmix.core.common.event.Subscription addDetachListener(java.util.function.Consumer<DetachEvent> listener)
AttachNotifieraddDetachListener in interface AttachNotifierlistener - a listener to addpublic boolean isEnabled()
Componentpublic void setEnabled(boolean enabled)
ComponentsetEnabled in interface Componentenabled - enabled flagpublic boolean isResponsive()
ComponentisResponsive in interface Componentpublic void setResponsive(boolean responsive)
ComponentsetResponsive in interface Componentresponsive - responsive flagpublic boolean isVisible()
Componentpublic void setVisible(boolean visible)
ComponentsetVisible in interface Componentvisible - visible flagpublic boolean isVisibleRecursive()
isVisibleRecursive in interface Componentpublic boolean isEnabledRecursive()
isEnabledRecursive in interface Componentpublic float getHeight()
ComponentComponent.getHeightSizeUnit()public SizeUnit getHeightSizeUnit()
ComponentgetHeightSizeUnit in interface Componentpublic void setHeight(@Nullable
java.lang.String height)
ComponentComponent.getHeightSizeUnit()public float getWidth()
ComponentComponent.getWidthSizeUnit()public SizeUnit getWidthSizeUnit()
ComponentgetWidthSizeUnit in interface Componentpublic void setWidth(@Nullable
java.lang.String width)
ComponentComponent.getWidthSizeUnit()}public Component.Alignment getAlignment()
getAlignment in interface Componentpublic void setAlignment(Component.Alignment alignment)
setAlignment in interface Componentpublic java.lang.String getStyleName()
ComponentgetStyleName in interface Componentpublic void setStyleName(@Nullable
java.lang.String styleName)
ComponentsetStyleName in interface ComponentstyleName - one or more style names separated by space.public void addStyleName(java.lang.String styleName)
ComponentaddStyleName in interface ComponentstyleName - one or more style names separated by space.public void removeStyleName(java.lang.String styleName)
ComponentremoveStyleName in interface ComponentstyleName - one or more style names separated by space.public <X> X unwrap(java.lang.Class<X> internalComponentClass)
Componentcom.vaadin.ui.TextField vTextField = textField.unwrap(com.vaadin.ui.TextField.class);
@Nullable public <X> X unwrapOrNull(java.lang.Class<X> internalComponentClass)
Componentnull if underlying component cannot be casted to the given internalComponentClass.
Example:
com.vaadin.ui.TextField vTextField = textField.unwrapOrNull(com.vaadin.ui.TextField.class);
unwrapOrNull in interface ComponentX - type of internal classinternalComponentClass - class of underlying component implementation based on Vaadin or Swingpublic <X> void withUnwrapped(java.lang.Class<X> internalComponentClass,
java.util.function.Consumer<X> action)
Componentaction with underlying component if it can be casted to the given
internalComponentClass.
Example:
textField.withUnwrapped(com.vaadin.ui.TextField.class, vTextField -> {
// do something
});
withUnwrapped in interface ComponentX - type of internal classinternalComponentClass - class of underlying component implementation based on Vaadin or Swingaction - action to perform if underlying component can be casted to given classpublic <X> X unwrapComposition(java.lang.Class<X> internalCompositionClass)
Componentcom.vaadin.ui.Layout vLayout = table.unwrapComposition(com.vaadin.ui.Layout.class);
unwrapComposition in interface ComponentX - type of internal classinternalCompositionClass - class of underlying composition implementation based on Vaadin or Swing@Nullable public <X> X unwrapCompositionOrNull(java.lang.Class<X> internalCompositionClass)
ComponentinternalCompositionClass.
Example:
com.vaadin.ui.Layout vLayout = table.unwrapCompositionOrNull(com.vaadin.ui.Layout.class);
unwrapCompositionOrNull in interface ComponentX - type of internal classinternalCompositionClass - class of underlying composition implementation based on Vaadin or Swingpublic <X> void withUnwrappedComposition(java.lang.Class<X> internalCompositionClass,
java.util.function.Consumer<X> action)
Componentaction.
table.withUnwrappedComposition(com.vaadin.ui.Layout.class, vLayout -> {
// do something
});
withUnwrappedComposition in interface ComponentX - type of internal classinternalCompositionClass - class of underlying composition implementation based on Vaadin or Swingaction - to perform if underlying composition can be casted to given class@Nullable public Frame getFrame()
getFrame in interface Component.BelongToFramepublic void setFrame(@Nullable
Frame frame)
setFrame in interface Component.BelongToFramepublic boolean isHtmlSanitizerEnabled()
isHtmlSanitizerEnabled in interface HasHtmlSanitizerpublic void setHtmlSanitizerEnabled(boolean htmlSanitizerEnabled)
HasHtmlSanitizersetHtmlSanitizerEnabled in interface HasHtmlSanitizerhtmlSanitizerEnabled - specifies whether html sanitizer is enabledprotected io.jmix.core.common.event.Subscription addCreateListener(java.util.function.Consumer<CompositeComponent.CreateEvent> listener)
CompositeComponent.CreateEvent listener.listener - a listener to addprotected java.util.List<org.springframework.context.ApplicationListener> getUiEventListeners()
protected void setUiEventListeners(java.util.List<org.springframework.context.ApplicationListener> uiEventListeners)
protected void enableEventListeners()
protected void disableEventListeners()