com.extjs.gxt.ui.client.widget
Class ListView<M extends ModelData>

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.ListView<M>
All Implemented Interfaces:
Observable, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.IsWidget
Direct Known Subclasses:
CheckBoxListView

public class ListView<M extends ModelData>
extends BoxComponent

A mechanism for displaying data using custom layout templates. ListView uses an XTemplate as its internal templating mechanism.

In order to use these features, an setItemSelector(String) must be provided for the ListView to determine what nodes it will be working with.

Events:
Select : ListViewEvent(listView, event)
Fires when a template node is clicked.
DoubleClick : ListViewEvent(listView, index, element, event)
Fires when a template node is double clicked.
ContextMenu : ListViewEvent(listView, index, element, event)
Fires when a template node is right clicked.
Inherited Events:
BoxComponent Move
BoxComponent Resize
Component Enable
Component Disable
Component BeforeHide
Component Hide
Component BeforeShow
Component Show
Component Attach
Component Detach
Component BeforeRender
Component Render
Component BrowserEvent
Component BeforeStateRestore
Component StateRestore
Component BeforeStateSave
Component SaveState


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
protected  int rowSelectorDepth
           
protected  ListStore<M> store
           
 
Fields inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustSize, cacheSizes, ensureVisibilityOnSizing, height, lastSize, layer, shim, width
 
Fields inherited from class com.extjs.gxt.ui.client.widget.Component
afterRender, attachables, baseStyle, disabled, disabledStyle, disableTextSelection, dummy, focusable, hidden, mask, maskMessage, maskMessageStyleName, monitorWindowResize, rendered, resizeHandler, setElementRender, stateId, swallowEvents, toolTip, windowResizeDelay, windowResizeTask
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
ListView()
          Creates a new view.
ListView(ListStore<M> store)
          Creates a new view.
ListView(ListStore<M> store, XTemplate template)
          Creates a new template list.
 
Method Summary
protected  void afterRender()
          Called after the component has been rendered and is attached for the first time.
protected  java.util.List<M> collectData(java.util.List<M> models, int startIndex)
           
protected  ComponentEvent createComponentEvent(com.google.gwt.user.client.Event event)
           
 com.google.gwt.user.client.Element findElement(com.google.gwt.user.client.Element element)
          Returns the matching element.
 int findElementIndex(com.google.gwt.user.client.Element element)
          Returns the element's index.
protected  void focusItem(int index)
           
 java.lang.String getDisplayProperty()
          Returns the display property.
 com.google.gwt.user.client.Element getElement(int index)
          Returns the element at the given index.
 java.util.List<com.google.gwt.user.client.Element> getElements()
          Returns all of the child elements.
 int getItemCount()
          Returns the number of models in the view.
 java.lang.String getItemSelector()
          Returns the item selector.
 java.lang.String getLoadingText()
          Returns the view's loading text.
 ModelProcessor<M> getModelProcessor()
          Returns the model processor.
 java.lang.String getOverStyle()
          Returns the over style.
 QuickTip getQuickTip()
          Returns the view's quick tip instance.
 ListViewSelectionModel<M> getSelectionModel()
          Returns the view's selection model.
 boolean getSelectOnOver()
          Returns true if select on hover is enabled.
 java.lang.String getSelectStyle()
          Returns the select style.
 ListStore<M> getStore()
          Returns the combo's store.
 XTemplate getTemplate()
          Returns the list's template.
 int indexOf(com.google.gwt.user.client.Element element)
          Returns the index of the element.
protected  void initComponent()
           
 boolean isEnableQuickTips()
          Returns true if quicktips are enabled.
 void moveSelectedDown()
          Moves the current selections down one level.
 void moveSelectedUp()
          Moves the current selections up one level.
protected  void onAdd(java.util.List<M> models, int index)
           
protected  void onBeforeLoad()
           
protected  void onClick(ListViewEvent<M> e)
           
 void onComponentEvent(ComponentEvent ce)
          Any events a component receives will be forwarded to this method.
protected  void onDoubleClick(ListViewEvent<M> e)
           
protected  void onFocus(ComponentEvent ce)
           
protected  void onHighlightRow(int index, boolean highLight)
           
protected  void onMouseDown(ListViewEvent<M> e)
           
protected  void onMouseOut(ListViewEvent<M> ce)
           
protected  void onMouseOver(ListViewEvent<M> ce)
           
protected  void onRemove(M data, int index)
           
protected  void onRender(com.google.gwt.user.client.Element target, int index)
          Subclasses must override and ensure setElement is called for lazy rendered components.
protected  void onSelectChange(M model, boolean select)
           
protected  void onUpdate(M model, int index)
           
protected  M prepareData(M model)
           
 void refresh()
          Refreshes the view by reloading the data from the store and re-rendering the template.
 void refreshNode(int index)
          Refreshes an individual node's data from the store.
 void setDisplayProperty(java.lang.String displayProperty)
          Sets the display property.
 void setEnableQuickTips(boolean enableQuickTip)
          True to enable quicktips (defaults to true, pre-render).
 void setItemSelector(java.lang.String itemSelector)
          This is a required setting.
 void setLoadingText(java.lang.String loadingText)
          Sets the text loading text to be displayed during a load request.
 void setModelProcessor(ModelProcessor<M> modelProcessor)
          Sets the view's model processor.
 void setOverStyle(java.lang.String overStyle)
          Sets the style name to apply on mouse over.
 void setSelectionModel(ListViewSelectionModel<M> sm)
          Sets the selection model.
 void setSelectOnOver(boolean selectOnHover)
          True to select the item when mousing over a element (defaults to false).
 void setSelectStyle(java.lang.String selectStyle)
          The style to be applied to each selected item (defaults to 'x-view-item-sel').
 void setSimpleTemplate(java.lang.String html)
          Sets the template fragment to be used for the text of each listview item.
 void setStore(ListStore<M> store)
          Changes the data store bound to this view and refreshes it.
 void setTemplate(java.lang.String html)
          Sets the view's template.
 void setTemplate(XTemplate template)
          Sets the view's template.
 
Methods inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustPosition, adjustSize, getBounds, getHeight, getHeight, getPosition, getPositionEl, getResizeEl, getShadow, getShadowOffset, getShadowPosition, getSize, getWidth, getWidth, hideShadow, hideShim, hideUnders, isAutoHeight, isAutoWidth, isDeferHeight, isShim, onHide, onPosition, onResize, onShow, onUnload, setAutoHeight, setAutoWidth, setBounds, setBounds, setDeferHeight, setHeight, setHeight, setPagePosition, setPagePosition, setPixelSize, setPosition, setShadow, setShadowOffset, setShadowPosition, setShim, setSize, setSize, setWidth, setWidth, sync, syncSize
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addAttachable, addListener, addPlugin, addStyleName, addStyleOnOver, addWidgetListener, applyState, assertAfterRender, assertPreRender, beforeRender, blur, clearState, createObservable, createStyles, disable, disableContextMenu, disableEvents, disableTextSelection, doAttachChildren, doDetachChildren, el, enable, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, frame, getAriaSupport, getBaseStyle, getBorders, getContextMenu, getData, getElement, getFocusEl, getFocusSupport, getHideMode, getId, getItemId, getListeners, getModel, getObservable, getPlugins, getState, getStateId, getTabIndex, getTitle, getToolTip, getWindowResizeDelay, hasListeners, hasListeners, hide, hideToolTip, initState, isDisabledEvents, isDisableTextSelection, isEnabled, isMasked, isMonitorWindowResize, isRendered, isStateful, isVisible, isVisible, mask, mask, mask, notifyHide, notifyShow, onAttach, onBrowserEvent, onDetach, onDetachHelper, onDisable, onEnable, onEnsureDebugId, onHideContextMenu, onLoad, onRightClick, onShowContextMenu, onWindowResize, previewEvent, recalculate, removeAllListeners, removeAttachagle, removeFromParent, removeListener, removeStyleName, removeStyleOnOver, removeSwallow, removeToolTip, removeWidgetListener, render, render, repaint, saveState, setAriaRole, setAriaState, setAriaSupport, setBorders, setContextMenu, setData, setEl, setElement, setElement, setEnabled, setFiresEvents, setHideMode, setId, setIntStyleAttribute, setItemId, setModel, setMonitorWindowResize, setParent, setStateful, setStateId, setStyleAttribute, setStyleName, setTabIndex, setTitle, setToolTip, setToolTip, setVisible, setWindowResizeDelay, setZIndex, show, sinkEvents, swallowEvent, swallowEvent, toString, unframe, unmask
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, setLayoutData
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, removeStyleDependentName, setElement, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, sinkBitlessEvent, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rowSelectorDepth

protected int rowSelectorDepth

store

protected ListStore<M extends ModelData> store
Constructor Detail

ListView

public ListView()
Creates a new view.


ListView

public ListView(ListStore<M> store)
Creates a new view.


ListView

public ListView(ListStore<M> store,
                XTemplate template)
Creates a new template list.

Parameters:
template - the template
Method Detail

findElement

public com.google.gwt.user.client.Element findElement(com.google.gwt.user.client.Element element)
Returns the matching element.

Parameters:
element - the element or any child element
Returns:
the parent element

findElementIndex

public int findElementIndex(com.google.gwt.user.client.Element element)
Returns the element's index.

Parameters:
element - the element or any child element
Returns:
the element index or -1 if no match

getDisplayProperty

public java.lang.String getDisplayProperty()
Returns the display property.

Returns:
the display property

getElement

public com.google.gwt.user.client.Element getElement(int index)
Returns the element at the given index.

Parameters:
index - the index
Returns:
the element

getElements

public java.util.List<com.google.gwt.user.client.Element> getElements()
Returns all of the child elements.

Returns:
the elements

getItemCount

public int getItemCount()
Returns the number of models in the view.

Returns:
the count

getItemSelector

public java.lang.String getItemSelector()
Returns the item selector.

Returns:
the selector

getLoadingText

public java.lang.String getLoadingText()
Returns the view's loading text.

Returns:
the loading text

getModelProcessor

public ModelProcessor<M> getModelProcessor()
Returns the model processor.

Returns:
the model processor

getOverStyle

public java.lang.String getOverStyle()
Returns the over style.

Returns:
the over style

getQuickTip

public QuickTip getQuickTip()
Returns the view's quick tip instance.

Returns:
the quicktip instance or null if not enabled

getSelectionModel

public ListViewSelectionModel<M> getSelectionModel()
Returns the view's selection model.

Returns:
the selection model

getSelectOnOver

public boolean getSelectOnOver()
Returns true if select on hover is enabled.

Returns:
the select on hover state

getSelectStyle

public java.lang.String getSelectStyle()
Returns the select style.

Returns:
the select style

getStore

public ListStore<M> getStore()
Returns the combo's store.

Returns:
the store

getTemplate

public XTemplate getTemplate()
Returns the list's template.

Returns:
the template

indexOf

public int indexOf(com.google.gwt.user.client.Element element)
Returns the index of the element.

Parameters:
element - the element
Returns:
the index

isEnableQuickTips

public boolean isEnableQuickTips()
Returns true if quicktips are enabled.

Returns:
true for enabled

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 Component
Parameters:
ce - the base event

refresh

public void refresh()
Refreshes the view by reloading the data from the store and re-rendering the template.


refreshNode

public void refreshNode(int index)
Refreshes an individual node's data from the store.

Parameters:
index - the items data index in the store

setDisplayProperty

public void setDisplayProperty(java.lang.String displayProperty)
Sets the display property. Applies when using the default template for each item's text.

Parameters:
displayProperty - the display property

setEnableQuickTips

public void setEnableQuickTips(boolean enableQuickTip)
True to enable quicktips (defaults to true, pre-render).

Parameters:
enableQuickTip - true to enable quicktips

setItemSelector

public void setItemSelector(java.lang.String itemSelector)
This is a required setting. A simple CSS selector (e.g. div.some-class or span:first-child) that will be used to determine what nodes this DataView will be working with (defaults to 'x-view-item').

Parameters:
itemSelector - the item selector

setLoadingText

public void setLoadingText(java.lang.String loadingText)
Sets the text loading text to be displayed during a load request.

Parameters:
loadingText - the loading text

setModelProcessor

public void setModelProcessor(ModelProcessor<M> modelProcessor)
Sets the view's model processor. The model processor can be used to provide "formatted" properties to the XTemplate used to render the view.

Parameters:
modelProcessor -
See Also:
ModelProcessor

setOverStyle

public void setOverStyle(java.lang.String overStyle)
Sets the style name to apply on mouse over.

Parameters:
overStyle - the over style

setSelectionModel

public void setSelectionModel(ListViewSelectionModel<M> sm)
Sets the selection model.

Parameters:
sm - the selection model

setSelectOnOver

public void setSelectOnOver(boolean selectOnHover)
True to select the item when mousing over a element (defaults to false).

Parameters:
selectOnHover - true to select on mouse over

setSelectStyle

public void setSelectStyle(java.lang.String selectStyle)
The style to be applied to each selected item (defaults to 'x-view-item-sel').

Parameters:
selectStyle - the select style

setSimpleTemplate

public void setSimpleTemplate(java.lang.String html)
Sets the template fragment to be used for the text of each listview item.
 <code>
 listview.setSimpleTemplate("{abbr} {name}");
 </code>
 

Parameters:
html - the html used only for the text of each item in the list

setStore

public void setStore(ListStore<M> store)
Changes the data store bound to this view and refreshes it.

Parameters:
store - the store to bind this view

setTemplate

public void setTemplate(java.lang.String html)
Sets the view's template.

Parameters:
html - the HTML fragment

setTemplate

public void setTemplate(XTemplate template)
Sets the view's template.

Parameters:
template - the template

afterRender

protected void afterRender()
Description copied from class: Component
Called after the component has been rendered and is attached for the first time. At this time, the component will be part of the DOM which is required when retrieving location and offsets.

Overrides:
afterRender in class BoxComponent

collectData

protected java.util.List<M> collectData(java.util.List<M> models,
                                        int startIndex)

createComponentEvent

protected ComponentEvent createComponentEvent(com.google.gwt.user.client.Event event)
Overrides:
createComponentEvent in class BoxComponent

focusItem

protected void focusItem(int index)

initComponent

protected void initComponent()

onAdd

protected void onAdd(java.util.List<M> models,
                     int index)

onBeforeLoad

protected void onBeforeLoad()

onClick

protected void onClick(ListViewEvent<M> e)

onDoubleClick

protected void onDoubleClick(ListViewEvent<M> e)

onFocus

protected void onFocus(ComponentEvent ce)

onHighlightRow

protected void onHighlightRow(int index,
                              boolean highLight)

onMouseDown

protected void onMouseDown(ListViewEvent<M> e)

onMouseOut

protected void onMouseOut(ListViewEvent<M> ce)

onMouseOver

protected void onMouseOver(ListViewEvent<M> ce)

onRemove

protected void onRemove(M data,
                        int index)

onRender

protected void onRender(com.google.gwt.user.client.Element target,
                        int index)
Description copied from class: Component
Subclasses must override and ensure setElement is called for lazy rendered components.

Overrides:
onRender in class Component
Parameters:
target - the target element
index - the insert location

onSelectChange

protected void onSelectChange(M model,
                              boolean select)

onUpdate

protected void onUpdate(M model,
                        int index)

prepareData

protected M prepareData(M model)