# Interface ISelectionProvider

All Known Subinterfaces:
  `IContentOutlinePage, IInputSelectionProvider, IPostSelectionProvider`

All Known Implementing Classes:
  `AbstractListViewer, AbstractTableViewer, AbstractTextEditor.SelectionProvider, AbstractTreeViewer, AbstractViewer, BinaryCompareViewer, CheckboxTableViewer, CheckboxTreeViewer, ColumnViewer, ComboViewer, CommonViewer, CompareContentViewerSwitchingPane, CompareEditorSelectionProvider, CompareOutlinePage, CompareStructureViewerSwitchingPane, CompareViewerPane, CompareViewerSwitchingPane, ContainerCheckedTreeViewer, ContentMergeViewer, ContentOutline, ContentOutlinePage, ContentViewer, DiffTreeViewer, ImageMergeViewer, ListViewer, MultiPageSelectionProvider, NullViewer, PageBookView.SelectionProvider, ProjectionViewer, SimpleTextViewer, SourceViewer, StructureDiffViewer, StructuredViewer, TableViewer, TextConsoleViewer, TextMergeViewer, TextViewer, TreeViewer, Viewer`

public interface ISelectionProvider
Interface common to all objects that provide a selection.

See Also:
  - `ISelection`
  - `ISelectionChangedListener`
  - `SelectionChangedEvent`

## Method Summary

Modifier and Type
Method
Description
`void`
`addSelectionChangedListener(ISelectionChangedListener listener)`
Adds a listener for selection changes in this selection provider.
`ISelection`
`getSelection()`
Returns the current selection for this provider.
`void`
`removeSelectionChangedListener(ISelectionChangedListener listener)`
Removes the given selection change listener from this selection provider.
`void`
`setSelection(ISelection selection)`
Sets the current selection for this selection provider.

## Method Details

### addSelectionChangedListener

void addSelectionChangedListener(ISelectionChangedListener listener)
Adds a listener for selection changes in this selection provider. Has no effect if an identical listener is already registered.

Parameters:
  `listener` - a selection changed listener

### getSelection

ISelection getSelection()
Returns the current selection for this provider.

Returns:
  the current selection

### removeSelectionChangedListener

void removeSelectionChangedListener(ISelectionChangedListener listener)
Removes the given selection change listener from this selection provider. Has no effect if an identical listener is not registered.

Parameters:
  `listener` - a selection changed listener

### setSelection

void setSelection(ISelection selection)
Sets the current selection for this selection provider.

Parameters:
  `selection` - the new selection