Class BreadcrumbBarModel<T>
- java.lang.Object
-
- org.pushingpixels.flamingo.api.bcb.BreadcrumbBarModel<T>
-
- Type Parameters:
T
- Type of data associated with each breadcrumb bar item.
public class BreadcrumbBarModel<T> extends Object
Model for the breadcrumb bar component (JBreadcrumbBar
).
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
isCumulative
Indication whether the model is in cumulative mode.protected EventListenerList
listenerList
Listener list.protected int
smallestCumulativeIndex
Smallest index of path change since the last call tosetCumulative(boolean)
withtrue
.
-
Constructor Summary
Constructors Constructor Description BreadcrumbBarModel()
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 l)
Adds the specified path listener to this model.protected 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.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 l)
Removes the specified path listener from this model.void
replace(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
-
listenerList
protected EventListenerList listenerList
Listener list.
-
isCumulative
protected boolean isCumulative
Indication whether the model is in cumulative mode.- See Also:
setCumulative(boolean)
-
smallestCumulativeIndex
protected 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 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(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 l)
Adds the specified path listener to this model.- Parameters:
l
- Path listener to add.
-
removePathListener
public void removePathListener(BreadcrumbPathListener l)
Removes the specified path listener from this model.- Parameters:
l
- Path listener to remove.
-
firePathChanged
protected void firePathChanged(int indexOfFirstChange)
Fires aBreadcrumbPathEvent
.- Parameters:
indexOfFirstChange
- Index of the first item that has changed in the model.
-
-