Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.gui.main.contactlist
Class ContactListModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by net.java.sip.communicator.impl.gui.main.contactlist.ContactListModel
All Implemented Interfaces:
Serializable, ListModel

public class ContactListModel
extends AbstractListModel

Implements ListModel for MetaContactListService in order to display it in ContactList as a list instead of a tree.

Author:
Yana Stamcheva, Lubomir Marinov
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
ContactListModel(MetaContactListService contactList)
          Initializes a new ContactListModel instance which is to implement ListModel for a specific MetaContactListService in order to display it in ContactList as a list instead of a tree.
 
Method Summary
 void closeGroup(MetaContactGroup group)
          Closes the given group by hiding all containing contacts.
 void contentAdded(int startIndex, int endIndex)
          Informs interested listeners that new cells are added from startIndex to endIndex.
 void contentChanged(int startIndex, int endIndex)
          Informs interested listeners that the content has changed of the cells given by the range from startIndex to endIndex.
 void contentRemoved(int startIndex, int endIndex)
          Informs interested listeners that a range of cells is removed.
 int countChildContacts(MetaContactGroup group)
          Counts group child contacts depending on the showOffline option.
 int countContactsAndSubgroups(MetaContactGroup parentGroup)
          Returns the number of all children of the given MetaContactGroup.
 Object getElementAt(int index)
          Returns the object at the given index.
 int getSize()
          Returns the size of this list model.
 int indexOf(Object o)
          If the given object is instance of MetaContact or MetaContactGroup returns the index of this meta contact or group, otherwiser returns -1.
 boolean isContactOnline(MetaContact contact)
          Returns TRUE if the given meta contact is online, FALSE otherwise.
 boolean isGroupClosed(MetaContactGroup group)
          Checks whether the group is closed.
 boolean isGroupEmpty(MetaContactGroup group)
          Checks whether the group is closed.
 boolean isShowOffline()
          Returns true if offline contacts should be shown, false otherwise.
 void openGroup(MetaContactGroup group)
          Opens the given group by showing all containing contacts.
 void setShowOffline(boolean showOffline)
          Sets the showOffline variable to indicate whether or not offline contacts should be shown.
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContactListModel

public ContactListModel(MetaContactListService contactList)
Initializes a new ContactListModel instance which is to implement ListModel for a specific MetaContactListService in order to display it in ContactList as a list instead of a tree.

Parameters:
contactList - the MetaContactListService which contains the contact list to be represented as a list by the new instance
Method Detail

contentChanged

public void contentChanged(int startIndex,
                           int endIndex)
Informs interested listeners that the content has changed of the cells given by the range from startIndex to endIndex.

Parameters:
startIndex - The start index of the range .
endIndex - The end index of the range.

contentAdded

public void contentAdded(int startIndex,
                         int endIndex)
Informs interested listeners that new cells are added from startIndex to endIndex.

Parameters:
startIndex - The start index of the range .
endIndex - The end index of the range.

contentRemoved

public void contentRemoved(int startIndex,
                           int endIndex)
Informs interested listeners that a range of cells is removed.

Parameters:
startIndex - The start index of the range.
endIndex - The end index of the range.

getSize

public int getSize()
Returns the size of this list model.

Returns:
The size of this list model.

getElementAt

public Object getElementAt(int index)
Returns the object at the given index.

Parameters:
index - The index.
Returns:
The object at the given index.

indexOf

public int indexOf(Object o)
If the given object is instance of MetaContact or MetaContactGroup returns the index of this meta contact or group, otherwiser returns -1.

Parameters:
o - the object, which index we search
Returns:
the index of the given object if it founds it, otherwise -1

countContactsAndSubgroups

public int countContactsAndSubgroups(MetaContactGroup parentGroup)
Returns the number of all children of the given MetaContactGroup. Counts in depth all subgroups and child contacts.

Parameters:
parentGroup - The parent MetaContactGroup.
Returns:
The number of all children of the given MetaContactGroup

closeGroup

public void closeGroup(MetaContactGroup group)
Closes the given group by hiding all containing contacts.

Parameters:
group - The group to close.

openGroup

public void openGroup(MetaContactGroup group)
Opens the given group by showing all containing contacts.

Parameters:
group - The group to open.

isGroupClosed

public boolean isGroupClosed(MetaContactGroup group)
Checks whether the group is closed.

Parameters:
group - The group to check.
Returns:
True if the group is closed, false - otherwise.

isGroupEmpty

public boolean isGroupEmpty(MetaContactGroup group)
Checks whether the group is closed.

Parameters:
group - The group to check.
Returns:
True if the group is closed, false - otherwise.

isShowOffline

public boolean isShowOffline()
Returns true if offline contacts should be shown, false otherwise.

Returns:
boolean true if offline contacts should be shown, false otherwise.

setShowOffline

public void setShowOffline(boolean showOffline)
Sets the showOffline variable to indicate whether or not offline contacts should be shown.

Parameters:
showOffline - true if offline contacts should be shown, false otherwise.

isContactOnline

public boolean isContactOnline(MetaContact contact)
Returns TRUE if the given meta contact is online, FALSE otherwise.

Parameters:
contact - the meta contact
Returns:
TRUE if the given meta contact is online, FALSE otherwise

countChildContacts

public int countChildContacts(MetaContactGroup group)
Counts group child contacts depending on the showOffline option.

Parameters:
group - the parent group to count for
Returns:
child contacts count for the given group

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.