Class BreadcrumbBarContentModel<T>
- java.lang.Object
-
- org.pushingpixels.radiance.component.api.bcb.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 Summary
Fields Modifier and Type Field Description private boolean
isCumulative
Indication whether the model is in cumulative mode.private java.util.LinkedList<BreadcrumbItem<T>>
items
The list of breadcrumb items.private java.util.List<BreadcrumbPathListener<T>>
listenerList
Listener list.private int
smallestCumulativeIndex
Smallest index of path change since the last call tosetCumulative(boolean)
withtrue
.
-
Constructor Summary
Constructors Constructor Description BreadcrumbBarContentModel()
Creates a new empty model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLast(BreadcrumbItem<T> item)
Adds the specified item at the end of the path.void
addPathListener(BreadcrumbPathListener<T> l)
Adds the specified path listener to this model.private void
firePathChanged(int indexOfFirstChange)
Fires aBreadcrumbPathEvent
.BreadcrumbItem<T>
getItem(int index)
Returns the model item at the specified index.int
getItemCount()
Returns the number of items in this model.java.util.List<BreadcrumbItem<T>>
getItems()
Returns an unmodifiable list of the items in this model.int
indexOf(BreadcrumbItem<T> item)
Returns the index of the specified item.void
removeLast()
Removes the last item in this model.void
removePathListener(BreadcrumbPathListener<T> l)
Removes the specified path listener from this model.void
replace(java.util.List<BreadcrumbItem<T>> items)
Replaces the current item list with the specified list.void
reset()
Resets this model, removing all the items.void
setCumulative(boolean isCumulative)
Starts or ends the cumulative mode.
-
-
-
Field Detail
-
items
private java.util.LinkedList<BreadcrumbItem<T>> items
The list of breadcrumb items.
-
listenerList
private java.util.List<BreadcrumbPathListener<T>> listenerList
Listener list.
-
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 tosetCumulative(boolean)
withtrue
.
-
-
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 toaddLast(BreadcrumbItem)
,removeLast()
,replace(List)
andreset()
will not fire events on the listeners registered withaddPathListener(BreadcrumbPathListener)
.- Parameters:
isCumulative
- Iftrue
, the model enters cumulative mode. Iffalse
, 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 withtrue
.
-
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)
Fires aBreadcrumbPathEvent
.- Parameters:
indexOfFirstChange
- Index of the first item that has changed in the model.
-
-