Package com.explodingpixels.macwidgets
Class SourceListModel
- java.lang.Object
-
- com.explodingpixels.macwidgets.SourceListModel
-
public final class SourceListModel extends java.lang.ObjectThe backing model to be used with aSourceList.
-
-
Constructor Summary
Constructors Constructor Description SourceListModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCategory(SourceListCategory category)Adds the given category to the model and fires an event such thatSourceListModelListeners will be notified.voidaddCategory(SourceListCategory category, int index)Adds the given category to the model at the given index and fires an event such thatSourceListModelListeners will be notified.voidaddItemToCategory(SourceListItem item, SourceListCategory category)Adds the given item to the givenSourceListCategory.voidaddItemToCategory(SourceListItem item, SourceListCategory category, int index)Adds the given item to the givenSourceListCategoryat the given index within that category.voidaddItemToItem(SourceListItem childItem, SourceListItem parentItem)Adds the given "child" item to the given "parent" item.voidaddItemToItem(SourceListItem childItem, SourceListItem parentItem, int index)Adds the given "child" item to the given "parent" item at the given index.voidaddSourceListModelListener(SourceListModelListener listener)Adds the givenSourceListModelListenerto the list of listeners.java.util.List<SourceListCategory>getCategories()Gets theSourceListCategorys associated with this model.voidremoveCategory(SourceListCategory category)Removes the given category from the model and fires an event such thatSourceListModelListeners will be notified.voidremoveCategoryAt(int index)Removes the category at the given index from the model and fires an event such thatSourceListModelListeners will be notified.voidremoveItemFromCategory(SourceListItem item, SourceListCategory category)Removes the given item from the given category.voidremoveItemFromCategoryAtIndex(SourceListCategory category, int index)Removes the item at the given index from the given category.voidremoveItemFromItem(SourceListItem parentItem, int index)Removes the given child item at from the given parent item.voidremoveItemFromItem(SourceListItem childItem, SourceListItem parentItem)Removes the given child item at from the given parent item.voidremoveSourceListModelListener(SourceListModelListener listener)Removes the givenSourceListModelListenerfrom the list of listeners.voidvalidateItemIsInModel(SourceListItem item)Checks if the givenSourceListItemis in this model.
-
-
-
Method Detail
-
getCategories
public java.util.List<SourceListCategory> getCategories()
Gets theSourceListCategorys associated with this model.- Returns:
- the
SourceListCategorys associated with this model.
-
addCategory
public void addCategory(SourceListCategory category)
Adds the given category to the model and fires an event such thatSourceListModelListeners will be notified.- Parameters:
category- theSourceListCategoryto add.
-
addCategory
public void addCategory(SourceListCategory category, int index)
Adds the given category to the model at the given index and fires an event such thatSourceListModelListeners will be notified.- Parameters:
category- theSourceListCategoryto add.index- the index to add the category at.
-
removeCategory
public void removeCategory(SourceListCategory category)
Removes the given category from the model and fires an event such thatSourceListModelListeners will be notified.- Parameters:
category- theSourceListCategoryto remove.- Throws:
java.lang.IllegalArgumentException- if the given category is not part of this model.
-
removeCategoryAt
public void removeCategoryAt(int index)
Removes the category at the given index from the model and fires an event such thatSourceListModelListeners will be notified.- Parameters:
index- the index of theSourceListCategoryto remove.- Throws:
java.lang.IllegalArgumentException- if there is no category at the given index.
-
addItemToCategory
public void addItemToCategory(SourceListItem item, SourceListCategory category)
Adds the given item to the givenSourceListCategory.- Parameters:
item- the item to add.category- the category to add the item to.- Throws:
java.lang.IllegalStateException- if the given category is not in the model.
-
addItemToCategory
public void addItemToCategory(SourceListItem item, SourceListCategory category, int index)
Adds the given item to the givenSourceListCategoryat the given index within that category.- Parameters:
item- the item to add.category- the category to add the item to.index- the index in the category to add the item.- Throws:
java.lang.IllegalStateException- if the given category is not in the model.
-
addItemToItem
public void addItemToItem(SourceListItem childItem, SourceListItem parentItem)
Adds the given "child" item to the given "parent" item.- Parameters:
childItem- the item to add to the given parent item.parentItem- the item to add the child item to.- Throws:
java.lang.IllegalStateException- if the given parent item is not in the model.
-
addItemToItem
public void addItemToItem(SourceListItem childItem, SourceListItem parentItem, int index)
Adds the given "child" item to the given "parent" item at the given index. The parentSourceListItemwill be expanded if it was not a parent but becomes a parent as a result of this call.- Parameters:
childItem- the item to add to the given parent item.parentItem- the item to add the child item to.index- the index of the parent item at which to add the child item.- Throws:
java.lang.IllegalStateException- if the given child or parent item is not in the model.
-
removeItemFromCategory
public void removeItemFromCategory(SourceListItem item, SourceListCategory category)
Removes the given item from the given category.- Parameters:
item- the item to remove from the given category.category- the category form which to remove the given item.- Throws:
java.lang.IllegalStateException- if the given category is not in the model.
-
removeItemFromCategoryAtIndex
public void removeItemFromCategoryAtIndex(SourceListCategory category, int index)
Removes the item at the given index from the given category.- Parameters:
category- the category from which to remove the item.index- the index of the item to remove.- Throws:
java.lang.IllegalStateException- if the given category is not in the model.
-
removeItemFromItem
public void removeItemFromItem(SourceListItem childItem, SourceListItem parentItem)
Removes the given child item at from the given parent item.- Parameters:
childItem- the item to remove.parentItem- the item from which to remove the given child item.- Throws:
java.lang.IllegalStateException- if the given child or parent item is not in the model.
-
removeItemFromItem
public void removeItemFromItem(SourceListItem parentItem, int index)
Removes the given child item at from the given parent item.- Parameters:
parentItem- the item from which to remove the given child item.index- the index of the item to remove.- Throws:
java.lang.IllegalStateException- if the given child or parent item is not in the model.
-
validateItemIsInModel
public void validateItemIsInModel(SourceListItem item)
Checks if the givenSourceListItemis in this model.- Parameters:
item- the item to check if is in this model.- Throws:
java.lang.IllegalArgumentException- if the given item is not part of this model.
-
addSourceListModelListener
public void addSourceListModelListener(SourceListModelListener listener)
Adds the givenSourceListModelListenerto the list of listeners.- Parameters:
listener- the listener to add.
-
removeSourceListModelListener
public void removeSourceListModelListener(SourceListModelListener listener)
Removes the givenSourceListModelListenerfrom the list of listeners.- Parameters:
listener- the listener to remove.
-
-