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, TreePanelSelectionModel

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 cancel the action by calling BaseEvent.setCancelled(boolean).


Field Summary
protected  M lastSelected
           
protected  boolean locked
           
protected  java.util.List<M> selected
           
protected  Style.SelectionMode selectionMode
           
protected  Store<M> store
           
protected  StoreListener<M> storeListener
           
 
Constructor Summary
AbstractStoreSelectionModel()
           
 
Method Summary
 void addSelectionChangedListener(SelectionChangedListener<M> listener)
          Add a selection changed listener.
 void bind(Store 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.
protected  void doDeselect(java.util.List<M> models, boolean supressEvent)
           
protected  void doMultiSelect(java.util.List<M> models, boolean keepExisting, boolean supressEvent)
           
protected  void doSelect(java.util.List<M> models, boolean keepExisting, boolean supressEvent)
           
protected  void doSingleSelect(M model, boolean supressEvent)
           
protected  void fireSelectionChange()
           
protected  M getLastFocused()
           
 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 selected.
protected  void onAdd(java.util.List<? extends M> models)
           
protected  void onClear(StoreEvent<M> se)
           
protected  void onLastFocusChanged(M oldFocused, M newFocused)
           
protected  void onRemove(M model)
           
protected abstract  void onSelectChange(M model, boolean select)
           
protected  void onUpdate(M model)
           
 void refresh()
          Refreshes the current selections.
 void removeSelectionListener(SelectionChangedListener<M> listener)
          Removes a selection changed listener.
 void select(boolean keepExisting, M... 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<M> items, boolean keepExisting)
          Selects the items.
 void select(M item, boolean keepExisting)
          Selects the item.
 void selectAll()
          Selects all items.
protected  void setLastFocused(M lastFocused)
           
 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, callListener, fireEvent, fireEvent, getFiresEvents, getListeners, hasActiveEvent, hasListeners, hasListeners, removeAllListeners, removeListener, setFiresEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastSelected

protected M extends ModelData lastSelected

locked

protected boolean locked

selected

protected java.util.List<M extends ModelData> selected

selectionMode

protected Style.SelectionMode selectionMode

store

protected Store<M extends ModelData> store

storeListener

protected StoreListener<M extends ModelData> storeListener
Constructor Detail

AbstractStoreSelectionModel

public AbstractStoreSelectionModel()
Method Detail

addSelectionChangedListener

public void addSelectionChangedListener(SelectionChangedListener<M> 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(Store 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 selected.

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<M> 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(boolean keepExisting,
                   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:
keepExisting - true to keep existing selected
items - the items

select

public void select(int index,
                   boolean keepExisting)
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
keepExisting - true to keep existing selected

select

public void select(int start,
                   int end,
                   boolean keepExisting)
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
keepExisting - true to keep existing selected

select

public void select(java.util.List<M> items,
                   boolean keepExisting)
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
keepExisting - true to keep existing selected

select

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

Specified by:
select in interface StoreSelectionModel<M extends ModelData>
Parameters:
item - the item
keepExisting - true to keep existing selected

selectAll

public void selectAll()
Description copied from interface: StoreSelectionModel
Selects 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.

The selection model supports 3 different selection modes:

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

doDeselect

protected void doDeselect(java.util.List<M> models,
                          boolean supressEvent)

doMultiSelect

protected void doMultiSelect(java.util.List<M> models,
                             boolean keepExisting,
                             boolean supressEvent)

doSelect

protected void doSelect(java.util.List<M> models,
                        boolean keepExisting,
                        boolean supressEvent)

doSingleSelect

protected void doSingleSelect(M model,
                              boolean supressEvent)

fireSelectionChange

protected void fireSelectionChange()

getLastFocused

protected M getLastFocused()

onAdd

protected void onAdd(java.util.List<? extends M> models)

onClear

protected void onClear(StoreEvent<M> se)

onLastFocusChanged

protected void onLastFocusChanged(M oldFocused,
                                  M newFocused)

onRemove

protected void onRemove(M model)

onSelectChange

protected abstract void onSelectChange(M model,
                                       boolean select)

onUpdate

protected void onUpdate(M model)

setLastFocused

protected void setLastFocused(M lastFocused)