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, wait
setHeightAuto, setHeightFull, setSizeAuto, setSizeFull, setWidthAuto, setWidthFull
protected 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()
Component
id
attributepublic void setId(@Nullable java.lang.String id)
Component
protected void assignDebugId()
@Nullable public java.lang.String getDebugId()
getDebugId
in interface HasDebugId
public void setDebugId(@Nullable java.lang.String id)
HasDebugId
setDebugId
in interface HasDebugId
@Nullable public Component getParent()
public void setParent(@Nullable Component parent)
Component
ComponentContainer.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 AttachNotifier
public void attached()
AttachNotifier
attached
in interface AttachNotifier
public void detached()
AttachNotifier
detached
in interface AttachNotifier
public io.jmix.core.common.event.Subscription addAttachListener(java.util.function.Consumer<AttachEvent> listener)
AttachNotifier
addAttachListener
in interface AttachNotifier
listener
- a listener to addpublic io.jmix.core.common.event.Subscription addDetachListener(java.util.function.Consumer<DetachEvent> listener)
AttachNotifier
addDetachListener
in interface AttachNotifier
listener
- a listener to addpublic boolean isEnabled()
Component
public void setEnabled(boolean enabled)
Component
setEnabled
in interface Component
enabled
- enabled flagpublic boolean isResponsive()
Component
isResponsive
in interface Component
public void setResponsive(boolean responsive)
Component
setResponsive
in interface Component
responsive
- responsive flagpublic boolean isVisible()
Component
public void setVisible(boolean visible)
Component
setVisible
in interface Component
visible
- visible flagpublic boolean isVisibleRecursive()
isVisibleRecursive
in interface Component
public boolean isEnabledRecursive()
isEnabledRecursive
in interface Component
public float getHeight()
Component
Component.getHeightSizeUnit()
public SizeUnit getHeightSizeUnit()
Component
getHeightSizeUnit
in interface Component
public void setHeight(@Nullable java.lang.String height)
Component
Component.getHeightSizeUnit()
public float getWidth()
Component
Component.getWidthSizeUnit()
public SizeUnit getWidthSizeUnit()
Component
getWidthSizeUnit
in interface Component
public void setWidth(@Nullable java.lang.String width)
Component
Component.getWidthSizeUnit()
}public Component.Alignment getAlignment()
getAlignment
in interface Component
public void setAlignment(Component.Alignment alignment)
setAlignment
in interface Component
public java.lang.String getStyleName()
Component
getStyleName
in interface Component
public void setStyleName(@Nullable java.lang.String styleName)
Component
setStyleName
in interface Component
styleName
- one or more style names separated by space.public void addStyleName(java.lang.String styleName)
Component
addStyleName
in interface Component
styleName
- one or more style names separated by space.public void removeStyleName(java.lang.String styleName)
Component
removeStyleName
in interface Component
styleName
- one or more style names separated by space.public <X> X unwrap(java.lang.Class<X> internalComponentClass)
Component
com.vaadin.ui.TextField vTextField = textField.unwrap(com.vaadin.ui.TextField.class);
@Nullable public <X> X unwrapOrNull(java.lang.Class<X> internalComponentClass)
Component
null
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 Component
X
- 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)
Component
action
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 Component
X
- 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)
Component
com.vaadin.ui.Layout vLayout = table.unwrapComposition(com.vaadin.ui.Layout.class);
unwrapComposition
in interface Component
X
- type of internal classinternalCompositionClass
- class of underlying composition implementation based on Vaadin or Swing@Nullable public <X> X unwrapCompositionOrNull(java.lang.Class<X> internalCompositionClass)
Component
internalCompositionClass
.
Example:
com.vaadin.ui.Layout vLayout = table.unwrapCompositionOrNull(com.vaadin.ui.Layout.class);
unwrapCompositionOrNull
in interface Component
X
- 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)
Component
action
.
table.withUnwrappedComposition(com.vaadin.ui.Layout.class, vLayout -> { // do something });
withUnwrappedComposition
in interface Component
X
- 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.BelongToFrame
public void setFrame(@Nullable Frame frame)
setFrame
in interface Component.BelongToFrame
public boolean isHtmlSanitizerEnabled()
isHtmlSanitizerEnabled
in interface HasHtmlSanitizer
public void setHtmlSanitizerEnabled(boolean htmlSanitizerEnabled)
HasHtmlSanitizer
setHtmlSanitizerEnabled
in interface HasHtmlSanitizer
htmlSanitizerEnabled
- 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()