Class EventSelectionModel<E>

    • Constructor Detail

      • EventSelectionModel

        public EventSelectionModel​(EventList<E> source)
        Creates a new selection model that also presents a list of the selection. The EventSelectionModel listens to this EventList in order to adjust selection when the EventList is modified. For example, when an element is added to the EventList, this may offset the selection of the following elements.
        Parameters:
        source - the EventList whose selection will be managed. This should be the same EventList passed to the constructor of your EventTableModel or EventListModel.
    • Method Detail

      • getSelected

        public EventList<E> getSelected()
        Gets an EventList that contains only selected values and modifies the source list on mutation. Adding and removing items from this list performs the same operation on the source list.
      • getTogglingSelected

        public EventList<E> getTogglingSelected()
        Gets an EventList that contains only selected values and modifies the selection state on mutation. Adding an item to this list selects it and removing an item deselects it. If an item not in the source list is added an IllegalArgumentException is thrown.
      • getDeselected

        public EventList<E> getDeselected()
        Gets an EventList that contains only deselected values and modifies the source list on mutation. Adding and removing items from this list performs the same operation on the source list.
      • getTogglingDeselected

        public EventList<E> getTogglingDeselected()
        Gets an EventList that contains only deselected values and modifies the selection state on mutation. Adding an item to this list deselects it and removing an item selects it. If an item not in the source list is added an IllegalArgumentException is thrown
      • setEnabled

        public void setEnabled​(boolean enabled)
        Set the EventSelectionModel as editable or not. This means that the user cannot manipulate the selection by clicking. The selection can still be changed as the source list changes.

        Note that this will also disable the selection from being modified programatically. Therefore you must use setEnabled(true) to modify the selection in code.

      • getEnabled

        public boolean getEnabled()
        Returns whether the EventSelectionModel is editable or not.
      • invertSelection

        public void invertSelection()
        Inverts the current selection.
      • setSelectionInterval

        public void setSelectionInterval​(int index0,
                                         int index1)
        Change the selection to be between index0 and index1 inclusive.

        First this calculates the smallest range where changes occur. This includes the union of the selection range before and the selection range specified. It then walks through the change and sets each index as selected or not based on whether the index is in the new range. Finally it fires events to both the listening lists and selection listeners about what changes happened.

        If the selection does not change, this will not fire any events.

        Specified by:
        setSelectionInterval in interface ListSelectionModel
      • addSelectionInterval

        public void addSelectionInterval​(int index0,
                                         int index1)
        Change the selection to be the set union of the current selection and the indices between index0 and index1 inclusive
        Specified by:
        addSelectionInterval in interface ListSelectionModel
      • removeSelectionInterval

        public void removeSelectionInterval​(int index0,
                                            int index1)
        Change the selection to be the set difference of the current selection and the indices between index0 and index1 inclusive.
        Specified by:
        removeSelectionInterval in interface ListSelectionModel
      • isSelectedIndex

        public boolean isSelectedIndex​(int index)
        Returns true if the specified index is selected. If the specified index has not been seen before, this will return false. This is in the case where the table painting and selection have fallen out of sync. Usually in this case there is an update event waiting in the event queue that notifies this model of the change in table size.
        Specified by:
        isSelectedIndex in interface ListSelectionModel
      • getAnchorSelectionIndex

        public int getAnchorSelectionIndex()
        Return the first index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().
        Specified by:
        getAnchorSelectionIndex in interface ListSelectionModel
      • getLeadSelectionIndex

        public int getLeadSelectionIndex()
        Return the second index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().
        Specified by:
        getLeadSelectionIndex in interface ListSelectionModel
      • insertIndexInterval

        public void insertIndexInterval​(int index,
                                        int length,
                                        boolean before)
        Insert length indices beginning before/after index.
        Specified by:
        insertIndexInterval in interface ListSelectionModel
      • removeIndexInterval

        public void removeIndexInterval​(int index0,
                                        int index1)
        Remove the indices in the interval index0,index1 (inclusive) from the selection model.
        Specified by:
        removeIndexInterval in interface ListSelectionModel
      • setValueIsAdjusting

        public void setValueIsAdjusting​(boolean valueIsAdjusting)
        This property is true if upcoming changes to the value of the model should be considered a single event.
        Specified by:
        setValueIsAdjusting in interface ListSelectionModel
      • getValueIsAdjusting

        public boolean getValueIsAdjusting()
        Returns true if the value is undergoing a series of changes.
        Specified by:
        getValueIsAdjusting in interface ListSelectionModel
      • addValidSelectionMatcher

        public void addValidSelectionMatcher​(Matcher<E> validSelectionMatcher)
        Add a matcher which decides when source elements are valid for selection.
        Parameters:
        validSelectionMatcher - returns true if a source element can be selected; false otherwise
      • removeValidSelectionMatcher

        public void removeValidSelectionMatcher​(Matcher<E> validSelectionMatcher)
        Remove a matcher which decides when source elements are valid for selection.
        Parameters:
        validSelectionMatcher - returns true if a source element can be selected; false otherwise
      • addListSelectionListener

        public void addListSelectionListener​(ListSelectionListener listener)
        Add a listener to the list that's notified each time a change to the selection occurs. Note that the change events fired by this class may include rows that have been removed from the table. For this reason it is advised not to for() through the changed range without also verifying that each row is still in the table.
        Specified by:
        addListSelectionListener in interface ListSelectionModel