com.vaadin.ui.
Class CheckBoxGroup<T>
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.ui.AbstractComponent
-
- com.vaadin.ui.AbstractListing<T>
-
- com.vaadin.ui.AbstractMultiSelect<T>
-
- com.vaadin.ui.CheckBoxGroup<T>
-
Type Parameters:
T
- item typeAll Implemented Interfaces:
HasDataProvider<T>
,HasItems<T>
,HasValue<Set<T>>
,ContextClickEvent.ContextClickNotifier
,FieldEvents.BlurNotifier
,FieldEvents.FocusNotifier
,MethodEventSource
,ClientConnector
,Sizeable
,Connector
,Component
,Component.Focusable
,MultiSelect<T>
,Serializable
public class CheckBoxGroup<T> extends AbstractMultiSelect<T> implements FieldEvents.FocusNotifier, FieldEvents.BlurNotifier, HasDataProvider<T>
A group of Checkboxes. Individual checkboxes are made from items supplied by a
DataProvider
. Checkboxes may have captions and icons.Since:
8.0
Author:
Vaadin Ltd
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractListing
AbstractListing.AbstractListingExtension<T>
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.data.HasValue
HasValue.ValueChangeEvent<V>, HasValue.ValueChangeListener<V>
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
-
Constructor Summary
Constructors Constructor Description CheckBoxGroup()
Constructs a new CheckBoxGroup.
CheckBoxGroup(String caption)
Constructs a new CheckBoxGroup with caption.
CheckBoxGroup(String caption, DataProvider<T,?> dataProvider)
Constructs a new CheckBoxGroup with caption and DataProvider.
CheckBoxGroup(String caption, Collection<T> items)
Constructs a new CheckBoxGroup with caption and DataProvider containing given items.
-
Method Summary
All Methods Modifier and Type Method Description Registration
addBlurListener(FieldEvents.BlurListener listener)
Adds a
BlurListener
to the Component which gets fired when aField
loses keyboard focus.Registration
addFocusListener(FieldEvents.FocusListener listener)
Adds a
FocusListener
to the Component which gets fired when aField
receives keyboard focus.DataProvider<T,?>
getDataProvider()
Returns the source of data items used by this listing.
DescriptionGenerator<T>
getItemDescriptionGenerator()
Gets the item description generator.
SerializablePredicate<T>
getItemEnabledProvider()
Returns the item enabled provider for this multiselect.
IconGenerator<T>
getItemIconGenerator()
Gets the currently used item icon generator.
protected CheckBoxGroupState
getState()
Returns the shared state bean with information to be sent from the server to the client.
protected CheckBoxGroupState
getState(boolean markAsDirty)
Returns the shared state for this connector.
boolean
isHtmlContentAllowed()
Checks whether captions are interpreted as html or plain text.
protected T
readItem(org.jsoup.nodes.Element child, Set<T> selected, DesignContext context)
Reads an Item from a design and inserts it into the data source.
protected void
readItems(org.jsoup.nodes.Element design, DesignContext context)
Reads the data source items from the
design
.void
setDataProvider(DataProvider<T,?> dataProvider)
Sets the data provider for this listing.
void
setHtmlContentAllowed(boolean htmlContentAllowed)
Sets whether html is allowed in the item captions.
void
setItemDescriptionGenerator(DescriptionGenerator<T> descriptionGenerator)
Sets the description generator that is used for generating descriptions for items.
void
setItemEnabledProvider(SerializablePredicate<T> itemEnabledProvider)
Sets the item enabled predicate for this multiselect.
void
setItemIconGenerator(IconGenerator<T> itemIconGenerator)
Sets the item icon generator that is used to produce custom icons for shown items.
protected org.jsoup.nodes.Element
writeItem(org.jsoup.nodes.Element design, T item, DesignContext context)
Writes a data source Item to a design.
-
Methods inherited from class com.vaadin.ui.AbstractMultiSelect
addSelectionListener, addValueChangeListener, deselect, deselect, deselectAll, getCustomAttributes, getItemCaptionGenerator, getSelectedItems, getValue, isReadOnly, isRequiredIndicatorVisible, isSelected, select, setItemCaptionGenerator, setReadOnly, setRequiredIndicatorVisible, setValue, updateSelection, updateSelection
-
Methods inherited from class com.vaadin.ui.AbstractListing
addDataGenerator, deserializeDeclarativeRepresentation, doReadDesign, doWriteDesign, focus, getDataCommunicator, getTabIndex, internalGetDataProvider, internalSetDataProvider, internalSetDataProvider, readDesign, readItem, removeDataGenerator, serializeDeclarativeRepresentation, setTabIndex, writeDesign, writeItems
-
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, readDesign, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible, writeDesign
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.data.HasDataProvider
setItems
-
Methods inherited from interface com.vaadin.data.HasValue
clear, getDefaultValidator, getOptionalValue, isEmpty
-
Methods inherited from interface com.vaadin.ui.MultiSelect
deselect, getEmptyValue, select
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefined
-
-
-
-
Constructor Detail
-
CheckBoxGroup
public CheckBoxGroup(String caption)
Constructs a new CheckBoxGroup with caption.
Parameters:
caption
- caption text
-
CheckBoxGroup
public CheckBoxGroup(String caption, DataProvider<T,?> dataProvider)
Constructs a new CheckBoxGroup with caption and DataProvider.
Parameters:
caption
- the caption textdataProvider
- the data provider, not nullSee Also:
-
CheckBoxGroup
public CheckBoxGroup(String caption, Collection<T> items)
Constructs a new CheckBoxGroup with caption and DataProvider containing given items.
Parameters:
caption
- the caption textitems
- the data items to use, not nullSee Also:
-
CheckBoxGroup
public CheckBoxGroup()
Constructs a new CheckBoxGroup.
-
-
Method Detail
-
setHtmlContentAllowed
public void setHtmlContentAllowed(boolean htmlContentAllowed)
Sets whether html is allowed in the item captions. If set to true, the captions are passed to the browser as html and the developer is responsible for ensuring no harmful html is used. If set to false, the content is passed to the browser as plain text.
Parameters:
htmlContentAllowed
- true if the captions are used as html, false if used as plain text
-
isHtmlContentAllowed
public boolean isHtmlContentAllowed()
Checks whether captions are interpreted as html or plain text.
Returns:
true if the captions are used as html, false if used as plain text
See Also:
-
getState
protected CheckBoxGroupState getState()
Description copied from class:
AbstractComponent
Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().
Overrides:
getState
in classAbstractMultiSelect<T>
Returns:
updated component shared state
-
getState
protected CheckBoxGroupState getState(boolean markAsDirty)
Description copied from class:
AbstractClientConnector
Returns the shared state for this connector.
Overrides:
getState
in classAbstractMultiSelect<T>
Parameters:
markAsDirty
- true if the connector should automatically be marked dirty, false otherwiseReturns:
The shared state for this connector. Never null.
See Also:
-
getItemIconGenerator
public IconGenerator<T> getItemIconGenerator()
Description copied from class:
AbstractListing
Gets the currently used item icon generator. The default item icon provider returns null for all items, resulting in no icons being used.
Implementations that support item icons make this method public.
Overrides:
getItemIconGenerator
in classAbstractListing<T>
Returns:
the currently used item icon generator, not null
See Also:
IconGenerator
,AbstractListing.setItemIconGenerator(IconGenerator)
-
setItemIconGenerator
public void setItemIconGenerator(IconGenerator<T> itemIconGenerator)
Description copied from class:
AbstractListing
Sets the item icon generator that is used to produce custom icons for shown items. The generator can return null for items with no icon.
Implementations that support item icons make this method public.
Overrides:
setItemIconGenerator
in classAbstractListing<T>
Parameters:
itemIconGenerator
- the item icon generator to set, not nullSee Also:
-
getItemEnabledProvider
public SerializablePredicate<T> getItemEnabledProvider()
Description copied from class:
AbstractMultiSelect
Returns the item enabled provider for this multiselect.
Implementation note: Override this method and
AbstractMultiSelect.setItemEnabledProvider(SerializablePredicate)
aspublic
and invokesuper
methods to support this feature in the multiselect component.Overrides:
getItemEnabledProvider
in classAbstractMultiSelect<T>
Returns:
the item enabled provider, not
null
See Also:
AbstractMultiSelect.setItemEnabledProvider(SerializablePredicate)
-
setItemEnabledProvider
public void setItemEnabledProvider(SerializablePredicate<T> itemEnabledProvider)
Description copied from class:
AbstractMultiSelect
Sets the item enabled predicate for this multiselect. The predicate is applied to each item to determine whether the item should be enabled (
true
) or disabled (false
). Disabled items are displayed as grayed out and the user cannot select them. The default predicate always returnstrue
(all the items are enabled).Implementation note: Override this method and
AbstractMultiSelect.getItemEnabledProvider()
aspublic
and invokesuper
methods to support this feature in the multiselect component.Overrides:
setItemEnabledProvider
in classAbstractMultiSelect<T>
Parameters:
itemEnabledProvider
- the item enabled provider to set, notnull
-
addFocusListener
public Registration addFocusListener(FieldEvents.FocusListener listener)
Description copied from interface:
FieldEvents.FocusNotifier
Adds a
FocusListener
to the Component which gets fired when aField
receives keyboard focus.Specified by:
addFocusListener
in interfaceFieldEvents.FocusNotifier
Parameters:
listener
- the focus listener to add, not nullReturns:
a registration object for removing the listener
See Also:
-
addBlurListener
public Registration addBlurListener(FieldEvents.BlurListener listener)
Description copied from interface:
FieldEvents.BlurNotifier
Adds a
BlurListener
to the Component which gets fired when aField
loses keyboard focus.Specified by:
addBlurListener
in interfaceFieldEvents.BlurNotifier
Parameters:
listener
- the blur listener to add, not nullReturns:
a registration object for removing the listener
See Also:
-
setItemDescriptionGenerator
public void setItemDescriptionGenerator(DescriptionGenerator<T> descriptionGenerator)
Sets the description generator that is used for generating descriptions for items. Description is shown as a tooltip when hovering on corresponding element. If the generator returns
null
, no tooltip is shown.Parameters:
descriptionGenerator
- the item description generator to set, notnull
Since:
8.2
-
getItemDescriptionGenerator
public DescriptionGenerator<T> getItemDescriptionGenerator()
Gets the item description generator.
Returns:
the item description generator
Since:
8.2
-
readItems
protected void readItems(org.jsoup.nodes.Element design, DesignContext context)
Description copied from class:
AbstractListing
Reads the data source items from the
design
.Overrides:
readItems
in classAbstractMultiSelect<T>
Parameters:
design
- The element to obtain the state fromcontext
- The DesignContext instance used for parsing the design
-
readItem
protected T readItem(org.jsoup.nodes.Element child, Set<T> selected, DesignContext context)
Description copied from class:
AbstractMultiSelect
Reads an Item from a design and inserts it into the data source. Hierarchical select components should override this method to recursively recursively read any child items as well.
Overrides:
readItem
in classAbstractMultiSelect<T>
Parameters:
child
- a child element representing the itemselected
- A set accumulating selected items. If the item that is read is marked as selected, its item id should be added to this set.context
- the DesignContext instance used in parsingReturns:
the item id of the new item
-
writeItem
protected org.jsoup.nodes.Element writeItem(org.jsoup.nodes.Element design, T item, DesignContext context)
Description copied from class:
AbstractListing
Writes a data source Item to a design. Hierarchical select components should override this method to recursively write any child items as well.
Overrides:
writeItem
in classAbstractMultiSelect<T>
Parameters:
design
- the element into which to insert the itemitem
- the item to writecontext
- the DesignContext instance used in writingReturns:
a JSOUP element representing the
item
-
getDataProvider
public DataProvider<T,?> getDataProvider()
Description copied from interface:
HasItems
Returns the source of data items used by this listing.
Specified by:
getDataProvider
in interfaceHasItems<T>
Returns:
the data provider, not null
-
setDataProvider
public void setDataProvider(DataProvider<T,?> dataProvider)
Description copied from interface:
HasDataProvider
Sets the data provider for this listing. The data provider is queried for displayed items as needed.
Specified by:
setDataProvider
in interfaceHasDataProvider<T>
Parameters:
dataProvider
- the data provider, not null
-
-