Class BreadcrumbBarContentModel<T>

  • Type Parameters:
    T - Type of data associated with each breadcrumb bar item.

    public class BreadcrumbBarContentModel<T>
    extends java.lang.Object
    Model for the breadcrumb bar component (JBreadcrumbBar).
    • Field Detail

      • items

        private java.util.LinkedList<BreadcrumbItem<T>> items
        The list of breadcrumb items.
      • isCumulative

        private boolean isCumulative
        Indication whether the model is in cumulative mode.
        See Also:
        setCumulative(boolean)
      • smallestCumulativeIndex

        private int smallestCumulativeIndex
        Smallest index of path change since the last call to setCumulative(boolean) with true.
    • Constructor Detail

      • BreadcrumbBarContentModel

        public BreadcrumbBarContentModel()
        Creates a new empty model.
    • Method Detail

      • indexOf

        public int indexOf​(BreadcrumbItem<T> item)
        Returns the index of the specified item.
        Parameters:
        item - Item.
        Returns:
        Index of the item if it is in the model or -1 if it is not.
      • removeLast

        public void removeLast()
        Removes the last item in this model.
      • reset

        public void reset()
        Resets this model, removing all the items.
      • getItems

        public java.util.List<BreadcrumbItem<T>> getItems()
        Returns an unmodifiable list of the items in this model.
        Returns:
        Unmodifiable list of the items in this model.
      • getItemCount

        public int getItemCount()
        Returns the number of items in this model.
        Returns:
        Number of items in this model.
      • getItem

        public BreadcrumbItem<T> getItem​(int index)
        Returns the model item at the specified index.
        Parameters:
        index - Item index.
        Returns:
        The model item at the specified index. Will return null if the index is negative or larger than the number of items.
      • replace

        public void replace​(java.util.List<BreadcrumbItem<T>> items)
        Replaces the current item list with the specified list.
        Parameters:
        items - New contents of the model.
      • addLast

        public void addLast​(BreadcrumbItem<T> item)
        Adds the specified item at the end of the path.
        Parameters:
        item - Item to add.
      • setCumulative

        public void setCumulative​(boolean isCumulative)
        Starts or ends the cumulative mode. In cumulative mode calls to addLast(BreadcrumbItem), removeLast(), replace(List) and reset() will not fire events on the listeners registered with addPathListener(BreadcrumbPathListener).
        Parameters:
        isCumulative - If true, the model enters cumulative mode. If false, the model exist cumulative mode and fires a path event on all registered listeners with the smallest index of all changes that have happened since the last time this method was called with true.
      • addPathListener

        public void addPathListener​(BreadcrumbPathListener<T> l)
        Adds the specified path listener to this model.
        Parameters:
        l - Path listener to add.
      • removePathListener

        public void removePathListener​(BreadcrumbPathListener<T> l)
        Removes the specified path listener from this model.
        Parameters:
        l - Path listener to remove.
      • firePathChanged

        private void firePathChanged​(int indexOfFirstChange)
        Parameters:
        indexOfFirstChange - Index of the first item that has changed in the model.