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

java.lang.Object
  extended by com.extjs.gxt.ui.client.event.BaseObservable
      extended by com.extjs.gxt.ui.client.widget.selection.AbstractStoreSelectionModel<M>
Type Parameters:
M - the model type contained within the store
All Implemented Interfaces:
Observable, SelectionProvider<M>, StoreSelectionModel<M>
Direct Known Subclasses:
GridSelectionModel, ListViewSelectionModel

public abstract class AbstractStoreSelectionModel<M extends ModelData>
extends BaseObservable
implements StoreSelectionModel<M>, SelectionProvider<M>

Abstract base class for store based selection models.

Events:
SelectionChange : SelectionEvent(source, selection)
Fires after the selection changes.
BeforeSelect : SelectionEvent(source, model)
Fires before a row is selected. Listeners can set the doit field to false to cancel the operation.


Constructor Summary
AbstractStoreSelectionModel()
           
 
Method Summary
 void addSelectionChangedListener(SelectionChangedListener listener)
          Add a selection changed listener.
 void bind(ListStore store)
          Binds the store to the selection model.
 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<M> items)
          Deselects the items.
 void deselect(M... items)
          Deselects the items.
 void deselect(M item)
          Deselects the item.
 void deselectAll()
          Deselects all selections.
 M getSelectedItem()
          Returns the selected item.
 java.util.List<M> getSelectedItems()
          Returns the selected items.
 java.util.List<M> getSelection()
          Returns the current selection.
 Style.SelectionMode getSelectionMode()
          Returns the selection mode.
 boolean isLocked()
          Returns true if the selection model is locked.
 boolean isSelected(M item)
          Returns true if the item is selcted.
 void refresh()
          Refreshes the current selections.
 void removeSelectionListener(SelectionChangedListener listener)
          Removes a selection changed listener.
 void select(int index)
          Selects the item at the given index.
 void select(int start, int end)
          Selects the range.
 void select(java.util.List<M> items)
          Selects the items.
 void select(M... items)
          Selects the items.
 void select(M item)
          Selects the item.
 void selectAll()
          Selets all items.
 void setLocked(boolean locked)
          True to lock the selection model.
 void setSelection(java.util.List<M> selection)
          Sets the current selection for this selection provider.
 void setSelectionMode(Style.SelectionMode selectionMode)
          Sets the selection mode.
 
Methods inherited from class com.extjs.gxt.ui.client.event.BaseObservable
addListener, fireEvent, fireEvent, getFiresEvents, hasListeners, hasListeners, removeAllListeners, removeListener, setFiresEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractStoreSelectionModel

public AbstractStoreSelectionModel()
Method Detail

addSelectionChangedListener

public void addSelectionChangedListener(SelectionChangedListener listener)
Description copied from interface: SelectionProvider
Add a selection changed listener.

Specified by:
addSelectionChangedListener in interface SelectionProvider<M extends ModelData>
Parameters:
listener - a selection changed listener

bind

public void bind(ListStore store)
Description copied from interface: StoreSelectionModel
Binds the store to the selection model.

Specified by:
bind in interface StoreSelectionModel<M extends ModelData>
Parameters:
store - the bound store

deselect

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

Specified by:
deselect in interface StoreSelectionModel<M extends ModelData>
Parameters:
index - the index of the item to be deselected

deselect

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

Specified by:
deselect in interface StoreSelectionModel<M extends ModelData>
Parameters:
start - the start index
end - the end index

deselect

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

Specified by:
deselect in interface StoreSelectionModel<M extends ModelData>
Parameters:
items - the item

deselect

public void deselect(M... items)
Description copied from interface: StoreSelectionModel
Deselects the items.

Specified by:
deselect in interface StoreSelectionModel<M extends ModelData>
Parameters:
items - the items to deselect

deselect

public void deselect(M item)
Description copied from interface: StoreSelectionModel
Deselects the item.

Specified by:
deselect in interface StoreSelectionModel<M extends ModelData>
Parameters:
item - the item to be deselected

deselectAll

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

Specified by:
deselectAll in interface StoreSelectionModel<M extends ModelData>

getSelectedItem

public M getSelectedItem()
Description copied from interface: StoreSelectionModel
Returns the selected item.

Specified by:
getSelectedItem in interface StoreSelectionModel<M extends ModelData>

getSelectedItems

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

Specified by:
getSelectedItems in interface StoreSelectionModel<M extends ModelData>

getSelection

public java.util.List<M> getSelection()
Description copied from interface: SelectionProvider
Returns the current selection.

Specified by:
getSelection in interface SelectionProvider<M extends ModelData>
Returns:
the current selection

getSelectionMode

public Style.SelectionMode getSelectionMode()
Description copied from interface: StoreSelectionModel
Returns the selection mode.

Specified by:
getSelectionMode in interface StoreSelectionModel<M extends ModelData>
Returns:
the selection mode

isLocked

public boolean isLocked()
Returns true if the selection model is locked.

Returns:
the locked state

isSelected

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

Specified by:
isSelected in interface StoreSelectionModel<M extends ModelData>
Parameters:
item - the item
Returns:
true if selected

refresh

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

Specified by:
refresh in interface StoreSelectionModel<M extends ModelData>

removeSelectionListener

public void removeSelectionListener(SelectionChangedListener listener)
Description copied from interface: SelectionProvider
Removes a selection changed listener.

Specified by:
removeSelectionListener in interface SelectionProvider<M extends ModelData>
Parameters:
listener - a selection changed listener

select

public void select(int index)
Description copied from interface: StoreSelectionModel
Selects the item at the given index.

Specified by:
select in interface StoreSelectionModel<M extends ModelData>
Parameters:
index - the index of the item to be selected

select

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

Specified by:
select in interface StoreSelectionModel<M extends ModelData>
Parameters:
start - the start index
end - the end index

select

public void select(java.util.List<M> items)
Description copied from interface: StoreSelectionModel
Selects the items. Selects the first item for single-select.

Specified by:
select in interface StoreSelectionModel<M extends ModelData>
Parameters:
items - the items to select

select

public void select(M... items)
Description copied from interface: StoreSelectionModel
Selects the items. Selects the first item for single-select.

Specified by:
select in interface StoreSelectionModel<M extends ModelData>
Parameters:
items - the items

select

public void select(M item)
Description copied from interface: StoreSelectionModel
Selects the item.

Specified by:
select in interface StoreSelectionModel<M extends ModelData>
Parameters:
item - the item

selectAll

public void selectAll()
Description copied from interface: StoreSelectionModel
Selets all items.

Specified by:
selectAll in interface StoreSelectionModel<M extends ModelData>

setLocked

public void setLocked(boolean locked)
True to lock the selection model. When locked, all selection changes are disabled.

Parameters:
locked - true to lock

setSelection

public void setSelection(java.util.List<M> selection)
Description copied from interface: SelectionProvider
Sets the current selection for this selection provider.

Specified by:
setSelection in interface SelectionProvider<M extends ModelData>
Parameters:
selection - the new selection

setSelectionMode

public void setSelectionMode(Style.SelectionMode selectionMode)
Description copied from interface: StoreSelectionModel
Sets the selection mode.

Specified by:
setSelectionMode in interface StoreSelectionModel<M extends ModelData>
Parameters:
selectionMode - the selection mode