com.maryanovsky.gwtutils.client.ui
Class DropDownList

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 com.maryanovsky.gwtutils.client.ui.DropDownList
All Implemented Interfaces:
HasAttachHandlers, HasValueChangeHandlers<Integer>, HasHandlers, EventListener, HasVisibility, IsRenderable, IsWidget

public class DropDownList
extends Composite
implements HasValueChangeHandlers<Integer>

A simple drop down list. The CSS style names of this widget are

Author:
Maryanovsky Alexander

Nested Class Summary
static interface DropDownList.Resources
          The interface for the resources required by a drop-down list.
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
 
Field Summary
 PopupPanel popup
          The popup.
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
DropDownList()
          Creates a new DropDownList which will use a character to represent the arrow.
DropDownList(DropDownList.Resources resources)
          Creates a new DropDownList with the specified DropDownList.Resources.
 
Method Summary
 void addItem(String item)
          Adds an item.
 HandlerRegistration addValueChangeHandler(ValueChangeHandler<Integer> handler)
          Adds a handler for change of the selected index.
protected  Widget createDropDownArrow(DropDownList.Resources resources)
          Creates the dropdown arrow widget from the specified resources.
protected  Widget createPopupSelectionList()
          Creates the widget to be displayed in the popup to select an item.
 String getItem(int index)
          Returns the item at the specified index.
 int getItemCount()
          Returns the number of items.
 PopupPanel getPopup()
          Returns the popup panel in which the items are displayed for selection.
 int getSelectedIndex()
          Returns the currently selected index; -1 if none.
 void insertItem(String item, int index)
          Inserts an item at the specified index.
 void removeItem(int index)
          Removes the item at the specified index.
 void setSelectedIndex(int index)
          Sets the item with the specified index to be selected.
 
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
 

Field Detail

popup

public final PopupPanel popup
The popup.

Constructor Detail

DropDownList

public DropDownList()
Creates a new DropDownList which will use a character to represent the arrow.


DropDownList

public DropDownList(DropDownList.Resources resources)
Creates a new DropDownList with the specified DropDownList.Resources.

Method Detail

createDropDownArrow

protected Widget createDropDownArrow(DropDownList.Resources resources)
Creates the dropdown arrow widget from the specified resources. If resources is not null, the default implementation returns an Image created from the ImageResource returned by DropDownList.Resources.dropDownArrowIcon(). Otherwise, it returns a label with a down-pointing triangle character.


addValueChangeHandler

public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Integer> handler)
Adds a handler for change of the selected index.

Specified by:
addValueChangeHandler in interface HasValueChangeHandlers<Integer>

addItem

public void addItem(String item)
Adds an item.


insertItem

public void insertItem(String item,
                       int index)
Inserts an item at the specified index.


removeItem

public void removeItem(int index)
Removes the item at the specified index.


getItem

public String getItem(int index)
Returns the item at the specified index.


getItemCount

public int getItemCount()
Returns the number of items.


getSelectedIndex

public int getSelectedIndex()
Returns the currently selected index; -1 if none.


setSelectedIndex

public void setSelectedIndex(int index)
Sets the item with the specified index to be selected.


getPopup

public final PopupPanel getPopup()
Returns the popup panel in which the items are displayed for selection.


createPopupSelectionList

protected Widget createPopupSelectionList()
Creates the widget to be displayed in the popup to select an item.