de.lessvoid.nifty.controls
Interface ListBox<T>

Type Parameters:
T -
All Superinterfaces:
NiftyControl
All Known Implementing Classes:
ListBoxControl, ListBoxNull

public interface ListBox<T>
extends NiftyControl

The ListBox interface is the Nifty control API view of a Nifty ListBox control.

Author:
void

Nested Class Summary
static interface ListBox.ListBoxViewConverter<T>
          You'll need to implement this interface to change the way your model class T needs to be displayed in the ListBox.
static class ListBox.ListBoxViewConverterSimple<T>
          A simple implementation of ListBoxViewConverter that will just use item.toString().
static class ListBox.SelectionMode
          The ListBoxSelectionMode determines how the ListBox handles selections.
 
Method Summary
 void addAllItems(List<T> itemsToAdd)
          Add all items to the ListBox.
 void addItem(T newItem)
          Add a item to the ListBox.
 void changeSelectionMode(ListBox.SelectionMode listBoxSelectionMode, boolean forceSelection)
          Change the ListBox.SelectionMode to a new one.
 void clear()
          Clear all items from this ListBox.
 void deselectItem(T item)
          Deselect the given item.
 void deselectItemByIndex(int itemIndex)
          Deselect the item with the given itemIndex.
 int getDisplayItemCount()
          Returns the number of items this ListBox can display without being scrolled.
 T getFocusItem()
          Get the current item that has the focus.
 int getFocusItemIndex()
          Get the index of the current focus item.
 List<T> getItems()
          Get all items of this ListBox.
 List<Integer> getSelectedIndices()
          Get the current selection as a list of indices.
 List<T> getSelection()
          Get the current selection.
 void insertItem(T item, int index)
          Insert the given item at the given index.
 int itemCount()
          Retrieve the number of items in the ListBox.
 void refresh()
          Refresh the Listbox display.
 void removeAllItems(List<T> itemsToRemove)
          Remove all items given in the List from this ListBox.
 void removeItem(T item)
          Remove the given item from the ListBox.
 void removeItemByIndex(int itemIndex)
          Remove an item from the ListBox by index.
 void selectItem(T item)
          Select the item in the ListBox.
 void selectItemByIndex(int selectionIndex)
          Select the item with the given index in the ListBox.
 void selectNext()
          Select the next item.
 void selectPrevious()
          Select the previous item.
 void setFocusItem(T item)
          Change the current focus item to the item given.
 void setFocusItemByIndex(int itemIndex)
          Change the current focus item to the given index.
 void setListBoxViewConverter(ListBox.ListBoxViewConverter<T> viewConverter)
          Change the ListBoxViewConverter for this ListBox.
 void showItem(T item)
          Make sure the given item is visible.
 void showItemByIndex(int itemIndex)
          Make sure the given item is visible.
 void sortAllItems()
          Sort all items using natural ordering.
 void sortAllItems(Comparator<T> comperator)
          Sort all items using the given comperator.
 
Methods inherited from interface de.lessvoid.nifty.controls.NiftyControl
disable, enable, getElement, getHeight, getId, getStyle, getWidth, hasFocus, isBound, isEnabled, layoutCallback, setEnabled, setFocus, setFocusable, setHeight, setId, setStyle, setWidth
 

Method Detail

changeSelectionMode

void changeSelectionMode(ListBox.SelectionMode listBoxSelectionMode,
                         boolean forceSelection)
Change the ListBox.SelectionMode to a new one.

Parameters:
listBoxSelectionMode - the new ListBox.SelectionMode to use
forceSelection - if set to true will not allow de selecting the last item in the selection and it will automatically select the first item added. when set to false it's possible to have no selection at all.

setListBoxViewConverter

void setListBoxViewConverter(ListBox.ListBoxViewConverter<T> viewConverter)
Change the ListBoxViewConverter for this ListBox.

Parameters:
viewConverter - ListBoxViewConverter

addItem

void addItem(T newItem)
Add a item to the ListBox.

Parameters:
newItem - the item to add

insertItem

void insertItem(T item,
                int index)
Insert the given item at the given index.

Parameters:
item - item
index - the index to insert the item.

itemCount

int itemCount()
Retrieve the number of items in the ListBox.

Returns:
number of items.

clear

void clear()
Clear all items from this ListBox.


selectItemByIndex

void selectItemByIndex(int selectionIndex)
Select the item with the given index in the ListBox. This might change the currently selected item if the ListBoxSingleSelectionMode is used or it will add to the selection if ListBoxMultiSelectionMode is used.

Parameters:
selectionIndex - the item index to select in the ComboBox

selectItem

void selectItem(T item)
Select the item in the ListBox.

Parameters:
item - the item to select

selectNext

void selectNext()
Select the next item. This will only work in SingleSelection mode and when there currently is an element selected.


selectPrevious

void selectPrevious()
Select the previous item. This will only work in SingleSelection mode and when there currently is an element selected.


deselectItemByIndex

void deselectItemByIndex(int itemIndex)
Deselect the item with the given itemIndex.

Parameters:
itemIndex - item index to deselect

deselectItem

void deselectItem(T item)
Deselect the given item.

Parameters:
item - item to deselect.

getSelection

List<T> getSelection()
Get the current selection.

Returns:
list of the selected items in this ListBox.

getSelectedIndices

List<Integer> getSelectedIndices()
Get the current selection as a list of indices.

Returns:
list of indices for the current selection

removeItemByIndex

void removeItemByIndex(int itemIndex)
Remove an item from the ListBox by index.

Parameters:
itemIndex - remove the item with the given index from the ListBox

removeItem

void removeItem(T item)
Remove the given item from the ListBox.

Parameters:
item - the item to remove from the ListBox

getItems

List<T> getItems()
Get all items of this ListBox.

Returns:
list of all items

showItem

void showItem(T item)
Make sure the given item is visible. This can also be used to make sure you can see the element after a new item has been added to the ListBox.

Parameters:
item - the item

showItemByIndex

void showItemByIndex(int itemIndex)
Make sure the given item is visible.

Parameters:
itemIndex - the item index to make visible

setFocusItem

void setFocusItem(T item)
Change the current focus item to the item given. The focus item is the item you can change with the cursor keys. It just marks the item it does not change the selection.

Parameters:
item - the item to set the focus to

setFocusItemByIndex

void setFocusItemByIndex(int itemIndex)
Change the current focus item to the given index.

Parameters:
itemIndex - the new focus item

getFocusItem

T getFocusItem()
Get the current item that has the focus.

Returns:
the item that has the focus

getFocusItemIndex

int getFocusItemIndex()
Get the index of the current focus item.

Returns:
the index of the current focus item.

addAllItems

void addAllItems(List<T> itemsToAdd)
Add all items to the ListBox.

Parameters:
itemsToAdd - all items to add

removeAllItems

void removeAllItems(List<T> itemsToRemove)
Remove all items given in the List from this ListBox.

Parameters:
itemsToRemove - list of items to remove

sortAllItems

void sortAllItems()
Sort all items using natural ordering.


getDisplayItemCount

int getDisplayItemCount()
Returns the number of items this ListBox can display without being scrolled.

Returns:
number of display items

sortAllItems

void sortAllItems(Comparator<T> comperator)
Sort all items using the given comperator.

Parameters:
comperator -

refresh

void refresh()
Refresh the Listbox display. You can use that when you've made changes to the underlying model classes. This just displays all currently visible elements.



Copyright © 2011. All Rights Reserved.