|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.WAbstractItemDelegate
public abstract class WAbstractItemDelegate
Abstract delegate class for rendering an item in an item view.
Rendering of an item in a WAbstractItemView is delegated to an
implementation of this delegate class. The default implementation used by
Wt's item views is WItemDelegate. To provide specialized
rendering support, you can reimplement this class (or specialize
WItemDelegate).
As a delegate is used for rendering multiple items, the class should not keep state about one specific item.
A delegate may provide editing support by instantiating an editor when
update() is called with the ViewItemRenderFlag.RenderEditing flag.
In that case, you will also need to implement
getEditState() and
setEditState() to support virtual scrolling and
setModelData() to save the edited value to the model. For an example, see
the WItemDelegate.
WAbstractItemView.setItemDelegateForColumn(int column,
WAbstractItemDelegate delegate)| Constructor Summary | |
|---|---|
WAbstractItemDelegate()
Constructor. |
|
WAbstractItemDelegate(WObject parent)
Constructor. |
|
| Method Summary | |
|---|---|
Signal2<WWidget,java.lang.Boolean> |
closeEditor()
Signal which indicates that an editor needs to be closed. |
java.lang.Object |
getEditState(WWidget widget)
Returns the current edit state. |
void |
setEditState(WWidget widget,
java.lang.Object value)
Sets the editor data from the editor state. |
void |
setModelData(java.lang.Object editState,
WAbstractItemModel model,
WModelIndex index)
Saves the edited data to the model. |
abstract WWidget |
update(WWidget widget,
WModelIndex index,
java.util.EnumSet<ViewItemRenderFlag> flags)
Creates or updates a widget that renders an item. |
WWidget |
update(WWidget widget,
WModelIndex index,
ViewItemRenderFlag flag,
ViewItemRenderFlag... flags)
Creates or updates a widget that renders an item. |
void |
updateModelIndex(WWidget widget,
WModelIndex index)
Updates the model index of a widget. |
WValidator.State |
validate(WModelIndex index,
java.lang.Object editState)
Returns whether the edited value is valid. |
| Methods inherited from class eu.webtoolkit.jwt.WObject |
|---|
getId, getObjectName, remove, setObjectName, tr |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WAbstractItemDelegate(WObject parent)
public WAbstractItemDelegate()
Calls this((WObject)null)
| Method Detail |
|---|
public abstract WWidget update(WWidget widget,
WModelIndex index,
java.util.EnumSet<ViewItemRenderFlag> flags)
The item is specified by its model index, which also
indicates the model. If an existing widget already renders the item, but
needs to be updated, it is passed as the widget parameter.
You may decide to create a new widget, in which case you are responsible
to delete the previous widget if it is not reused.
When widget is null, a new widget needs to be
created.
The returned widget should be a widget that responds properly to be given
a height, width and style class. In practice, that means it cannot have a
border or margin, and thus cannot be a WFormWidget since those
widgets typically have built-in borders and margins. If you want to
return a form widget (for editing the item), you should wrap it in a
container widget.
The flags parameter indicates options for rendering the
item.
public final WWidget update(WWidget widget,
WModelIndex index,
ViewItemRenderFlag flag,
ViewItemRenderFlag... flags)
Returns update(widget, index, EnumSet.of(flag, flags))
public void updateModelIndex(WWidget widget,
WModelIndex index)
This method is invoked by the view when due to row/column insertions or removals, the index has shifted.
You should reimplement this method only if you are storing the model
index in the widget, to update the stored model index.
The default implementation does nothing.
public java.lang.Object getEditState(WWidget widget)
Because a View may support virtual scrolling in combination with editing, it may happen that the view decides to delete the editor widget while the user is editing. To allow to reconstruct the editor in its original state, the View will therefore ask for the editor to serialize its state in a boost::any.
When the view decides to close an editor and save its value back to the
model, he will first call
getEditState()
and then
setModelData().
The default implementation assumes a read-only delegate, and returns a boost::any().
setEditState(WWidget widget, Object value),
setModelData(Object editState,
WAbstractItemModel model, WModelIndex index)
public void setEditState(WWidget widget,
java.lang.Object value)
When the View scrolls back into view an item that was being edited, he
will use
setEditState() to allow the editor to restore its current editor state.
The default implementation assumes a read-only delegate and does nothing.
getEditState(WWidget widget)
public WValidator.State validate(WModelIndex index,
java.lang.Object editState)
The default implementation does nothing and returns Valid.
WValidator.validate(String input)
public void setModelData(java.lang.Object editState,
WAbstractItemModel model,
WModelIndex index)
The View will use this method to save the edited value to the model. The
editState is first fetched from the editor using
getEditState().
The default implementation assumes a read-only delegate does nothing.
public Signal2<WWidget,java.lang.Boolean> closeEditor()
The delegate should emit this signal when it decides for itself that it should be closed (e.g. because the user confirmed the edited value or cancelled the editing). The View will then rerender the item if needed.
The second boolean argument passed to the signal is a flag which indicates whether the editor feels that the value should be saved or cancelled.
WAbstractItemView.closeEditor(WModelIndex index, boolean saveData)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||