Class BaseListWithButtons

    • Field Detail

      • m_CountModelListener

        protected ListDataListener m_CountModelListener
        the model listener for updating the counts.
    • Constructor Detail

      • BaseListWithButtons

        public BaseListWithButtons()
        The default constructor.
      • BaseListWithButtons

        public BaseListWithButtons​(ListModel model)
        Initializes the list with the specified model.
        Parameters:
        model - the model to use
    • Method Detail

      • setModel

        public void setModel​(ListModel model)
        Sets the model that represents the contents or "value" of the list, notifies property change listeners, and then clears the list's selection.

        This is a JavaBeans bound property.

        Parameters:
        model - the ListModel that provides the list of items for display
      • getModel

        public ListModel getModel()
        Returns the underlying list model.
        Returns:
        the underlying list model
      • addListSelectionListener

        public void addListSelectionListener​(ListSelectionListener listener)
        Adds a listener to the list, to be notified each time a change to the selection occurs; the preferred way of listening for selection state changes. JList takes care of listening for selection state changes in the selection model, and notifies the given listener of each change. ListSelectionEvents sent to the listener have a source property set to this list.
        Parameters:
        listener - the ListSelectionListener to add
      • removeListSelectionListener

        public void removeListSelectionListener​(ListSelectionListener listener)
        Removes a selection listener from the list.
        Parameters:
        listener - the ListSelectionListener to remove
      • getSelectedIndices

        public int[] getSelectedIndices()
        Returns an array of all of the selected indices, in increasing order.
        Returns:
        all of the selected indices, in increasing order, or an empty array if nothing is selected
        See Also:
        #removeSelectionInterval, addListSelectionListener(javax.swing.event.ListSelectionListener)
      • setSelectedIndices

        public void setSelectedIndices​(int[] indices)
        Changes the selection to be the set of indices specified by the given array. Indices greater than or equal to the model size are ignored. This is a convenience method that clears the selection and then uses addSelectionInterval on the selection model to add the indices. Refer to the documentation of the selection model class being used for details on how values less than 0 are handled.
        Parameters:
        indices - an array of the indices of the cells to select, non-null
        Throws:
        NullPointerException - if the given array is null
        See Also:
        ListSelectionModel.addSelectionInterval(int, int), #isSelectedIndex, addListSelectionListener(javax.swing.event.ListSelectionListener)
      • getSelectedValuesList

        public List getSelectedValuesList()
        Returns a list of all the selected items, in increasing order based on their indices in the list.
        Returns:
        the selected items, or an empty list if nothing is selected
      • getSelectedIndex

        public int getSelectedIndex()
        Returns the smallest selected cell index; the selection when only a single item is selected in the list. When multiple items are selected, it is simply the smallest selected index. Returns -1 if there is no selection.

        This method is a cover that delegates to getMinSelectionIndex.

        Returns:
        the smallest selected cell index
      • getSelectedValue

        public Object getSelectedValue()
        Returns the value for the smallest selected cell index; the selected value when only a single item is selected in the list. When multiple items are selected, it is simply the value for the smallest selected index. Returns null if there is no selection.

        This is a convenience method that simply returns the model value for getMinSelectionIndex.

        Returns:
        the first selected value
      • setSelectedValue

        public void setSelectedValue​(Object anObject,
                                     boolean shouldScroll)
        Selects the specified object from the list.
        Parameters:
        anObject - the object to select
        shouldScroll - true if the list should scroll to display the selected object, if one exists; otherwise false
      • moveUp

        public void moveUp()
        moves the selected items up by 1.
      • moveDown

        public void moveDown()
        moves the selected item down by 1.
      • moveTop

        public void moveTop()
        moves the selected items to the top.
      • moveBottom

        public void moveBottom()
        moves the selected items to the end.
      • canMoveUp

        public boolean canMoveUp()
        checks whether the selected items can be moved up.
        Returns:
        true if the selected items can be moved
      • canMoveDown

        public boolean canMoveDown()
        checks whether the selected items can be moved down.
        Returns:
        true if the selected items can be moved
      • setSelectionMode

        public void setSelectionMode​(int selectionMode)
        Sets the selection mode for the list. This is a cover method that sets the selection mode directly on the selection model.

        The following list describes the accepted selection modes:

        • ListSelectionModel.SINGLE_SELECTION - Only one list index can be selected at a time. In this mode, setSelectionInterval and addSelectionInterval are equivalent, both replacing the current selection with the index represented by the second argument (the "lead").
        • ListSelectionModel.SINGLE_INTERVAL_SELECTION - Only one contiguous interval can be selected at a time. In this mode, addSelectionInterval behaves like setSelectionInterval (replacing the current selection}, unless the given interval is immediately adjacent to or overlaps the existing selection, and can be used to grow the selection.
        • ListSelectionModel.MULTIPLE_INTERVAL_SELECTION - In this mode, there's no restriction on what can be selected. This mode is the default.
        Parameters:
        selectionMode - the selection mode
        See Also:
        getSelectionMode()
      • getSelectionMode

        public int getSelectionMode()
        Returns the current selection mode for the list. This is a cover method that delegates to the method of the same name on the list's selection model.
        Returns:
        the current selection mode
        See Also:
        setSelectionMode(int)
      • setSelectionModel

        public void setSelectionModel​(ListSelectionModel selectionModel)
        Sets the selectionModel for the list to a non-null ListSelectionModel implementation. The selection model handles the task of making single selections, selections of contiguous ranges, and non-contiguous selections.

        This is a JavaBeans bound property.

        Parameters:
        selectionModel - the ListSelectionModel that implements the selections
      • addRemoveItemsListener

        public void addRemoveItemsListener​(RemoveItemsListener l)
        Adds the remove items listener to its internal list.
        Parameters:
        l - the listener to add
      • removeRemoveItemsListener

        public void removeRemoveItemsListener​(RemoveItemsListener l)
        Removes the remove items listener from its internal list.
        Parameters:
        l - the listener to remove
      • setInfoVisible

        public void setInfoVisible​(boolean value)
        Whether to display the information JLabel or not.
        Overrides:
        setInfoVisible in class AbstractComponentWithButtons<BaseList>
        Parameters:
        value - if true then the information is being displayed
      • updateCountsModelListener

        protected void updateCountsModelListener​(ListModel dataModel)
        Updates the table model's listener for updating the counts.
        Parameters:
        dataModel - the model to update
      • updateCounts

        protected void updateCounts()
        Updates the information about the counts.
      • selectAll

        public void selectAll()
        Selects all items.
      • selectNone

        public void selectNone()
        Select no items.
      • invertSelection

        public void invertSelection()
        Inverts the current selection.