Package org.apache.pivot.wtk.content
Class TreeBranch
- java.lang.Object
-
- org.apache.pivot.wtk.content.BaseContent
-
- org.apache.pivot.wtk.content.UserContent
-
- org.apache.pivot.wtk.content.TreeNode
-
- org.apache.pivot.wtk.content.TreeBranch
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.pivot.collections.List
List.ItemIterator<T>, List.ListListenerList<T>
-
Nested classes/interfaces inherited from interface org.apache.pivot.collections.Sequence
Sequence.Tree<T>
-
-
Field Summary
-
Fields inherited from class org.apache.pivot.wtk.content.UserContent
userData
-
Fields inherited from class org.apache.pivot.wtk.content.BaseContent
icon, text
-
-
Constructor Summary
Constructors Constructor Description TreeBranch()
TreeBranch(java.lang.String text)
TreeBranch(Image icon)
TreeBranch(Image icon, java.lang.String text)
TreeBranch(Image icon, Image expandedIcon, java.lang.String text)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
add(TreeNode treeNode)
Adds an item to the list.void
clear()
Removes all elements from the collection.TreeNode
get(int index)
Retrieves the item at the given index.java.util.Comparator<TreeNode>
getComparator()
Returns the collection's sort order.Image
getExpandedIcon()
int
getLength()
Returns the length of the list.ListenerList<ListListener<TreeNode>>
getListListeners()
Returns the list listener list.int
indexOf(TreeNode treeNode)
Returns the index of an item in the sequence.void
insert(TreeNode treeNode, int index)
Inserts an item into the list.boolean
isEmpty()
Tests the emptiness of the collection.java.util.Iterator<TreeNode>
iterator()
Sequence<TreeNode>
remove(int index, int count)
Removes one or more items from the sequence.int
remove(TreeNode treeNode)
Removes the first occurrence of the given item from the sequence.void
setComparator(java.util.Comparator<TreeNode> comparator)
Sets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order.void
setExpandedIcon(java.lang.String expandedIconName)
Sets the tree branch's expanded icon by resource name.void
setExpandedIcon(java.net.URL iconURL)
Sets the tree branch's expanded icon by URL.void
setExpandedIcon(Image expandedIcon)
java.lang.String
toString()
TreeNode
update(int index, TreeNode treeNode)
Updates the item at the given index.-
Methods inherited from class org.apache.pivot.wtk.content.UserContent
getUserData, setUserData
-
Methods inherited from class org.apache.pivot.wtk.content.BaseContent
getIcon, getText, setIcon, setIcon, setIcon, setText
-
-
-
-
Method Detail
-
getExpandedIcon
public Image getExpandedIcon()
-
setExpandedIcon
public void setExpandedIcon(Image expandedIcon)
-
setExpandedIcon
public void setExpandedIcon(java.net.URL iconURL)
Sets the tree branch's expanded icon by URL.If the icon already exists in the application context resource cache, the cached value will be used. Otherwise, the icon will be loaded synchronously and added to the cache.
- Parameters:
iconURL
- The location of the expanded icon to set.
-
setExpandedIcon
public void setExpandedIcon(java.lang.String expandedIconName)
Sets the tree branch's expanded icon by resource name.- Parameters:
expandedIconName
- The resource name of the expanded icon to set.- See Also:
setExpandedIcon(URL)
-
add
public int add(TreeNode treeNode)
Description copied from interface:List
Adds an item to the list. If the list is unsorted, the item is appended to the end of the list. Otherwise, it is inserted at the appropriate index.
-
insert
public void insert(TreeNode treeNode, int index)
Description copied from interface:List
Inserts an item into the list.- Specified by:
insert
in interfaceList<TreeNode>
- Specified by:
insert
in interfaceSequence<TreeNode>
- Parameters:
treeNode
- The item to be added to the list.index
- The index at which the item should be inserted. Must be a value between0
andgetLength()
.- See Also:
ListListener.itemInserted(List, int)
-
update
public TreeNode update(int index, TreeNode treeNode)
Description copied from interface:List
Updates the item at the given index.- Specified by:
update
in interfaceList<TreeNode>
- Specified by:
update
in interfaceSequence<TreeNode>
- Parameters:
index
- The index of the item to update.treeNode
- The item that will replace any existing value at the given index.- Returns:
- The item that was previously stored at the given index.
- See Also:
ListListener.itemUpdated(List, int, Object)
-
remove
public int remove(TreeNode treeNode)
Description copied from interface:Sequence
Removes the first occurrence of the given item from the sequence.- Specified by:
remove
in interfaceSequence<TreeNode>
- Parameters:
treeNode
- The item to remove.- Returns:
- The index of the item that was removed, or
-1
if the item could not be found. - See Also:
Sequence.remove(int, int)
-
remove
public Sequence<TreeNode> remove(int index, int count)
Description copied from interface:Sequence
Removes one or more items from the sequence.- Specified by:
remove
in interfaceList<TreeNode>
- Specified by:
remove
in interfaceSequence<TreeNode>
- Parameters:
index
- The starting index to remove.count
- The number of items to remove, beginning withindex
.- Returns:
- A sequence containing the items that were removed.
- See Also:
ListListener.itemsRemoved(List, int, Sequence)
-
clear
public void clear()
Description copied from interface:Collection
Removes all elements from the collection.- Specified by:
clear
in interfaceCollection<TreeNode>
- Specified by:
clear
in interfaceList<TreeNode>
- See Also:
ListListener.itemsRemoved(List, int, Sequence)
-
get
public TreeNode get(int index)
Description copied from interface:Sequence
Retrieves the item at the given index.
-
indexOf
public int indexOf(TreeNode treeNode)
Description copied from interface:Sequence
Returns the index of an item in the sequence.
-
isEmpty
public boolean isEmpty()
Description copied from interface:Collection
Tests the emptiness of the collection.- Specified by:
isEmpty
in interfaceCollection<TreeNode>
- Returns:
true
if the collection contains no elements;false
, otherwise.
-
getLength
public int getLength()
Description copied from interface:List
Returns the length of the list.
-
getComparator
public java.util.Comparator<TreeNode> getComparator()
Description copied from interface:Collection
Returns the collection's sort order.- Specified by:
getComparator
in interfaceCollection<TreeNode>
- Returns:
- The comparator used to order elements in the collection, or
null
if the sort order is undefined. - See Also:
Collection.setComparator(Comparator)
-
setComparator
public void setComparator(java.util.Comparator<TreeNode> comparator)
Description copied from interface:Collection
Sets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order.Calling this method more than once with the same comparator will re-sort the collection.
- Specified by:
setComparator
in interfaceCollection<TreeNode>
- Specified by:
setComparator
in interfaceList<TreeNode>
- Parameters:
comparator
- The comparator used to order elements in the collection, or null if the collection is unsorted.- See Also:
ListListener.comparatorChanged(List, Comparator)
-
iterator
public java.util.Iterator<TreeNode> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<TreeNode>
-
getListListeners
public ListenerList<ListListener<TreeNode>> getListListeners()
Description copied from interface:List
Returns the list listener list.- Specified by:
getListListeners
in interfaceList<TreeNode>
- Returns:
- The list of listeners for this list.
-
-