public class ListSelectionModel
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.ArrayList<SelectionListener> |
listeners
List of listeners.
|
private int |
mode
Active selection mode.
|
static int |
MULTIPLE_INTERVAL_SELECTION
Multiple intervals selection mode.
|
private java.util.TreeSet<java.lang.Integer> |
selection
Selected item index storage.
|
static int |
SINGLE_INTERVAL_SELECTION
Single interval selection mode.
|
static int |
SINGLE_SELECTION
Single item selection mode.
|
Constructor and Description |
---|
ListSelectionModel() |
Modifier and Type | Method and Description |
---|---|
void |
add(SelectionListener listener)
Add selection item listener.
|
private java.util.TreeSet<java.lang.Integer> |
asSet(int from,
int to)
Convert index range into set.
|
void |
clear()
Clear model and remove selection.
|
void |
deselect(int from,
int to)
Deselect specified range of items.
|
boolean |
empty()
Check if selection is empty.
|
int |
first()
Get first selected index.
|
int |
last()
Get last selected index.
|
int |
mode()
Get current selection mode.
|
void |
notifyListeners()
Trigger notification of listeners.
|
void |
select(int from,
int to)
Select specified range of items.
|
boolean |
selected(int index)
Check if specified index is selected.
|
int[] |
selection()
Get all selected indices as array.
|
void |
set(int from,
int to)
Set selection to specified interval.
|
void |
setMode(int mode)
Set selection mode.
|
private void |
setSelection(java.util.TreeSet<java.lang.Integer> newSel)
Selection setting worker.
|
public static final int SINGLE_SELECTION
public static final int SINGLE_INTERVAL_SELECTION
public static final int MULTIPLE_INTERVAL_SELECTION
private java.util.ArrayList<SelectionListener> listeners
private int mode
private java.util.TreeSet<java.lang.Integer> selection
public void select(int from, int to)
from
- Start index in the range.to
- End index in the range.public void add(SelectionListener listener)
listener
- Listener to add.public void clear()
public boolean empty()
true
if selection is empty.public int first()
public int last()
public int mode()
public int[] selection()
public void deselect(int from, int to)
from
- Start index in the range.to
- End index in the range.public boolean selected(int index)
index
- Index to check.true
if index is in one of selected ranges.public void set(int from, int to)
from
- Start index in the range.to
- End index in the range.public void setMode(int mode)
mode
- Selection mode.public void notifyListeners()
private java.util.TreeSet<java.lang.Integer> asSet(int from, int to)
from
- Initial index.to
- Final index.private void setSelection(java.util.TreeSet<java.lang.Integer> newSel)
newSel
- Source selection.