Package com.explodingpixels.macwidgets
Class SourceListItem
- java.lang.Object
-
- com.explodingpixels.macwidgets.SourceListItem
-
- All Implemented Interfaces:
MacBadgeContentProvider,SourceListBadgeContentProvider,IconProvider,TextProvider
public class SourceListItem extends java.lang.Object implements TextProvider, IconProvider, SourceListBadgeContentProvider
An item in aSourceListwhich is contained within aSourceListCategory.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCOUNTER_VALUEstatic java.lang.StringICONstatic java.lang.StringTEXT
-
Constructor Summary
Constructors Constructor Description SourceListItem(java.lang.String text)Creates aSourceListItemwith the given text.SourceListItem(java.lang.String text, javax.swing.Icon icon)Creates aSourceListItemwith the given text and icon.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)Adds aPropertyChangeListeneron thisSourceListItem.booleancontainsItem(SourceListItem item)Returnstrueif the givenSourceListItemis contained by this item, to include being a sub-element of another childSourceListItem.java.lang.StringgetBadgeValue()Returns the string value of what should be displayed in the badge areajava.util.List<SourceListItem>getChildItems()Gets a list of thisSourceListItem's childSourceListItems.intgetCounterValue()Gets the counter value to use for this item.javax.swing.IcongetIcon()Gets the icon to use for this item.java.lang.StringgetText()Gets the text to use for this item.voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)Removes aPropertyChangeListenerfrom thisSourceListItem.voidsetCounterValue(int counterValue)Sets the counter value to use for this item.voidsetIcon(javax.swing.Icon icon)Sets the icon to use for this item.voidsetText(java.lang.String text)Sets the text to use for this item.java.lang.StringtoString()Returns aStringrepresentation of thisSourceListItem.
-
-
-
Field Detail
-
TEXT
public static final java.lang.String TEXT
- See Also:
- Constant Field Values
-
ICON
public static final java.lang.String ICON
- See Also:
- Constant Field Values
-
COUNTER_VALUE
public static final java.lang.String COUNTER_VALUE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SourceListItem
public SourceListItem(java.lang.String text)
Creates aSourceListItemwith the given text.- Parameters:
text- the item text. Cannot be null.- Throws:
java.lang.IllegalArgumentException- if the text is null.
-
SourceListItem
public SourceListItem(java.lang.String text, javax.swing.Icon icon)Creates aSourceListItemwith the given text and icon.- Parameters:
text- the item text. Cannot be null.icon- the item icon. Can be null.- Throws:
java.lang.IllegalArgumentException- if the text is null.
-
-
Method Detail
-
getText
public java.lang.String getText()
Gets the text to use for this item.- Specified by:
getTextin interfaceTextProvider- Returns:
- the text to use for this item.
-
setText
public void setText(java.lang.String text)
Sets the text to use for this item.- Parameters:
text- the text to use for this item. Cannot be null.- Throws:
java.lang.IllegalArgumentException- if the text is null.
-
getIcon
public javax.swing.Icon getIcon()
Gets the icon to use for this item.- Specified by:
getIconin interfaceIconProvider- Returns:
- the icon to use for this item.
-
setIcon
public void setIcon(javax.swing.Icon icon)
Sets the icon to use for this item.- Parameters:
icon- the icon to use for this item. Can be null.
-
getCounterValue
public int getCounterValue()
Gets the counter value to use for this item. The counter value will be displayed to the right of the item.- Specified by:
getCounterValuein interfaceSourceListBadgeContentProvider- Returns:
- the counter value to use for this item.
-
getBadgeValue
public java.lang.String getBadgeValue()
Returns the string value of what should be displayed in the badge area- Specified by:
getBadgeValuein interfaceMacBadgeContentProvider- Returns:
- text to display
-
setCounterValue
public void setCounterValue(int counterValue)
Sets the counter value to use for this item. The counter value will be displayed to the right of the item.- Parameters:
counterValue- the counter value to use for this item. Must be >= 0.- Throws:
java.lang.IllegalArgumentException- if the counter value is not >= 0.
-
containsItem
public boolean containsItem(SourceListItem item)
Returnstrueif the givenSourceListItemis contained by this item, to include being a sub-element of another childSourceListItem.- Parameters:
item- theSourceListItemto determine whether or not is contained by this item.- Returns:
trueif the givenSourceListItemis contained within this item or within on of this items childSourceListItems.
-
toString
public java.lang.String toString()
Returns aStringrepresentation of thisSourceListItem.- Overrides:
toStringin classjava.lang.Object- Returns:
- a
Stringrepresentation of thisSourceListItem.
-
getChildItems
public java.util.List<SourceListItem> getChildItems()
Gets a list of thisSourceListItem's childSourceListItems.- Returns:
- a list of this
SourceListItem's childSourceListItems.
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds aPropertyChangeListeneron thisSourceListItem.- Parameters:
listener- the listener to add.
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes aPropertyChangeListenerfrom thisSourceListItem.- Parameters:
listener- the listener to remove.
-
-