eu.webtoolkit.jwt
Class WItemSelectionModel

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WItemSelectionModel

public class WItemSelectionModel
extends WObject

A class that represents a selection for a WAbstractItemView.

This model is currently only used by WTreeView, and plays only a role in drag & drop of an item selection.

When an item selection is dragged from a view widget, the generated drop events will have as source object (see WDropEvent#getSource()) this selection model.

Although this class does not (yet) allow you to modify the selection, note that manipulations to the model may modify the selection (row insertions and removals may shift the selection, and row deletions may shrink the selection).

Note: Currently this class cannot be shared between multiple views.

See Also:
WTreeView, WTableView, WAbstractItemModel

Method Summary
 WAbstractItemModel getModel()
          Returns the WAbstractItemModel.
 java.util.SortedSet<WModelIndex> getSelectedIndexes()
          Returns the set of selected items.
 SelectionBehavior getSelectionBehavior()
          Returns the selection behaviour.
 boolean isSelected(WModelIndex index)
          Returns wheter an item is selected.
 void setSelectionBehavior(SelectionBehavior behavior)
          Sets the selection behaviour.
 
Methods inherited from class eu.webtoolkit.jwt.WObject
getId, getObjectName, remove, setObjectName, tr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getModel

public WAbstractItemModel getModel()
Returns the WAbstractItemModel.


getSelectedIndexes

public java.util.SortedSet<WModelIndex> getSelectedIndexes()
Returns the set of selected items.

The model indexes are returned as a set, topologically ordered (in the order they appear in the view).


isSelected

public boolean isSelected(WModelIndex index)
Returns wheter an item is selected.

See Also:
getSelectedIndexes()

setSelectionBehavior

public void setSelectionBehavior(SelectionBehavior behavior)
Sets the selection behaviour.

By default, the selection contains rows ( SelectRows), in which case model indexes will always be have column 0, but represent the whole row.

Alternatively, you can allow selection for individual items ( SelectItems).


getSelectionBehavior

public SelectionBehavior getSelectionBehavior()
Returns the selection behaviour.

See Also:
setSelectionBehavior(SelectionBehavior behavior)