Class CL_SelectionUtilities

java.lang.Object
org.jjazz.cl_editor.api.CL_SelectionUtilities

public final class CL_SelectionUtilities extends Object
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 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

      public void unselectAll(CL_Editor editor)
      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

      public ChordLeadSheet getChordLeadSheet()
      Can be null if selection is empty.
      Returns:
    • isItemSelected

      public boolean isItemSelected(ChordLeadSheetItem<?> item)
    • isBarSelected

      public boolean isBarSelected(int bbIndex)
    • getSelectedItems

      public List<ChordLeadSheetItem> getSelectedItems()
      Get all the selected items sections, chord symbols, sorted by position.
      Returns:
      Can be empty.
    • getSelectedChordSymbols

      public List<CLI_ChordSymbol> getSelectedChordSymbols()
      Get only the selected chord symbols sorted by position.
      Returns:
      Can be empty.
    • getSelectedBars

      public List<SelectedBar> getSelectedBars()
      Get the selected bars sorted by position.
      Returns:
      Can be empty if isItemSelected() returns true.
    • getSelectedBarIndexes

      public List<Integer> getSelectedBarIndexes()
      The bar indexes of the SelectedBars (sorted by position).

      Return an empty list if selection is not made of SelectedBars.

      Returns:
    • getSelectedBarsWithinCls

      public List<SelectedBar> getSelectedBarsWithinCls()
      Same as getSelectedBars() but limited to bars within the chordleadsheet's range.
      Returns:
      Can be empty if isItemSelected() returns true.
    • getSelectedBarIndexesWithinCls

      public List<Integer> getSelectedBarIndexesWithinCls()
      Same as getSelectedBarsIndexes() but limited to bars within the chordleadsheet's range.

      Returns:
    • getSelectedSections

      public List<CLI_Section> getSelectedSections()
      Get only the selected sections sorted by position.
      Returns:
      Can be empty.
    • toString

      public String toString()
      Overrides:
      toString in class Object