T
- the item data typepublic abstract class AbstractListing<T> extends AbstractComponent implements Component.Focusable, HasItems<T>
Note: concrete component implementations should implement
the HasDataProvider
or HasFilterableDataProvider
interface.
Modifier and Type | Class and Description |
---|---|
static class |
AbstractListing.AbstractListingExtension<T>
A helper base class for creating extensions for Listing components.
|
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
Sizeable.Unit
DESIGN_ATTR_PLAIN_TEXT
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
Modifier | Constructor and Description |
---|---|
protected |
AbstractListing()
Creates a new
AbstractListing with a default data communicator. |
protected |
AbstractListing(DataCommunicator<T> dataCommunicator)
Creates a new
AbstractListing with the given custom data
communicator. |
Modifier and Type | Method and Description |
---|---|
protected void |
addDataGenerator(DataGenerator<T> generator)
Adds the given data generator to this listing.
|
protected T |
deserializeDeclarativeRepresentation(String item)
Deserializes a string to a data item.
|
protected void |
doReadDesign(org.jsoup.nodes.Element design,
DesignContext context)
Reads the listing specific state from the given design.
|
protected void |
doWriteDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Writes listing specific state into the given design.
|
void |
focus()
Sets the focus for this component if the component is
Focusable . |
DataCommunicator<T> |
getDataCommunicator()
Returns the data communicator of this listing.
|
protected ItemCaptionGenerator<T> |
getItemCaptionGenerator()
Gets the item caption generator that is used to produce the strings shown
in the combo box for each item.
|
protected IconGenerator<T> |
getItemIconGenerator()
Gets the currently used item icon generator.
|
protected AbstractListingState |
getState()
Returns the shared state bean with information to be sent from the server
to the client.
|
protected AbstractListingState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
int |
getTabIndex()
Gets the tabulator index of the
Focusable component. |
protected DataProvider<T,?> |
internalGetDataProvider() |
protected void |
internalSetDataProvider(DataProvider<T,?> dataProvider) |
protected <F> SerializableConsumer<F> |
internalSetDataProvider(DataProvider<T,F> dataProvider,
F initialFilter) |
void |
readDesign(org.jsoup.nodes.Element design,
DesignContext context)
Reads the component state from the given design.
|
protected T |
readItem(org.jsoup.nodes.Element child,
DesignContext context)
Reads an Item from a design and inserts it into the data source.
|
protected abstract void |
readItems(org.jsoup.nodes.Element design,
DesignContext context)
Reads the data source items from the
design . |
protected void |
removeDataGenerator(DataGenerator<T> generator)
Removes the given data generator from this listing.
|
protected String |
serializeDeclarativeRepresentation(T item)
Serializes an
item to a string for saving declarative format. |
protected void |
setItemCaptionGenerator(ItemCaptionGenerator<T> itemCaptionGenerator)
Sets the item caption generator that is used to produce the strings shown
in the combo box for each item.
|
protected void |
setItemIconGenerator(IconGenerator<T> itemIconGenerator)
Sets the item icon generator that is used to produce custom icons for
shown items.
|
void |
setTabIndex(int tabIndex)
Sets the tabulator index of the
Focusable component. |
void |
writeDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Writes the component state to the given design.
|
protected org.jsoup.nodes.Element |
writeItem(org.jsoup.nodes.Element design,
T item,
DesignContext context)
Writes a data source Item to a design.
|
protected void |
writeItems(org.jsoup.nodes.Element design,
DesignContext context)
Writes the data source items to a design.
|
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getCustomAttributes, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isReadOnly, isRequiredIndicatorVisible, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeight, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setReadOnly, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthUndefined
addAttachListener, addDetachListener, addExtension, 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, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getDataProvider, setItems, setItems, setItems
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getConnectorId
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
protected AbstractListing()
AbstractListing
with a default data communicator.
protected AbstractListing(DataCommunicator<T> dataCommunicator)
AbstractListing
with the given custom data
communicator.
Note: This method is for creating an
AbstractListing
with a custom communicator. In the common case
AbstractListing()
should be used.
dataCommunicator
- the data communicator to use, not nullprotected void internalSetDataProvider(DataProvider<T,?> dataProvider)
protected <F> SerializableConsumer<F> internalSetDataProvider(DataProvider<T,F> dataProvider, F initialFilter)
protected DataProvider<T,?> internalGetDataProvider()
protected ItemCaptionGenerator<T> getItemCaptionGenerator()
protected void setItemCaptionGenerator(ItemCaptionGenerator<T> itemCaptionGenerator)
String.valueOf(Object)
is used.itemCaptionGenerator
- the item caption provider to use, not nullprotected void setItemIconGenerator(IconGenerator<T> itemIconGenerator)
Implementations that support item icons make this method public.
itemIconGenerator
- the item icon generator to set, not nullNullPointerException
- if itemIconGenerator
is null
IconGenerator
protected IconGenerator<T> getItemIconGenerator()
Implementations that support item icons make this method public.
IconGenerator
,
setItemIconGenerator(IconGenerator)
protected void addDataGenerator(DataGenerator<T> generator)
generator
- the data generator to add, not nullprotected void removeDataGenerator(DataGenerator<T> generator)
generator
- the data generator to remove, not nullpublic DataCommunicator<T> getDataCommunicator()
public void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Component
The component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.
This method must not modify the component state.
writeDesign
in interface Component
writeDesign
in class AbstractComponent
design
- The element to write the component state to. Any previous
attributes or child nodes are not cleared.designContext
- The DesignContext instance used for writing the designprotected void doWriteDesign(org.jsoup.nodes.Element design, DesignContext designContext)
This method is separated from
writeDesign(Element, DesignContext)
to be overridable in
subclasses that need to replace this, but still must be able to call
super.writeDesign(...)
.
design
- The element to write the component state to. Any previous
attributes or child nodes are not cleared.designContext
- The DesignContext instance used for writing the designdoReadDesign(Element, DesignContext)
protected void writeItems(org.jsoup.nodes.Element design, DesignContext context)
design
- the element into which to insert the itemscontext
- the DesignContext instance used in writingprotected org.jsoup.nodes.Element writeItem(org.jsoup.nodes.Element design, T item, DesignContext context)
design
- the element into which to insert the itemitem
- the item to writecontext
- the DesignContext instance used in writingitem
public void readDesign(org.jsoup.nodes.Element design, DesignContext context)
Component
The component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.
It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.
This method must not modify the design.
readDesign
in interface Component
readDesign
in class AbstractComponent
design
- The element to obtain the state fromcontext
- The DesignContext instance used for parsing the designprotected void doReadDesign(org.jsoup.nodes.Element design, DesignContext context)
This method is separated from readDesign(Element, DesignContext)
to be overridable in subclasses that need to replace this, but still must
be able to call super.readDesign(...)
.
design
- The element to obtain the state fromcontext
- The DesignContext instance used for parsing the designdoWriteDesign(Element, DesignContext)
protected abstract void readItems(org.jsoup.nodes.Element design, DesignContext context)
design
.design
- The element to obtain the state fromcontext
- The DesignContext instance used for parsing the designprotected T readItem(org.jsoup.nodes.Element child, DesignContext context)
Doesn't care about selection/value (if any).
child
- a child element representing the itemcontext
- the DesignContext instance used in parsingDesignException
- if the tag name of the child
element is not
option
.protected T deserializeDeclarativeRepresentation(String item)
Default implementation is able to handle only String
as an item
type. There will be a ClassCastException
if T
is not a
String
.
item
- string to deserializeClassCastException
- if type T
is not a String
serializeDeclarativeRepresentation(Object)
protected String serializeDeclarativeRepresentation(T item)
item
to a string for saving declarative format.
Default implementation delegates a call to item.toString()
.
item
- a data itemitem
.deserializeDeclarativeRepresentation(String)
protected AbstractListingState getState()
AbstractComponent
getState
in class AbstractComponent
protected AbstractListingState getState(boolean markAsDirty)
AbstractClientConnector
getState
in class AbstractComponent
markAsDirty
- true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()
public void focus()
AbstractComponent
Focusable
.focus
in interface Component.Focusable
focus
in class AbstractComponent
FieldEvents
,
FieldEvents.FocusEvent
,
FieldEvents.FocusListener
,
FieldEvents.BlurEvent
,
FieldEvents.BlurListener
public int getTabIndex()
Component.Focusable
Focusable
component.getTabIndex
in interface Component.Focusable
Focusable
componentComponent.Focusable.setTabIndex(int)
public void setTabIndex(int tabIndex)
Component.Focusable
Focusable
component.
The tab index property is used to specify the order in which the
fields are focused when the user presses the Tab key. Components with
a defined tab index are focused sequentially first, and then the
components with no tab index.
Form loginBox = new Form(); loginBox.setCaption("Login"); layout.addComponent(loginBox); // Create the first field which will be focused TextField username = new TextField("User name"); loginBox.addField("username", username); // Set focus to the user name username.focus(); TextField password = new TextField("Password"); loginBox.addField("password", password); Button login = new Button("Login"); loginBox.getFooter().addComponent(login); // An additional component which natural focus order would // be after the button. CheckBox remember = new CheckBox("Remember me"); loginBox.getFooter().addComponent(remember); username.setTabIndex(1); password.setTabIndex(2); remember.setTabIndex(3); // Different than natural place login.setTabIndex(4);
After all focusable user interface components are done, the browser can begin again from the component with the smallest tab index, or it can take the focus out of the page, for example, to the location bar.
If the tab index is not set (is set to zero), the default tab order is used. The order is somewhat browser-dependent, but generally follows the HTML structure of the page.
A negative value means that the component is completely removed from the tabulation order and can not be reached by pressing the Tab key at all.
setTabIndex
in interface Component.Focusable
tabIndex
- the tab order of this component. Indexes usually start
from 1. Zero means that default tab order should be used.
A negative value means that the field should not be
included in the tabbing sequence.Component.Focusable.getTabIndex()
Copyright © 2019 Vaadin Ltd. All rights reserved.