com.extjs.gxt.ui.client.widget
Class DataList

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.extjs.gxt.ui.client.widget.Component
              extended by com.extjs.gxt.ui.client.widget.BoxComponent
                  extended by com.extjs.gxt.ui.client.widget.Container<T>
                      extended by com.extjs.gxt.ui.client.widget.ScrollContainer<DataListItem>
                          extended by com.extjs.gxt.ui.client.widget.DataList
All Implemented Interfaces:
Observable, Selectable<DataListItem>, com.google.gwt.user.client.EventListener

public class DataList
extends ScrollContainer<DataListItem>
implements Selectable<DataListItem>

Displays a list of list items.

Events:
BeforeAdd : DateListEvent(dataList, item, index)
Fires before an item is added or inserted. Listeners can set the doit field to false to cancel the action.
BeforeRemove : DateListEvent(dataList, item, index)
Fires before an item is removed. Listeners can set the doit field to false to cancel the action.
Add : DateListEvent(dataList, item, index)
Fires after an item has been added or inserted.
Remove : DateListEvent(dataList, item, index)
Fires after an item has been removed.
BeforeSelect : DateListEvent(dataList, item)
Fires before a item is selected. Listeners can set the doit field to false to cancel the action.
SelectionChange : DateListEvent(dataList, selected)
Fires after the selection changes.
ContextMenu : DateListEvent(dataList)
Fires before the list's context menu is shown. Listeners can set the doit field to false to cancel the action.
CheckChange : DateListEvent(dataList, item)
Fires after an item is selected.
CSS:
.my-list (the list itself)
.my-listitem (list item)
.my-listitem .my-listitem-text (list item text)


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
static Template defaultItemTemplate
          The default template for data list items.
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
DataList()
          Creates a new single select list.
 
Method Summary
 boolean add(DataListItem component)
          Creates then adds an item to the list.
 DataListItem add(java.lang.String text)
          Creates then adds an item to the list.
 java.util.List<DataListItem> getChecked()
          Returns an array of checked items.
 Menu getContextMenu()
          Returns the component's context menu.
 DataListItem getSelectedItem()
          Returns the selected item.
 java.util.List<DataListItem> getSelectedItems()
          Returns the selected items.
 Style.SelectionMode getSelectionMode()
           
 DataListSelectionModel getSelectionModel()
          Returns the list's selection model.
 boolean insert(DataListItem item, int index)
          Inserts an item into the list at the given index.
 boolean isCheckable()
          Returns true if check boxes are enabled.
 boolean isFlat()
          Returns true if the list is using the "flat" style.
 boolean isTrackMouseOver()
          Returns true if rows are highlighted on mouse over.
 void moveSelectedDown()
          Moves the current selections down one level.
 void moveSelectedUp()
          Moves the current selections up one level.
 void onComponentEvent(ComponentEvent ce)
          Any events a component receives will be forwarded to this method.
 void onSelectChange(DataListItem item, boolean select)
          Called when the visual state of a item is changed.
 boolean remove(DataListItem item)
          Removes the item from the list.
 void scrollIntoView(DataListItem item)
          Scrolls the item into view.
 void setCheckable(boolean checkable)
          Sets whether items shoud have a check box (defaults to false, pre-render).
 void setContextMenu(Menu menu)
          Sets the component's context menu.
 void setFlatStyle(boolean flat)
          Sets whether the list should use a "flat" style without rounded corners (defaults to false, pre-render).
 void setItemTemplate(Template itemTemplate)
          Sets the optional template to be used by the data list items (pre-render).
 void setSelectedItem(DataListItem item)
          Selects the item.
 void setSelectedItems(java.util.List<DataListItem> items)
          Selects the items.
 void setSelectionMode(Style.SelectionMode mode)
          Sets the list's selection mode.
 void setSelectionModel(DataListSelectionModel sm)
          Sets the list's selection model.
 void setTrackMouseOver(boolean trackMouseOver)
          True to highlight items when the mouse is over (defaults to true).
 void sort(java.util.Comparator<DataListItem> comparator)
          Sorts the data list.
 
Methods inherited from class com.extjs.gxt.ui.client.widget.ScrollContainer
addScrollListener, getHScrollPosition, getScrollMode, getVScrollPosition, removeScrollListener, scrollIntoView, setHScrollPosition, setScrollMode, setVScrollPosition
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Container
disable, enable, findItem, getItem, getItemByItemId, getItemCount, getItems, getWidget, indexOf, iterator, removeAll
 
Methods inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
getBounds, getHeight, getHeight, getPosition, getShadow, getSize, getWidth, getWidth, isAutoHeight, isAutoWidth, isDeferHeight, isShim, setAutoHeight, setAutoWidth, setBounds, setBounds, setDeferHeight, setHeight, setHeight, setPagePosition, setPagePosition, setPixelSize, setPosition, setShadow, setShim, setSize, setSize, setWidth, setWidth
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addListener, addPlugin, addStyleName, addWidgetListener, disableEvents, disableTextSelection, el, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, getBaseStyle, getBorders, getData, getData, getElement, getId, getItemId, getModel, getState, getToolTip, hide, hideToolTip, isDisabledEvents, isEnabled, isRendered, isVisible, onBrowserEvent, recalculate, removeAllListeners, removeFromParent, removeListener, removeStyleName, removeWidgetListener, render, render, saveState, setBorders, setData, setData, setElement, setEnabled, setEnableState, setId, setIntStyleAttribute, setItemId, setStyleAttribute, setStyleName, setTitle, setToolTip, setToolTip, setVisible, show, sinkEvents, toString
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, setStylePrimaryName, setVisible, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultItemTemplate

public static Template defaultItemTemplate
The default template for data list items.

Constructor Detail

DataList

public DataList()
Creates a new single select list.

Method Detail

add

public boolean add(DataListItem component)
Creates then adds an item to the list. Fires the BeforeAdd event before inserting, then fires the Add event after the widget has been inserted.

Parameters:
component - the dataListItem to add

add

public DataListItem add(java.lang.String text)
Creates then adds an item to the list. Fires the BeforeAdd event before inserting, then fires the Add event after the widget has been inserted.

Parameters:
text - the item's text
Returns:
the newly created item, or null if the add was cancelled

getChecked

public java.util.List<DataListItem> getChecked()
Returns an array of checked items.

Returns:
the checked items

getContextMenu

public Menu getContextMenu()
Description copied from class: Component
Returns the component's context menu. This method is marked protected, subclasses can change access to public to expose the contenxt menu.

Returns:
the context menu

getSelectedItem

public DataListItem getSelectedItem()
Description copied from interface: Selectable
Returns the selected item.

Specified by:
getSelectedItem in interface Selectable<DataListItem>
Returns:
the selected item

getSelectedItems

public java.util.List<DataListItem> getSelectedItems()
Description copied from interface: Selectable
Returns the selected items. For single-select, the last selected item is returned.

Specified by:
getSelectedItems in interface Selectable<DataListItem>
Returns:
the selected items

getSelectionMode

public Style.SelectionMode getSelectionMode()

getSelectionModel

public DataListSelectionModel getSelectionModel()
Returns the list's selection model.

Returns:
the selection model

insert

public boolean insert(DataListItem item,
                      int index)
Inserts an item into the list at the given index. Fires the BeforeAdd event before inserting, then fires the Add event after the widget has been inserted.

Parameters:
item - the item
index - the insert location

isCheckable

public boolean isCheckable()
Returns true if check boxes are enabled.

Returns:
the check box state

isFlat

public boolean isFlat()
Returns true if the list is using the "flat" style.

Returns:
the flat state

isTrackMouseOver

public boolean isTrackMouseOver()
Returns true if rows are highlighted on mouse over.

Returns:
the track mouse state

moveSelectedDown

public void moveSelectedDown()
Moves the current selections down one level.


moveSelectedUp

public void moveSelectedUp()
Moves the current selections up one level.


onComponentEvent

public void onComponentEvent(ComponentEvent ce)
Description copied from class: Component
Any events a component receives will be forwarded to this method. Subclasses should override as needed. The Component.onBrowserEvent(com.google.gwt.user.client.Event) method should not be overridden or modified.

Overrides:
onComponentEvent in class ScrollContainer<DataListItem>
Parameters:
ce - the base event

onSelectChange

public void onSelectChange(DataListItem item,
                           boolean select)
Description copied from interface: Selectable
Called when the visual state of a item is changed.

Specified by:
onSelectChange in interface Selectable<DataListItem>
Parameters:
item - the item
select - the select state

remove

public boolean remove(DataListItem item)
Removes the item from the list.

Parameters:
item - the item to be removed
Returns:
true if the item was removed

scrollIntoView

public void scrollIntoView(DataListItem item)
Scrolls the item into view.

Overrides:
scrollIntoView in class Container<DataListItem>
Parameters:
item - the item

setCheckable

public void setCheckable(boolean checkable)
Sets whether items shoud have a check box (defaults to false, pre-render).

Parameters:
checkable - true to enable checbox

setContextMenu

public void setContextMenu(Menu menu)
Description copied from class: Component
Sets the component's context menu.

Parameters:
menu - the context menu

setFlatStyle

public void setFlatStyle(boolean flat)
Sets whether the list should use a "flat" style without rounded corners (defaults to false, pre-render). The flat style supports variable height list items.

Parameters:
flat - the flat state

setItemTemplate

public void setItemTemplate(Template itemTemplate)
Sets the optional template to be used by the data list items (pre-render). The custom template will be rendered with the following parameters: id, style, iconStyle, text.

Parameters:
itemTemplate - the template

setSelectedItem

public void setSelectedItem(DataListItem item)
Description copied from interface: Selectable
Selects the item. Any existing selections are cleared.

Specified by:
setSelectedItem in interface Selectable<DataListItem>
Parameters:
item - the item to select

setSelectedItems

public void setSelectedItems(java.util.List<DataListItem> items)
Description copied from interface: Selectable
Selects the items. Only the first item is selected for single-select. Any existing selections are cleared.

Specified by:
setSelectedItems in interface Selectable<DataListItem>
Parameters:
items - the items to select

setSelectionMode

public void setSelectionMode(Style.SelectionMode mode)
Sets the list's selection mode.

Parameters:
mode - the selection mode

setSelectionModel

public void setSelectionModel(DataListSelectionModel sm)
Sets the list's selection model.

Parameters:
sm - the selection model

setTrackMouseOver

public void setTrackMouseOver(boolean trackMouseOver)
True to highlight items when the mouse is over (defaults to true).

Parameters:
trackMouseOver - true to highlight items on mouse over

sort

public void sort(java.util.Comparator<DataListItem> comparator)
Sorts the data list.

Parameters:
comparator - the comparator