Package eu.webtoolkit.jwt
Class WEnumModel<E extends java.lang.Enum<E>>
- java.lang.Object
-
- eu.webtoolkit.jwt.WObject
-
- eu.webtoolkit.jwt.WAbstractItemModel
-
- eu.webtoolkit.jwt.WAbstractTableModel
-
- eu.webtoolkit.jwt.WEnumModel<E>
-
public class WEnumModel<E extends java.lang.Enum<E>> extends WAbstractTableModel
A model that lists the different values of an Enum. This model is often used in conjunction with aWSelectionBoxorWComboBoxto 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. AsItemDataRole.Display, theEnum.toString()function is returned while asItemDataRole.User, the actual Enum value is returned.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
-
Constructor Summary
Constructors Constructor Description WEnumModel(java.lang.Class<E> enumType)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetColumnCount(WModelIndex parent)Returns the number of columns.java.lang.ObjectgetData(WModelIndex index, ItemDataRole role)Returns data at a specified model index for the given role.EgetObject(int row)Returns the enum value corresponding to a row.intgetRow(E value)Returns the row corresponding to an enum value.intgetRowCount(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 Detail
-
WEnumModel
public WEnumModel(java.lang.Class<E> enumType)
Constructor.- Parameters:
enumType- the enum class (e.g. MyEnum.class).
-
-
Method Detail
-
getColumnCount
public int getColumnCount(WModelIndex parent)
Description copied from class:WAbstractItemModelReturns the number of columns.This returns the number of columns at index
parent.- Specified by:
getColumnCountin classWAbstractItemModel- See Also:
WAbstractItemModel.getRowCount(WModelIndex parent)
-
getData
public java.lang.Object getData(WModelIndex index, ItemDataRole role)
Description copied from class:WAbstractItemModelReturns data at a specified model index for the given role.You should check the
roleto 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
public int getRowCount(WModelIndex parent)
Description copied from class:WAbstractItemModelReturns the number of rows.This returns the number of rows at index
parent.- Specified by:
getRowCountin classWAbstractItemModel- See Also:
WAbstractItemModel.getColumnCount(WModelIndex parent)
-
getObject
public E getObject(int row)
Returns the enum value corresponding to a row.- Parameters:
row-- Returns:
- the enum value corresponding to a row.
- See Also:
getRow(Enum)
-
getRow
public int getRow(E value)
Returns the row corresponding to an enum value.- Parameters:
value- enum value- Returns:
- the row of that value.
- See Also:
getObject(int)
-
-