de.matthiasmann.twl
Class ComboBox<T>

java.lang.Object
  extended by de.matthiasmann.twl.Widget
      extended by de.matthiasmann.twl.ComboBoxBase
          extended by de.matthiasmann.twl.ComboBox<T>
Type Parameters:
T - the data type of the combobox entries

public class ComboBox<T>
extends ComboBoxBase

A drop down combobox. It creates a popup containing a Listbox.


Nested Class Summary
 
Nested classes/interfaces inherited from class de.matthiasmann.twl.Widget
Widget.OffscreenMouseAdjustments, Widget.RenderOffscreen
 
Field Summary
static AnimationState.StateKey STATE_ERROR
           
 
Fields inherited from class de.matthiasmann.twl.ComboBoxBase
button, popup, STATE_COMBOBOX_KEYBOARD_FOCUS
 
Fields inherited from class de.matthiasmann.twl.Widget
STATE_DISABLED, STATE_HAS_FOCUSED_CHILD, STATE_HAS_OPEN_POPUPS, STATE_KEYBOARD_FOCUS
 
Constructor Summary
ComboBox()
           
ComboBox(ListModel<T> model)
           
ComboBox(ListModel<T> model, IntegerModel selectionModel)
           
ComboBox(ListSelectionModel<T> model)
           
 
Method Summary
 void addCallback(java.lang.Runnable cb)
           
protected  void applyTheme(ThemeInfo themeInfo)
          Apply the given theme.
protected  int computeEntryWidth(int idx)
           
 java.lang.String getDisplayTextNoSelection()
           
protected  Widget getLabel()
           
 ListModel<T> getModel()
           
protected  java.lang.String getModelData(int idx)
           
 int getSelected()
           
 IntegerModel getSelectionModel()
           
protected  boolean handleEvent(Event evt)
          Called when an event occurred that this widget could be interested in.
protected  void handleRightClick()
          Called when a right click was made on the ComboboxLabel.
 boolean isComputeWidthFromModel()
           
 boolean isNoSelectionIsError()
           
protected  void listBoxSelectionChanged(boolean close)
           
protected  boolean openPopup()
           
protected  void popupEscapePressed(Event evt)
          Called when the escape key is pressed in the open popup.
 void removeCallback(java.lang.Runnable cb)
           
 void setComputeWidthFromModel(boolean computeWidthFromModel)
           
 void setDisplayTextNoSelection(java.lang.String displayTextNoSelection)
          Sets the text to display when nothing is selected.
 void setModel(ListModel<T> model)
           
 void setModel(ListSelectionModel<T> model)
           
 void setNoSelectionIsError(boolean noSelectionIsError)
          Controls the value of STATE_ERROR on the combobox display when nothing is selected.
 void setSelected(int selected)
           
 void setSelectionModel(IntegerModel selectionModel)
           
protected  void updateLabel()
           
 
Methods inherited from class de.matthiasmann.twl.ComboBoxBase
getMinHeight, getMinWidth, getPreferredInnerHeight, getPreferredInnerWidth, keyboardFocusGained, keyboardFocusLost, layout, setPopupSize, sizeChanged
 
Methods inherited from class de.matthiasmann.twl.Widget
add, addActionMapping, addPropertyChangeListener, addPropertyChangeListener, adjustSize, afterAddToGUI, allChildrenRemoved, applyThemeBackground, applyThemeBorder, applyThemeInputMap, applyThemeMaxSize, applyThemeMinSize, applyThemeMouseCursor, applyThemeOffscreenExtra, applyThemeOverlay, applyThemeTooltip, beforeRemoveFromGUI, borderChanged, canAcceptKeyboardFocus, childAdded, childInvalidateLayout, childRemoved, childVisibilityChanged, computeSize, destroy, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, focusFirstChild, focusLastChild, focusNextChild, focusPrevChild, getActionMap, getAnimationState, getBackground, getBorderBottom, getBorderHorizontal, getBorderLeft, getBorderRight, getBorderTop, getBorderVertical, getBottom, getChild, getChildAt, getChildIndex, getGUI, getHeight, getInnerBottom, getInnerHeight, getInnerRight, getInnerWidth, getInnerX, getInnerY, getInputMap, getKeyboardFocusOrder, getMaxHeight, getMaxWidth, getMouseCursor, getMouseCursor, getNumChildren, getOffscreenExtraBottom, getOffscreenExtraLeft, getOffscreenExtraRight, getOffscreenExtraTop, getOrCreateActionMap, getOverlay, getParent, getPreferredHeight, getPreferredWidth, getRenderOffscreen, getRight, getRootWidget, getTheme, getThemePath, getThemeTooltipContent, getTintAnimator, getTooltipContent, getTooltipContentAt, getWidgetAt, getWidth, getX, getY, giveupKeyboardFocus, handleKeyStrokeAction, hasKeyboardFocus, hasOpenPopups, hasSharedAnimationState, insertChild, invalidateLayout, invalidateLayoutLocally, isAbsoluteTheme, isClip, isDepthFocusTraversal, isEnabled, isFocusKeyEnabled, isInside, isLocallyEnabled, isMouseInside, isVisible, keyboardFocusChildChanged, keyboardFocusGained, layoutChildFullInnerArea, layoutChildrenFullInnerArea, moveChild, paint, paintBackground, paintChild, paintChildren, paintDragOverlay, paintOverlay, paintWidget, positionChanged, reapplyTheme, removeAllChildren, removeChild, removeChild, removePropertyChangeListener, removePropertyChangeListener, requestKeyboardFocus, requestKeyboardFocus, resetTooltip, setActionMap, setBackground, setBorderSize, setBorderSize, setBorderSize, setBorderSize, setCanAcceptKeyboardFocus, setClip, setDepthFocusTraversal, setEnabled, setFocusKeyEnabled, setInnerSize, setInputMap, setMaxSize, setMinSize, setMouseCursor, setOffscreenExtra, setOffscreenExtra, setOverlay, setPosition, setRenderOffscreen, setSize, setTheme, setTintAnimator, setTooltipContent, setVisible, updateTintAnimation, updateTooltip, validateLayout, widgetDisabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_ERROR

public static final AnimationState.StateKey STATE_ERROR
Constructor Detail

ComboBox

public ComboBox(ListSelectionModel<T> model)

ComboBox

public ComboBox(ListModel<T> model,
                IntegerModel selectionModel)

ComboBox

public ComboBox(ListModel<T> model)

ComboBox

public ComboBox()
Method Detail

addCallback

public void addCallback(java.lang.Runnable cb)

removeCallback

public void removeCallback(java.lang.Runnable cb)

setModel

public void setModel(ListModel<T> model)

getModel

public ListModel<T> getModel()

setSelectionModel

public void setSelectionModel(IntegerModel selectionModel)

getSelectionModel

public IntegerModel getSelectionModel()

setModel

public void setModel(ListSelectionModel<T> model)

setSelected

public void setSelected(int selected)

getSelected

public int getSelected()

isComputeWidthFromModel

public boolean isComputeWidthFromModel()

setComputeWidthFromModel

public void setComputeWidthFromModel(boolean computeWidthFromModel)

getDisplayTextNoSelection

public java.lang.String getDisplayTextNoSelection()

setDisplayTextNoSelection

public void setDisplayTextNoSelection(java.lang.String displayTextNoSelection)
Sets the text to display when nothing is selected. Default is ""

Parameters:
displayTextNoSelection - the text to display
Throws:
java.lang.NullPointerException - when displayTextNoSelection is null

isNoSelectionIsError

public boolean isNoSelectionIsError()

setNoSelectionIsError

public void setNoSelectionIsError(boolean noSelectionIsError)
Controls the value of STATE_ERROR on the combobox display when nothing is selected. Default is false.

Parameters:
noSelectionIsError -

openPopup

protected boolean openPopup()
Overrides:
openPopup in class ComboBoxBase

popupEscapePressed

protected void popupEscapePressed(Event evt)
Description copied from class: ComboBoxBase
Called when the escape key is pressed in the open popup. The default implementation closes the popup.

Overrides:
popupEscapePressed in class ComboBoxBase
Parameters:
evt - the event

handleRightClick

protected void handleRightClick()
Called when a right click was made on the ComboboxLabel. The default implementation does nothing


listBoxSelectionChanged

protected void listBoxSelectionChanged(boolean close)

getModelData

protected java.lang.String getModelData(int idx)

getLabel

protected Widget getLabel()
Specified by:
getLabel in class ComboBoxBase

updateLabel

protected void updateLabel()

applyTheme

protected void applyTheme(ThemeInfo themeInfo)
Description copied from class: Widget
Apply the given theme. This method also calls invalidateLayout()

Overrides:
applyTheme in class Widget
Parameters:
themeInfo - The theme info for this widget

handleEvent

protected boolean handleEvent(Event evt)
Description copied from class: Widget
Called when an event occurred that this widget could be interested in.

The default implementation handles only keyboard events and delegates them to the child widget which has keyboard focus. If focusKey handling is enabled then this widget cycles the keyboard focus through it's children. If the key was not consumed by a child or focusKey and an inputMap is specified then the event is translated by the InputMap and handleKeyStrokeAction is called when a mapping was found.

If the widget wants to receive mouse events then it must return true for all mouse events except for MOUSE_WHEEL (which is optional) event. Otherwise the following mouse event are not send. Before mouse movement or button events are send a MOUSE_ENTERED event is send first.

Overrides:
handleEvent in class Widget
Parameters:
evt - The event - do not store this object - it may be reused
Returns:
true if the widget handled this event
See Also:
Widget.setFocusKeyEnabled(boolean), Widget.handleKeyStrokeAction(java.lang.String, de.matthiasmann.twl.Event), Widget.setInputMap(de.matthiasmann.twl.InputMap)

computeEntryWidth

protected int computeEntryWidth(int idx)