Package org.jjazz.cl_editor.api
Class CL_SelectionUtilities
java.lang.Object
org.jjazz.cl_editor.api.CL_SelectionUtilities
Provide convenience methods to get information about a selection in a lookup.
Selected items can be either ChordLeadSheetItems or SelectedBars, but not both in the same time.
-
Constructor Summary
ConstructorDescriptionCL_SelectionUtilities
(org.openide.util.Lookup lookup) Refresh the selection with selected objects in the specified lookup. -
Method Summary
Modifier and TypeMethodDescriptionCan be null if selection is empty.int
The first selected bar index if bars are selected, or the barIndex of the first item selected if items are selected.int
Same as getMaxBarIndex but limited to bars within the chordleadsheet's range.int
The first selected bar index if bars are selected, or the barIndex of the first item selected if items are selected.int
Same as getMinBarIndex but limited to bars within the chordleadsheet's range.The bar indexes of the SelectedBars (sorted by position).Same as getSelectedBarsIndexes() but limited to bars within the chordleadsheet's range.Get the selected bars sorted by position.Same as getSelectedBars() but limited to bars within the chordleadsheet's range.Get only the selected chord symbols sorted by position.Get all the selected items sections, chord symbols, sorted by position.Get only the selected sections sorted by position.boolean
True if a BarBox is selected.boolean
isBarSelected
(int bbIndex) boolean
True if at least one selected BarBox is within the chordleadsheet range.boolean
Same as isContiguousBarSelection but limited to bars within the chordleadsheet's range.boolean
True if all selectedBars are contiguous.boolean
isEmpty()
boolean
boolean
isItemSelected
(ChordLeadSheetItem<?> item) toString()
void
unselectAll
(CL_Editor editor) Unselect the current selection in the specified editor.
-
Constructor Details
-
CL_SelectionUtilities
public CL_SelectionUtilities(org.openide.util.Lookup lookup) Refresh the selection with selected objects in the specified lookup.- Parameters:
lookup
-- Throws:
IllegalStateException
- If lookup contains both SelectedBars and ChordLeadSheetItems
-
-
Method Details
-
unselectAll
Unselect the current selection in the specified editor.- Parameters:
editor
-
-
isContiguousBarSelection
public boolean isContiguousBarSelection()True if all selectedBars are contiguous.- Returns:
-
isContiguousBarboxSelectionWithinCls
public boolean isContiguousBarboxSelectionWithinCls()Same as isContiguousBarSelection but limited to bars within the chordleadsheet's range.- Returns:
-
isEmpty
public boolean isEmpty() -
isItemSelected
public boolean isItemSelected() -
isBarSelected
public boolean isBarSelected()True if a BarBox is selected.- Returns:
-
isBarSelectedWithinCls
public boolean isBarSelectedWithinCls()True if at least one selected BarBox is within the chordleadsheet range.- Returns:
-
getMinBarIndexWithinCls
public int getMinBarIndexWithinCls()Same as getMinBarIndex but limited to bars within the chordleadsheet's range.- Returns:
- -1 if selection is empty or first selected bar is after chordleadsheet's end.
-
getMaxBarIndexWithinCls
public int getMaxBarIndexWithinCls()Same as getMaxBarIndex but limited to bars within the chordleadsheet's range.- Returns:
- -1 if selection is empty or selected bars are after chordleadsheet's end.
-
getMaxBarIndex
public int getMaxBarIndex()The first selected bar index if bars are selected, or the barIndex of the first item selected if items are selected.- Returns:
- -1 if selection is empty.
-
getMinBarIndex
public int getMinBarIndex()The first selected bar index if bars are selected, or the barIndex of the first item selected if items are selected.- Returns:
- -1 if selection is empty.
-
getChordLeadSheet
Can be null if selection is empty.- Returns:
-
isItemSelected
-
isBarSelected
public boolean isBarSelected(int bbIndex) -
getSelectedItems
Get all the selected items sections, chord symbols, sorted by position.- Returns:
- Can be empty.
-
getSelectedChordSymbols
Get only the selected chord symbols sorted by position.- Returns:
- Can be empty.
-
getSelectedBars
Get the selected bars sorted by position.- Returns:
- Can be empty if isItemSelected() returns true.
-
getSelectedBarIndexes
The bar indexes of the SelectedBars (sorted by position).Return an empty list if selection is not made of SelectedBars.
- Returns:
-
getSelectedBarsWithinCls
Same as getSelectedBars() but limited to bars within the chordleadsheet's range.- Returns:
- Can be empty if isItemSelected() returns true.
-
getSelectedBarIndexesWithinCls
Same as getSelectedBarsIndexes() but limited to bars within the chordleadsheet's range.- Returns:
-
getSelectedSections
Get only the selected sections sorted by position.- Returns:
- Can be empty.
-
toString
-