Package eu.webtoolkit.jwt
Class WEnumModel<E extends Enum<E>>
java.lang.Object
eu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.WAbstractItemModel
eu.webtoolkit.jwt.WAbstractTableModel
eu.webtoolkit.jwt.WEnumModel<E>
A model that lists the different values of an Enum.
This model is often used in conjunction with a
WSelectionBox
or WComboBox
to allow
a user to make a choice of a possible value of an enumerated type.
The model has one column, and as many rows as the enum has values.
As ItemDataRole.Display
, the Enum.toString()
function is returned while
as ItemDataRole.User
, the actual Enum value is returned.-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
getColumnCount
(WModelIndex parent) Returns the number of columns.getData
(WModelIndex index, ItemDataRole role) Returns data at a specified model index for the given role.getObject
(int row) Returns the enum value corresponding to a row.int
Returns the row corresponding to an enum value.int
getRowCount
(WModelIndex parent) Returns the number of rows.Methods inherited from class eu.webtoolkit.jwt.WAbstractTableModel
getIndex, getParent
Methods inherited from class eu.webtoolkit.jwt.WAbstractItemModel
beginInsertColumns, beginInsertRows, beginRemoveColumns, beginRemoveRows, collapseColumn, columnsAboutToBeInserted, columnsAboutToBeRemoved, columnsInserted, columnsRemoved, copyData, createIndex, createIndex, dataChanged, dropEvent, dropEvent, endInsertColumns, endInsertRows, endRemoveColumns, endRemoveRows, expandColumn, fromRawIndex, getAcceptDropMimeTypes, getColumnCount, getData, getData, getData, getData, getFlags, getHeaderData, getHeaderData, getHeaderData, getHeaderFlags, getHeaderFlags, getIndex, getItemData, getMimeType, getRowCount, hasChildren, hasIndex, hasIndex, headerDataChanged, insertColumn, insertColumn, insertColumns, insertColumns, insertRow, insertRow, insertRows, insertRows, layoutAboutToBeChanged, layoutChanged, match, modelReset, removeColumn, removeColumn, removeColumns, removeColumns, removeRow, removeRow, removeRows, removeRows, reset, rowsAboutToBeInserted, rowsAboutToBeRemoved, rowsInserted, rowsRemoved, setData, setData, setData, setData, setData, setHeaderData, setHeaderData, setHeaderData, setItemData, sort, sort, toRawIndex
Methods inherited from class eu.webtoolkit.jwt.WObject
getId, getObjectName, remove, setFormData, setObjectName, tr
-
Constructor Details
-
WEnumModel
Constructor.- Parameters:
enumType
- the enum class (e.g. MyEnum.class).
-
-
Method Details
-
getColumnCount
Description copied from class:WAbstractItemModel
Returns the number of columns.This returns the number of columns at index
parent
.- Specified by:
getColumnCount
in classWAbstractItemModel
- See Also:
-
getData
Description copied from class:WAbstractItemModel
Returns data at a specified model index for the given role.You should check the
role
to decide what data to return. Usually a View class will ask for data for several roles which affect not only the contents (ItemDataRole.Display
) but also icons (ItemDataRole.Decoration
), URLs (ItemDataRole.Link
), and other visual aspects. If your item does not specify data for a particular role, it should simply return a Wt::cpp17::any(). -
getRowCount
Description copied from class:WAbstractItemModel
Returns the number of rows.This returns the number of rows at index
parent
.- Specified by:
getRowCount
in classWAbstractItemModel
- See Also:
-
getObject
Returns the enum value corresponding to a row.- Parameters:
row
-- Returns:
- the enum value corresponding to a row.
- See Also:
-
getRow
Returns the row corresponding to an enum value.- Parameters:
value
- enum value- Returns:
- the row of that value.
- See Also:
-