com.extjs.gxt.ui.client.widget.selection
Class AbstractSelectionModel<C extends Container<T>,T extends Component>

java.lang.Object
  extended by com.extjs.gxt.ui.client.widget.selection.AbstractSelectionModel<C,T>
Type Parameters:
C - the container type
T - the container item type
All Implemented Interfaces:
Listener<ContainerEvent>, SelectionModel<C,T>, java.util.EventListener
Direct Known Subclasses:
DataListSelectionModel, DataView.DataViewSelectionModel, TableSelectionModel, TreeSelectionModel

public abstract class AbstractSelectionModel<C extends Container<T>,T extends Component>
extends java.lang.Object
implements SelectionModel<C,T>, Listener<ContainerEvent>

Concrete selection model. 3 selection models are supported:


Field Summary
protected  C container
           
protected  KeyNav keyNav
           
protected  boolean locked
           
protected  Style.SelectionMode mode
           
protected  boolean multiSelect
           
protected  java.util.List<T> selected
           
protected  T selectedItem
           
protected  java.util.List<T> selectedPreRender
           
protected  boolean simpleSelect
           
protected  boolean singleSelect
           
 
Constructor Summary
AbstractSelectionModel()
          Creates a new single-select selection model.
AbstractSelectionModel(Style.SelectionMode mode)
          Creates a new selection model.
 
Method Summary
 void bind(C container)
          Binds the selection model to the container.
protected  ContainerEvent createContainerEvent(Container container)
           
protected  void createKeyNav(Container tree)
           
 void deselect(int index)
          Deselects the item at the given index.
 void deselect(int start, int end)
          Deselects the range.
 void deselect(java.util.List<T> items)
          Deselects the items.
 void deselect(T... items)
          Deselects the items.
 void deselect(T item)
          Deselects the item.
 void deselectAll()
          Deselects all selections.
protected  void deselectAll(boolean supressEvent)
           
protected  void doDeselect(Items<T> items)
           
protected  void doMultiSelect(T item, ContainerEvent ce)
           
protected  void doSelect(Items<T> items, boolean keepExisting, boolean supressEvent)
           
protected  void doSelectChange(T item, boolean select)
           
protected  void doSingleSelect(T item, int index, ContainerEvent ce)
           
protected  void fireSelectionChanged()
           
 T getSelectedItem()
          Returns the selected item.
 java.util.List<T> getSelectedItems()
          Returns the selected items.
 Style.SelectionMode getSelectionMode()
          Returns the selection mode.
 void handleEvent(ContainerEvent e)
          Sent when an event that the listener has registered for occurs.
protected  void hookPreRender(T item, boolean select)
           
 boolean isLocked()
          Returns true if selections are locked.
 boolean isSelected(T item)
          Returns true if the item is selcted.
protected  T next()
           
protected  void onDoubleClick(ContainerEvent ce)
           
protected  void onKeyDown(ContainerEvent ce)
           
protected  void onKeyLeft(ContainerEvent ce)
           
protected  void onKeyRight(ContainerEvent ce)
           
protected  void onKeyUp(ContainerEvent ce)
           
protected  void onMouseDown(ContainerEvent ce)
           
protected  void onRemove(ContainerEvent ce)
           
protected  void onRender()
           
protected  void onSelectChange(T item, boolean select)
           
protected  T previous()
           
 void refresh()
          Refreshes the current selections.
 void select(boolean keepExisting, T... items)
          Selects the items.
 void select(int index, boolean keepExisting)
          Selects the item at the given index.
 void select(int start, int end, boolean keepExisting)
          Selects the range.
 void select(java.util.List<T> items, boolean keepExisting)
          Selects the items.
 void select(T item, boolean keepExisting)
          Selects the item.
 void selectAll()
          Selects all items.
 void setLocked(boolean locked)
          Sets whether selections are locked.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

selectedItem

protected T extends Component selectedItem

selected

protected java.util.List<T extends Component> selected

selectedPreRender

protected java.util.List<T extends Component> selectedPreRender

container

protected C extends Container<T> container

keyNav

protected KeyNav keyNav

mode

protected Style.SelectionMode mode

singleSelect

protected boolean singleSelect

simpleSelect

protected boolean simpleSelect

multiSelect

protected boolean multiSelect

locked

protected boolean locked
Constructor Detail

AbstractSelectionModel

public AbstractSelectionModel()
Creates a new single-select selection model.


AbstractSelectionModel

public AbstractSelectionModel(Style.SelectionMode mode)
Creates a new selection model.

Parameters:
mode - the selection mode
Method Detail

bind

public void bind(C container)
Description copied from interface: SelectionModel
Binds the selection model to the container.

Specified by:
bind in interface SelectionModel<C extends Container<T>,T extends Component>
Parameters:
container - the container

deselect

public void deselect(int index)
Description copied from interface: SelectionModel
Deselects the item at the given index.

Specified by:
deselect in interface SelectionModel<C extends Container<T>,T extends Component>
Parameters:
index - the index of the item to be deselected

deselect

public void deselect(int start,
                     int end)
Description copied from interface: SelectionModel
Deselects the range.

Specified by:
deselect in interface SelectionModel<C extends Container<T>,T extends Component>
Parameters:
start - the start index
end - the end index

deselect

public void deselect(java.util.List<T> items)
Description copied from interface: SelectionModel
Deselects the items.

Specified by:
deselect in interface SelectionModel<C extends Container<T>,T extends Component>
Parameters:
items - the item

deselect

public void deselect(T... items)
Description copied from interface: SelectionModel
Deselects the items.

Specified by:
deselect in interface SelectionModel<C extends Container<T>,T extends Component>
Parameters:
items - the items to deselect

deselect

public void deselect(T item)
Description copied from interface: SelectionModel
Deselects the item.

Specified by:
deselect in interface SelectionModel<C extends Container<T>,T extends Component>
Parameters:
item - the item to be deselected

deselectAll

public void deselectAll()
Description copied from interface: SelectionModel
Deselects all selections.

Specified by:
deselectAll in interface SelectionModel<C extends Container<T>,T extends Component>

getSelectedItem

public T getSelectedItem()
Description copied from interface: SelectionModel
Returns the selected item.

Specified by:
getSelectedItem in interface SelectionModel<C extends Container<T>,T extends Component>

getSelectedItems

public java.util.List<T> getSelectedItems()
Description copied from interface: SelectionModel
Returns the selected items.

Specified by:
getSelectedItems in interface SelectionModel<C extends Container<T>,T extends Component>

getSelectionMode

public Style.SelectionMode getSelectionMode()
Returns the selection mode.

Returns:
the selection mode

handleEvent

public void handleEvent(ContainerEvent e)
Description copied from interface: Listener
Sent when an event that the listener has registered for occurs.

Specified by:
handleEvent in interface Listener<ContainerEvent>
Parameters:
e - the event which occurred

isLocked

public boolean isLocked()
Returns true if selections are locked.

Returns:
the locked state

isSelected

public boolean isSelected(T item)
Description copied from interface: SelectionModel
Returns true if the item is selcted.

Specified by:
isSelected in interface SelectionModel<C extends Container<T>,T extends Component>
Parameters:
item - the item
Returns:
true if selected

refresh

public void refresh()
Description copied from interface: SelectionModel
Refreshes the current selections.

Specified by:
refresh in interface SelectionModel<C extends Container<T>,T extends Component>

select

public void select(int index,
                   boolean keepExisting)
Description copied from interface: SelectionModel
Selects the item at the given index.

Specified by:
select in interface SelectionModel<C extends Container<T>,T extends Component>
Parameters:
index - the index of the item to be selected
keepExisting - true to keep existing selected

select

public void select(int start,
                   int end,
                   boolean keepExisting)
Description copied from interface: SelectionModel
Selects the range.

Specified by:
select in interface SelectionModel<C extends Container<T>,T extends Component>
Parameters:
start - the start index
end - the end index
keepExisting - true to keep existing selected

select

public void select(java.util.List<T> items,
                   boolean keepExisting)
Description copied from interface: SelectionModel
Selects the items. Selects the first item for single-select.

Specified by:
select in interface SelectionModel<C extends Container<T>,T extends Component>
Parameters:
items - the items to select
keepExisting - true to keep existing selected

select

public void select(boolean keepExisting,
                   T... items)
Description copied from interface: SelectionModel
Selects the items. Selects the first item for single-select.

Specified by:
select in interface SelectionModel<C extends Container<T>,T extends Component>
Parameters:
keepExisting - true to keep existing selected
items - the items

select

public void select(T item,
                   boolean keepExisting)
Description copied from interface: SelectionModel
Selects the item.

Specified by:
select in interface SelectionModel<C extends Container<T>,T extends Component>
Parameters:
item - the item
keepExisting - true to keep existing selected

selectAll

public void selectAll()
Description copied from interface: SelectionModel
Selects all items.

Specified by:
selectAll in interface SelectionModel<C extends Container<T>,T extends Component>

setLocked

public void setLocked(boolean locked)
Sets whether selections are locked.

Parameters:
locked - true to lock

createContainerEvent

protected ContainerEvent createContainerEvent(Container container)

createKeyNav

protected void createKeyNav(Container tree)

deselectAll

protected void deselectAll(boolean supressEvent)

doDeselect

protected void doDeselect(Items<T> items)

doMultiSelect

protected void doMultiSelect(T item,
                             ContainerEvent ce)

doSelect

protected void doSelect(Items<T> items,
                        boolean keepExisting,
                        boolean supressEvent)

doSelectChange

protected void doSelectChange(T item,
                              boolean select)

doSingleSelect

protected void doSingleSelect(T item,
                              int index,
                              ContainerEvent ce)

fireSelectionChanged

protected void fireSelectionChanged()

hookPreRender

protected void hookPreRender(T item,
                             boolean select)

next

protected T next()

onMouseDown

protected void onMouseDown(ContainerEvent ce)

onDoubleClick

protected void onDoubleClick(ContainerEvent ce)

onKeyDown

protected void onKeyDown(ContainerEvent ce)

onKeyLeft

protected void onKeyLeft(ContainerEvent ce)

onKeyRight

protected void onKeyRight(ContainerEvent ce)

onKeyUp

protected void onKeyUp(ContainerEvent ce)

onRemove

protected void onRemove(ContainerEvent ce)

onRender

protected void onRender()

onSelectChange

protected void onSelectChange(T item,
                              boolean select)

previous

protected T previous()