Package com.google.gwt.view.client
Class SingleSelectionModel<T>
- java.lang.Object
-
- com.google.gwt.view.client.SelectionModel.AbstractSelectionModel<T>
-
- com.google.gwt.view.client.SingleSelectionModel<T>
-
- Type Parameters:
T- the record data type
- All Implemented Interfaces:
HasHandlers,ProvidesKey<T>,SelectionChangeEvent.HasSelectionChangedHandlers,SelectionModel<T>,SetSelectionModel<T>
public class SingleSelectionModel<T> extends SelectionModel.AbstractSelectionModel<T> implements SetSelectionModel<T>
A simple selection model that allows only one item to be selected a a time.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.gwt.view.client.SelectionModel
SelectionModel.AbstractSelectionModel<T>
-
-
Constructor Summary
Constructors Constructor Description SingleSelectionModel()Constructs a SingleSelectionModel without a key provider.SingleSelectionModel(ProvidesKey<T> keyProvider)Constructs a SingleSelectionModel with the given key provider.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the current selection.protected voidfireSelectionChangeEvent()Fire aSelectionChangeEvent.TgetSelectedObject()Gets the currently-selected item.java.util.Set<T>getSelectedSet()Get the set of selected items.booleanisSelected(T item)Check if an object is selected.voidsetSelected(T item, boolean selected)Set the selected state of an object and fire aSelectionChangeEventif the selection has changed.-
Methods inherited from class com.google.gwt.view.client.SelectionModel.AbstractSelectionModel
addSelectionChangeHandler, fireEvent, getKey, getKeyProvider, isEventCancelled, isEventScheduled, scheduleSelectionChangeEvent, setEventCancelled, setEventScheduled
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
-
Methods inherited from interface com.google.gwt.view.client.ProvidesKey
getKey
-
Methods inherited from interface com.google.gwt.view.client.SelectionModel
addSelectionChangeHandler
-
-
-
-
Constructor Detail
-
SingleSelectionModel
public SingleSelectionModel()
Constructs a SingleSelectionModel without a key provider.
-
SingleSelectionModel
public SingleSelectionModel(ProvidesKey<T> keyProvider)
Constructs a SingleSelectionModel with the given key provider.- Parameters:
keyProvider- an instance of ProvidesKey, or null if the item should act as its own key
-
-
Method Detail
-
clear
public void clear()
Description copied from interface:SetSelectionModelClears the current selection.- Specified by:
clearin interfaceSetSelectionModel<T>
-
getSelectedObject
public T getSelectedObject()
Gets the currently-selected item.- Returns:
- the selected item
-
getSelectedSet
public java.util.Set<T> getSelectedSet()
Description copied from interface:SetSelectionModelGet the set of selected items.- Specified by:
getSelectedSetin interfaceSetSelectionModel<T>- Returns:
- the set of selected items
-
isSelected
public boolean isSelected(T item)
Description copied from interface:SelectionModelCheck if an object is selected.- Specified by:
isSelectedin interfaceSelectionModel<T>- Parameters:
item- the object- Returns:
- true if selected, false if not
-
setSelected
public void setSelected(T item, boolean selected)
Description copied from interface:SelectionModelSet the selected state of an object and fire aSelectionChangeEventif the selection has changed. Subclasses should not fire an event in the case where selected is true and the object was already selected, or selected is false and the object was not previously selected.- Specified by:
setSelectedin interfaceSelectionModel<T>- Parameters:
item- the object to select or deselectselected- true to select, false to deselect
-
fireSelectionChangeEvent
protected void fireSelectionChangeEvent()
Description copied from class:SelectionModel.AbstractSelectionModelFire aSelectionChangeEvent. Multiple firings may be coalesced.- Overrides:
fireSelectionChangeEventin classSelectionModel.AbstractSelectionModel<T>
-
-