org.xwiki.gwt.user.client.ui
Class ListBox<T>

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Composite
              extended by org.xwiki.gwt.user.client.ui.ListBox<T>
Type Parameters:
T - the data type that can be attached to list items
All Implemented Interfaces:
com.google.gwt.event.dom.client.ClickHandler, com.google.gwt.event.dom.client.HasAllKeyHandlers, com.google.gwt.event.dom.client.HasDoubleClickHandlers, com.google.gwt.event.dom.client.HasKeyDownHandlers, com.google.gwt.event.dom.client.HasKeyPressHandlers, com.google.gwt.event.dom.client.HasKeyUpHandlers, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.logical.shared.HasSelectionHandlers<ListItem<T>>, com.google.gwt.event.shared.EventHandler, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.Focusable, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.IsRenderable, com.google.gwt.user.client.ui.IsWidget

public class ListBox<T>
extends com.google.gwt.user.client.ui.Composite
implements com.google.gwt.event.logical.shared.HasSelectionHandlers<ListItem<T>>, com.google.gwt.event.dom.client.HasDoubleClickHandlers, com.google.gwt.event.dom.client.HasAllKeyHandlers, com.google.gwt.event.dom.client.ClickHandler, com.google.gwt.user.client.ui.Focusable

Displays a list of items allowing us to select one using the mouse or the keyboard.

Version:
$Id: a2bdf43bf958fbecfedde25a7e97eff810c769bb $

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
ListBox()
          Creates a new list box.
 
Method Summary
 com.google.gwt.event.shared.HandlerRegistration addDoubleClickHandler(com.google.gwt.event.dom.client.DoubleClickHandler handler)
           
 void addItem(ListItem<T> item)
          Adds a new item to the list.
 com.google.gwt.event.shared.HandlerRegistration addKeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addKeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler handler)
           
 com.google.gwt.event.shared.HandlerRegistration addSelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler<ListItem<T>> handler)
           
 void clear()
          Removes all the items from this list.
 ListItem<T> getItem(int index)
           
 int getItemCount()
           
 ListItem<T> getItemForEvent(com.google.gwt.event.dom.client.DomEvent<?> event)
          Finds the list item that is the target of the specified DOM event.
 ListItem<T> getSelectedItem()
           
 int getTabIndex()
           
 void insertItem(ListItem<T> item, int beforeIndex)
          Inserts an item before the specified position.
 void onClick(com.google.gwt.event.dom.client.ClickEvent event)
           
 void removeItem(ListItem<T> item)
          Removes an item from this list.
protected  void selectFirstItem()
          Selects the first list item if the list is not empty.
protected  void selectLastItem()
          Selects the last list item if the list of not empty.
protected  void selectNextItem()
          Selects the next list item with respect to the currently selected item.
protected  void selectPreviousItem()
          Selects the previous list item with respect to the currently selected item.
 void setAccessKey(char key)
           
 void setFocus(boolean focused)
           
 void setSelectedItem(ListItem<T> item)
          Selects the specified list item.
 void setTabIndex(int index)
           
protected  void updateSelectedItem(Event event)
          Updates the selected item based on the native keyboard event that was fired.
 
Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 

Constructor Detail

ListBox

public ListBox()
Creates a new list box.

Method Detail

addItem

public void addItem(ListItem<T> item)
Adds a new item to the list.

Parameters:
item - the item to be added

getItem

public ListItem<T> getItem(int index)
Parameters:
index - a valid list item index
Returns:
the list item at the specified index in this list

insertItem

public void insertItem(ListItem<T> item,
                       int beforeIndex)
Inserts an item before the specified position.

Parameters:
item - the item to be inserted
beforeIndex - the index before which to insert the item

removeItem

public void removeItem(ListItem<T> item)
Removes an item from this list.

Parameters:
item - the list item to be removed

clear

public void clear()
Removes all the items from this list.


addSelectionHandler

public com.google.gwt.event.shared.HandlerRegistration addSelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler<ListItem<T>> handler)
Specified by:
addSelectionHandler in interface com.google.gwt.event.logical.shared.HasSelectionHandlers<ListItem<T>>

addDoubleClickHandler

public com.google.gwt.event.shared.HandlerRegistration addDoubleClickHandler(com.google.gwt.event.dom.client.DoubleClickHandler handler)
Specified by:
addDoubleClickHandler in interface com.google.gwt.event.dom.client.HasDoubleClickHandlers

addKeyDownHandler

public com.google.gwt.event.shared.HandlerRegistration addKeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler handler)
Specified by:
addKeyDownHandler in interface com.google.gwt.event.dom.client.HasKeyDownHandlers

addKeyPressHandler

public com.google.gwt.event.shared.HandlerRegistration addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler handler)
Specified by:
addKeyPressHandler in interface com.google.gwt.event.dom.client.HasKeyPressHandlers

addKeyUpHandler

public com.google.gwt.event.shared.HandlerRegistration addKeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler handler)
Specified by:
addKeyUpHandler in interface com.google.gwt.event.dom.client.HasKeyUpHandlers

getSelectedItem

public ListItem<T> getSelectedItem()
Returns:
the list item currently selected

setSelectedItem

public void setSelectedItem(ListItem<T> item)
Selects the specified list item.

Parameters:
item - the list item to be selected

onClick

public void onClick(com.google.gwt.event.dom.client.ClickEvent event)
Specified by:
onClick in interface com.google.gwt.event.dom.client.ClickHandler

getItemForEvent

public ListItem<T> getItemForEvent(com.google.gwt.event.dom.client.DomEvent<?> event)
Finds the list item that is the target of the specified DOM event.

Parameters:
event - the DOM event that was fired
Returns:
the target list item if found, null otherwise

updateSelectedItem

protected void updateSelectedItem(Event event)
Updates the selected item based on the native keyboard event that was fired.

Parameters:
event - the native event that was fired

selectPreviousItem

protected void selectPreviousItem()
Selects the previous list item with respect to the currently selected item.


selectNextItem

protected void selectNextItem()
Selects the next list item with respect to the currently selected item.


selectFirstItem

protected void selectFirstItem()
Selects the first list item if the list is not empty.


selectLastItem

protected void selectLastItem()
Selects the last list item if the list of not empty.


getItemCount

public int getItemCount()
Returns:
the number of list items in this list box

getTabIndex

public int getTabIndex()
Specified by:
getTabIndex in interface com.google.gwt.user.client.ui.Focusable

setTabIndex

public void setTabIndex(int index)
Specified by:
setTabIndex in interface com.google.gwt.user.client.ui.Focusable

setFocus

public void setFocus(boolean focused)
Specified by:
setFocus in interface com.google.gwt.user.client.ui.Focusable

setAccessKey

public void setAccessKey(char key)
Specified by:
setAccessKey in interface com.google.gwt.user.client.ui.Focusable


Copyright © 2004-2012 XWiki. All Rights Reserved.