M
- the model typeW
- the item widget type, needs to implement HasModel
for
associating the widget instance with the corresponding model
instance.public abstract class ListWidget<M,W extends HasModel<M> & com.google.gwt.user.client.ui.IsWidget> extends com.google.gwt.user.client.ui.Composite implements com.google.gwt.user.client.ui.HasValue<List<M>>, BindableListChangeHandler<M>
ComplexPanel
. By default, a
FlowPanel
is used, but an alternative can be specified using
ListWidget(ComplexPanel)
.Modifier | Constructor and Description |
---|---|
protected |
ListWidget() |
protected |
ListWidget(com.google.gwt.user.client.ui.ComplexPanel panel) |
Modifier and Type | Method and Description |
---|---|
com.google.gwt.event.shared.HandlerRegistration |
addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<List<M>> handler) |
protected abstract Class<W> |
getItemWidgetType()
Returns the class object for the item widget type
|
protected com.google.gwt.user.client.ui.ComplexPanel |
getPanel()
Returns the panel that contains all item widgets.
|
List<M> |
getValue() |
W |
getWidget(int index)
Returns the widget at the specified index.
|
W |
getWidget(M model)
Returns the widget currently displaying the provided model.
|
int |
getWidgetCount()
Returns the number of widgets currently being displayed.
|
void |
onItemAdded(List<M> oldList,
M item)
Called when a single item has been appended to the list.
|
void |
onItemAddedAt(List<M> oldList,
int index,
M item)
Called when a single item has been added to the list at the provided index.
|
void |
onItemChanged(List<M> oldList,
int index,
M item)
Called when a single item has been changed.
|
void |
onItemRemovedAt(List<M> oldList,
int index)
Called when a single item has been removed from the list at the provided index.
|
void |
onItemsAdded(List<M> oldList,
Collection<? extends M> items)
Called when multiple items have been appended to the list.
|
void |
onItemsAddedAt(List<M> oldList,
int index,
Collection<? extends M> item)
Called when multiple items have been added to the list starting at the provided index.
|
void |
onItemsCleared(List<M> oldList)
Called when all items have been removed from the list.
|
void |
onItemsRemovedAt(List<M> oldList,
List<Integer> indexes)
Called when multiple items have been removed from the list.
|
protected void |
onItemsRendered(List<M> items)
Called after all item widgets have been rendered.
|
void |
setItems(List<M> items)
Sets the list of model objects.
|
void |
setValue(List<M> value) |
void |
setValue(List<M> value,
boolean fireEvents) |
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
protected ListWidget()
protected ListWidget(com.google.gwt.user.client.ui.ComplexPanel panel)
protected abstract Class<W> getItemWidgetType()
protected void onItemsRendered(List<M> items)
Using the standard synchronous bean manager this method is invoked before
setItems(List)
returns. However, when using the asynchronous bean
manager and declaring @LoadAsync on the item widget, this method might be
called after setItems(List)
returns and after the corresponding
JavaScript code has been downloaded.
items
- the rendered item list. Every change to this list will update the
corresponding rendered item widgets.protected com.google.gwt.user.client.ui.ComplexPanel getPanel()
public void setItems(List<M> items)
BindableListWrapper
to make direct changes to the list observable.
If the standard synchronous bean manager is used it is guaranteed that all
widgets have been added to the panel when this method returns. In case the
asynchronous bean manager is used this method might return before the
widgets have been added to the panel. See onItemsRendered(List)
.
items
- The list of model objects. If null or empty all existing child
widgets will be removed.public W getWidget(int index)
index
- the index to be retrievedIndexOutOfBoundsException
- if the index is out of rangepublic W getWidget(M model)
model
- the model displayed by the widgetpublic int getWidgetCount()
public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<List<M>> handler)
public void onItemAdded(List<M> oldList, M item)
BindableListChangeHandler
onItemAdded
in interface BindableListChangeHandler<M>
oldList
- a list representing the state before the item was appended (equal to the old value of the
list). Never null.item
- the added item. May be null.public void onItemAddedAt(List<M> oldList, int index, M item)
BindableListChangeHandler
onItemAddedAt
in interface BindableListChangeHandler<M>
oldList
- a list representing the state before the item was added (equal to the old value of the
list). Never null.index
- the index at which the item has been added.item
- the added item. May be null.public void onItemsAdded(List<M> oldList, Collection<? extends M> items)
BindableListChangeHandler
onItemsAdded
in interface BindableListChangeHandler<M>
oldList
- a list representing the state before the items were appended (equal to the old value of
the list). Never null.items
- the added items. May contain null elements.public void onItemsAddedAt(List<M> oldList, int index, Collection<? extends M> item)
BindableListChangeHandler
onItemsAddedAt
in interface BindableListChangeHandler<M>
oldList
- a list representing the state before the items were added (equal to the old value of
the list). Never null.index
- the index at which the items have been added.public void onItemsCleared(List<M> oldList)
BindableListChangeHandler
onItemsCleared
in interface BindableListChangeHandler<M>
oldList
- a list representing the state before all items were removed (equal to the old value of
the list). Never null.public void onItemRemovedAt(List<M> oldList, int index)
BindableListChangeHandler
onItemRemovedAt
in interface BindableListChangeHandler<M>
oldList
- a list representing the state before the item was removed (equal to the old value of
the list). Never null.index
- the index at which the item has been removed.public void onItemsRemovedAt(List<M> oldList, List<Integer> indexes)
BindableListChangeHandler
onItemsRemovedAt
in interface BindableListChangeHandler<M>
oldList
- a list representing the state before the items were removed (equal to the old value of
the list). Never null.public void onItemChanged(List<M> oldList, int index, M item)
BindableListChangeHandler
onItemChanged
in interface BindableListChangeHandler<M>
oldList
- a list representing the state before the item was changed (equal to the old value of
the list). Never null.index
- the index of the item that has changed.item
- the new value of the item at the provided index.Copyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.