eu.webtoolkit.jwt
Class WSelectionBox

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WWidget
          extended by eu.webtoolkit.jwt.WWebWidget
              extended by eu.webtoolkit.jwt.WInteractWidget
                  extended by eu.webtoolkit.jwt.WFormWidget
                      extended by eu.webtoolkit.jwt.WComboBox
                          extended by eu.webtoolkit.jwt.WSelectionBox

public class WSelectionBox
extends WComboBox

A selection box allows selection from a list of options.

By default, a selection box may be used to let the user select one item from a list. This may be changed to multiple selection mode using setSelectionMode().

The current selection may be set and read using WComboBox#setCurrentIndex() and WComboBox#getCurrentIndex(), for SingleSelection mode, or setSelectedIndexes() and getSelectedIndexes() for SelectionMode.ExtendedSelection mode. The WComboBox#activated() and WComboBox#sactivated() signals are not emited in the SelectionMode.ExtendedSelection mode, use the WFormWidget#changed() signal WFormWidget#changed().

WSelectionBox is an MVC view class, using a simple string list model by default. The model may be populated using WComboBox#addItem() or WComboBox#insertItem() and the contents can be cleared through WComboBox#clear(). These methods manipulate the underlying WComboBox#getModel().

To use the selectionbox with a custom model instead of the default WStringListModel, use WComboBox#setModel().

WSelectionBox is an inline widget.

CSS

The widget corresponds to the HTML <select> tag and does not provide styling. It can be styled using inline or external CSS as appropriate.


Constructor Summary
WSelectionBox()
          Constructor.
WSelectionBox(WContainerWidget parent)
          Constructor.
 
Method Summary
 void clearSelection()
          Clears the current selection.
 java.util.Set<java.lang.Integer> getSelectedIndexes()
          Returns the current selection (in SelectionMode.ExtendedSelection mode).
 SelectionMode getSelectionMode()
          Returns the selection mode.
 int getVerticalSize()
          Sets the number of items that are visible.
 void setSelectedIndexes(java.util.Set<java.lang.Integer> selection)
          Sets the selection (in SelectionMode.ExtendedSelection mode).
 void setSelectionMode(SelectionMode mode)
          Sets the selection mode.
 void setVerticalSize(int items)
          Returns the number of items that are visible.
 
Methods inherited from class eu.webtoolkit.jwt.WComboBox
activated, addItem, clear, findText, getCount, getCurrentIndex, getCurrentText, getItemText, getModel, getValueText, insertItem, refresh, removeItem, sactivated, setCurrentIndex, setItemText, setModel, setModelColumn, setValueText
 
Methods inherited from class eu.webtoolkit.jwt.WFormWidget
blurred, changed, enableAjax, focussed, getEmptyText, getLabel, getTabIndex, getValidator, hasFocus, isReadOnly, propagateSetEnabled, remove, render, selected, setEmptyText, setEnabled, setFocus, setFocus, setHidden, setReadOnly, setTabIndex, setValidator, validate, validated
 
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, setDraggable, setDraggable, setDraggable, setDraggable, touchEnded, touchMoved, touchStarted
 
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, callJavaScriptMember, childrenChanged, doJavaScript, domCanBeSaved, escapeText, escapeText, escapeText, escapeText, find, getAttributeValue, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getStyleClass, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isVisible, jsStringLiteral, jsStringLiteral, removeScript, removeStyleClass, resize, setAttributeValue, setClearSides, setDecorationStyle, setDisabled, setFloatSide, setHiddenKeepsGeometry, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPopup, setPositionScheme, setSelectable, setStyleClass, setToolTip, setVerticalAlignment, updateSignalConnection
 
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
 
Methods inherited from class eu.webtoolkit.jwt.WObject
addChild, getObjectName, setObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WSelectionBox

public WSelectionBox(WContainerWidget parent)
Constructor.


WSelectionBox

public WSelectionBox()
Constructor.

Calls this((WContainerWidget)null)

Method Detail

getVerticalSize

public int getVerticalSize()
Sets the number of items that are visible.

If more items are available, a scroll-bar is provided.


setVerticalSize

public void setVerticalSize(int items)
Returns the number of items that are visible.


setSelectionMode

public void setSelectionMode(SelectionMode mode)
Sets the selection mode.

The default selection mode is SingleSelection. You can change to SelectionMode.ExtendedSelection to allow selection of multiple items.


getSelectionMode

public SelectionMode getSelectionMode()
Returns the selection mode.

See Also:
setSelectionMode(SelectionMode mode)

getSelectedIndexes

public java.util.Set<java.lang.Integer> getSelectedIndexes()
Returns the current selection (in SelectionMode.ExtendedSelection mode).

Get the list of currently selected items. This method is only defined when getSelectionMode() is SelectionMode.ExtendedSelection. Otherwise, you should use WComboBox#getCurrentIndex() to get item currently selected.

See Also:
WComboBox.getCurrentIndex()

setSelectedIndexes

public void setSelectedIndexes(java.util.Set<java.lang.Integer> selection)
Sets the selection (in SelectionMode.ExtendedSelection mode).

For an SelectionMode.ExtendedSelection mode, set the list of currently selected items.

See Also:
getSelectedIndexes()

clearSelection

public void clearSelection()
Clears the current selection.

Clears the current selection.

See Also:
WComboBox.setCurrentIndex(int index), setSelectedIndexes(Set selection)