public class GroupedListBox extends SingleListBox
Rather than provide a separate API, it uses the names of the OPTION elements to establish the grouping using a simple syntax. The text before the first "|" character is used as the group name and is used to group elements inside an OPTGROUP of that name. The rest of the text is used as the text of the OPTION.
It uses "doubling" for escaping so if "||" appears in the name, it is converted to a single "|" and the first single "|" is used as the delimiter.
As a simple example, in a normal listbox I might have:
- Item 1A - Item 2A - Item 1B - Item 2B
You could imaging using a text prefix to represent groups so that you have:
- Group A | Item 1 - Group A | Item 2 - Group B | Item 1 - Group B | Item 2
The ListBox would get wide and hard to read. But if you add those same items to a GroupedListBox, it will create OPTGROUPS automatically so that you will have:
- Group A -- Item 1 -- Item 2 - Group B -- Item 1 -- Item 2
With regard to indexes and selection, it will mostly work the same as a normal ListBox. The one difference is that it will not repeat groups. This means that if you add the items in this order:
- Group A | Item 1 - Group B | Item 1 - Group A | Item 2 - Group B | Item 2then you will rearrange the items to group them:
- Group A -- Item 1 -- Item 2 - Group B -- Item 1 -- Item 2Note: Though it can be used with a multiple select control, this extends SingleListBox to provide
SingleListBox.setValue(String)
and
other useful methods.UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
DEFAULT_DIRECTION_ESTIMATOR
DEBUG_ID_PREFIX
Constructor and Description |
---|
GroupedListBox() |
GroupedListBox(boolean isMultipleSelect) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkIndex(int index) |
void |
clear() |
protected com.tractionsoftware.gwt.user.client.ui.GroupedListBox.RealOptGroup |
createOptGroup(String groupName) |
protected OptionElement |
createOption(String item,
String value) |
protected com.tractionsoftware.gwt.user.client.ui.GroupedListBox.OptGroup |
findOptGroup(String groupName) |
protected int |
getChildCount() |
protected int |
getIndexInGroup(String groupName,
int index) |
protected int |
getIndexOfFirstGroup() |
int |
getItemCount() |
int |
getItemCountFromGroups()
This is provided for testing purposes only.
|
String |
getItemText(int index) |
protected com.tractionsoftware.gwt.user.client.ui.GroupedListBox.OptGroup |
getOptGroup(int index) |
protected OptionElement |
getOption(int index) |
int |
getSelectedIndex() |
protected SelectElement |
getSelectElement() |
String |
getValue(int index) |
void |
insertItem(String item,
String value,
int index) |
boolean |
isItemSelected(int index) |
protected void |
onLoad() |
protected void |
onUnload() |
void |
removeItem(int index) |
void |
setItemSelected(int index,
boolean selected) |
void |
setItemText(int index,
String text) |
void |
setSelectedIndex(int index) |
void |
setValue(int index,
String value) |
addValueChangeHandler, findValueIndex, findValueInListBox, getAddMissingValue, getSelectedText, getSelectedValue, getValue, setAddMissingValue, setSelectedValue, setValue, setValue
addChangeHandler, addChangeListener, addItem, addItem, addItem, addItem, getDirectionEstimator, getName, getOptionText, getVisibleItemCount, insertItem, insertItem, insertItem, isMultipleSelect, onEnsureDebugId, removeChangeListener, setDirectionEstimator, setDirectionEstimator, setItemText, setMultipleSelect, setName, setOptionText, setVisibleItemCount, wrap
addBlurHandler, addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addFocusHandler, addFocusListener, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addKeyboardListener, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, getFocusImpl, getTabIndex, isEnabled, onAttach, removeClickListener, removeFocusListener, removeKeyboardListener, removeMouseListener, removeMouseWheelListener, setAccessKey, setEnabled, setFocus, setTabIndex
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onBrowserEvent, onDetach, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
fireEvent
public GroupedListBox()
public GroupedListBox(boolean isMultipleSelect)
public int getItemCount()
getItemCount
in class ListBox
public int getItemCountFromGroups()
public String getItemText(int index)
getItemText
in class ListBox
public int getSelectedIndex()
getSelectedIndex
in class ListBox
public void insertItem(String item, String value, int index)
insertItem
in class ListBox
public boolean isItemSelected(int index)
isItemSelected
in class ListBox
public void removeItem(int index)
removeItem
in class ListBox
public void setItemSelected(int index, boolean selected)
setItemSelected
in class ListBox
public void setItemText(int index, String text)
setItemText
in class ListBox
public void setSelectedIndex(int index)
setSelectedIndex
in class ListBox
protected SelectElement getSelectElement()
protected void checkIndex(int index)
protected int getChildCount()
protected com.tractionsoftware.gwt.user.client.ui.GroupedListBox.OptGroup findOptGroup(String groupName)
protected com.tractionsoftware.gwt.user.client.ui.GroupedListBox.OptGroup getOptGroup(int index)
protected com.tractionsoftware.gwt.user.client.ui.GroupedListBox.RealOptGroup createOptGroup(String groupName)
protected OptionElement getOption(int index)
protected int getIndexOfFirstGroup()
protected int getIndexInGroup(String groupName, int index)
protected OptionElement createOption(String item, String value)
Copyright © 2015. All Rights Reserved.