Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.gui.main.contactlist.contactsource
Class MetaContactListSource

java.lang.Object
  extended by net.java.sip.communicator.impl.gui.main.contactlist.contactsource.MetaContactListSource
All Implemented Interfaces:
EventListener, MetaContactListListener, ContactPresenceStatusListener

public class MetaContactListSource
extends Object
implements ContactPresenceStatusListener, MetaContactListListener

The MetaContactListSource is an abstraction of the MetaContactListService, which makes the correspondence between a MetaContact and an UIContact and between a MetaContactGroup and an UIGroup. It is also responsible for filtering of the MetaContactListService through a given pattern.

Author:
Yana Stamcheva

Field Summary
static String UI_CONTACT_DATA_KEY
          The data key of the MetaContactDescriptor object used to store a reference to this object in its corresponding MetaContact.
static String UI_GROUP_DATA_KEY
          The data key of the MetaGroupDescriptor object used to store a reference to this object in its corresponding MetaContactGroup.
 
Constructor Summary
MetaContactListSource()
           
 
Method Summary
 void childContactsReordered(MetaContactGroupEvent evt)
          Reorders contact list nodes, when MetaContact-s in a MetaContactGroup has been reordered.
 void contactPresenceStatusChanged(ContactPresenceStatusChangeEvent evt)
          Called whenever a change occurs in the PresenceStatus of one of the contacts that we have subscribed for.
static UIContact createUIContact(MetaContact metaContact)
          Creates a UIContact for the given metaContact.
static UIGroup createUIGroup(MetaContactGroup metaGroup)
          Creates a UIGroupDescriptor for the given metaGroup.
static UIContact getUIContact(MetaContact metaContact)
          Returns the UIContact corresponding to the given MetaContact.
static UIGroup getUIGroup(MetaContactGroup metaGroup)
          Returns the UIGroup corresponding to the given MetaContactGroup.
 boolean isMatching(Pattern filterPattern, MetaContactGroup metaGroup)
          Checks if the given metaGroup is matching the current filter.
static boolean isNewGroup(MetaContactGroup metaGroup)
          Returns whether MetaContactGroup is newly created.
static boolean isRootGroup(MetaContactGroup group)
          Indicates if the given MetaContactGroup is the root group.
 void metaContactAdded(MetaContactEvent evt)
          Adds a node in the contact list, when a MetaContact has been added in the MetaContactListService.
 void metaContactAvatarUpdated(MetaContactAvatarUpdateEvent evt)
          Notifies the tree model, when the MetaContact avatar has been modified in the MetaContactListService.
 void metaContactGroupAdded(MetaContactGroupEvent evt)
          Adds a group node in the contact list, when a MetaContactGroup has been added in the MetaContactListService.
 void metaContactGroupModified(MetaContactGroupEvent evt)
          Notifies the tree model, when a MetaContactGroup has been modified in the MetaContactListService.
 void metaContactGroupRemoved(MetaContactGroupEvent evt)
          Removes the corresponding group node in the contact list, when a MetaContactGroup has been removed from the MetaContactListService.
 void metaContactModified(MetaContactModifiedEvent evt)
          Notifies the tree model, when a MetaContact has been modified in the MetaContactListService.
 void metaContactMoved(MetaContactMovedEvent evt)
          Performs needed operations, when a MetaContact has been moved in the MetaContactListService from one group to another.
 void metaContactRemoved(MetaContactEvent evt)
          Removes the corresponding contact node in the contact list, when a MetaContact has been removed from the MetaContactListService.
 void metaContactRenamed(MetaContactRenamedEvent evt)
          Refreshes the corresponding node, when a MetaContact has been renamed in the MetaContactListService.
 void protoContactAdded(ProtoContactEvent evt)
          Adds a contact node corresponding to the parent MetaContact if this last is matching the current filter and wasn't previously contained in the contact list.
 void protoContactModified(ProtoContactEvent evt)
          Notifies the UI representation of the parent MetaContact that this contact has been modified.
 void protoContactMoved(ProtoContactEvent evt)
          Adds the new MetaContact parent and removes the old one if the first is matching the current filter and the last is no longer matching it.
 void protoContactRemoved(ProtoContactEvent evt)
          Removes the contact node corresponding to the parent MetaContact if the last is no longer matching the current filter and wasn't previously contained in the contact list.
 MetaContactQuery queryMetaContactSource(Pattern filterPattern)
          Filters the MetaContactListService to match the given filterPattern and stores the result in the given treeModel.
 void queryMetaContactSource(Pattern filterPattern, MetaContactGroup parentGroup, MetaContactQuery query, int resultCount)
          Filters the children in the given MetaContactGroup to match the given filterPattern and stores the result in the given treeModel.
static void removeUIContact(MetaContact metaContact)
          Removes the UIContact from the given metaContact.
static void removeUIGroup(MetaContactGroup metaGroup)
          Removes the descriptor from the given metaGroup.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UI_CONTACT_DATA_KEY

public static final String UI_CONTACT_DATA_KEY
The data key of the MetaContactDescriptor object used to store a reference to this object in its corresponding MetaContact.


UI_GROUP_DATA_KEY

public static final String UI_GROUP_DATA_KEY
The data key of the MetaGroupDescriptor object used to store a reference to this object in its corresponding MetaContactGroup.

Constructor Detail

MetaContactListSource

public MetaContactListSource()
Method Detail

getUIContact

public static UIContact getUIContact(MetaContact metaContact)
Returns the UIContact corresponding to the given MetaContact.

Parameters:
metaContact - the MetaContact, which corresponding UI contact we're looking for
Returns:
the UIContact corresponding to the given MetaContact

getUIGroup

public static UIGroup getUIGroup(MetaContactGroup metaGroup)
Returns the UIGroup corresponding to the given MetaContactGroup.

Parameters:
metaGroup - the MetaContactGroup, which UI group we're looking for
Returns:
the UIGroup corresponding to the given MetaContactGroup

isNewGroup

public static boolean isNewGroup(MetaContactGroup metaGroup)
Returns whether MetaContactGroup is newly created.

Parameters:
metaGroup - the MetaContactGroup, which we will check.
Returns:
whether the MetaContactGroup is newly created.

createUIContact

public static UIContact createUIContact(MetaContact metaContact)
Creates a UIContact for the given metaContact.

Parameters:
metaContact - the MetaContact for which we would like to create an UIContact
Returns:
an UIContact for the given metaContact

removeUIContact

public static void removeUIContact(MetaContact metaContact)
Removes the UIContact from the given metaContact.

Parameters:
metaContact - the MetaContact, which corresponding UI contact we would like to remove

createUIGroup

public static UIGroup createUIGroup(MetaContactGroup metaGroup)
Creates a UIGroupDescriptor for the given metaGroup.

Parameters:
metaGroup - the MetaContactGroup for which we would like to create an UIContact
Returns:
a UIGroup for the given metaGroup

removeUIGroup

public static void removeUIGroup(MetaContactGroup metaGroup)
Removes the descriptor from the given metaGroup.

Parameters:
metaGroup - the MetaContactGroup, which descriptor we would like to remove

isRootGroup

public static boolean isRootGroup(MetaContactGroup group)
Indicates if the given MetaContactGroup is the root group.

Parameters:
group - the MetaContactGroup to check
Returns:
true if the given group is the root group, false - otherwise

queryMetaContactSource

public MetaContactQuery queryMetaContactSource(Pattern filterPattern)
Filters the MetaContactListService to match the given filterPattern and stores the result in the given treeModel.

Parameters:
filterPattern - the pattern to filter through
Returns:
the created MetaContactQuery corresponding to the query this method does

queryMetaContactSource

public void queryMetaContactSource(Pattern filterPattern,
                                   MetaContactGroup parentGroup,
                                   MetaContactQuery query,
                                   int resultCount)
Filters the children in the given MetaContactGroup to match the given filterPattern and stores the result in the given treeModel.

Parameters:
filterPattern - the pattern to filter through
parentGroup - the MetaContactGroup to filter
query - the object that tracks the query
resultCount - the initial result count we would insert directly to the contact list without firing events

isMatching

public boolean isMatching(Pattern filterPattern,
                          MetaContactGroup metaGroup)
Checks if the given metaGroup is matching the current filter. A group is matching the current filter only if it contains at least one child MetaContact, which is matching the current filter.

Parameters:
filterPattern - the filter pattern to check for matches
metaGroup - the MetaContactGroup to check
Returns:
true to indicate that the given metaGroup is matching the current filter, otherwise returns false

contactPresenceStatusChanged

public void contactPresenceStatusChanged(ContactPresenceStatusChangeEvent evt)
Description copied from interface: ContactPresenceStatusListener
Called whenever a change occurs in the PresenceStatus of one of the contacts that we have subscribed for.

Specified by:
contactPresenceStatusChanged in interface ContactPresenceStatusListener
Parameters:
evt - the ContactPresenceStatusChangeEvent describing the status change.

childContactsReordered

public void childContactsReordered(MetaContactGroupEvent evt)
Reorders contact list nodes, when MetaContact-s in a MetaContactGroup has been reordered.

Specified by:
childContactsReordered in interface MetaContactListListener
Parameters:
evt - the MetaContactGroupEvent that notified us

metaContactAdded

public void metaContactAdded(MetaContactEvent evt)
Adds a node in the contact list, when a MetaContact has been added in the MetaContactListService.

Specified by:
metaContactAdded in interface MetaContactListListener
Parameters:
evt - the MetaContactEvent that notified us

metaContactGroupAdded

public void metaContactGroupAdded(MetaContactGroupEvent evt)
Adds a group node in the contact list, when a MetaContactGroup has been added in the MetaContactListService.

Specified by:
metaContactGroupAdded in interface MetaContactListListener
Parameters:
evt - the MetaContactGroupEvent that notified us

metaContactGroupModified

public void metaContactGroupModified(MetaContactGroupEvent evt)
Notifies the tree model, when a MetaContactGroup has been modified in the MetaContactListService.

Specified by:
metaContactGroupModified in interface MetaContactListListener
Parameters:
evt - the MetaContactGroupEvent that notified us

metaContactGroupRemoved

public void metaContactGroupRemoved(MetaContactGroupEvent evt)
Removes the corresponding group node in the contact list, when a MetaContactGroup has been removed from the MetaContactListService.

Specified by:
metaContactGroupRemoved in interface MetaContactListListener
Parameters:
evt - the MetaContactGroupEvent that notified us

metaContactModified

public void metaContactModified(MetaContactModifiedEvent evt)
Notifies the tree model, when a MetaContact has been modified in the MetaContactListService.

Specified by:
metaContactModified in interface MetaContactListListener
Parameters:
evt - the MetaContactEvent that notified us

metaContactMoved

public void metaContactMoved(MetaContactMovedEvent evt)
Performs needed operations, when a MetaContact has been moved in the MetaContactListService from one group to another.

Specified by:
metaContactMoved in interface MetaContactListListener
Parameters:
evt - the MetaContactMovedEvent that notified us

metaContactRemoved

public void metaContactRemoved(MetaContactEvent evt)
Removes the corresponding contact node in the contact list, when a MetaContact has been removed from the MetaContactListService.

Specified by:
metaContactRemoved in interface MetaContactListListener
Parameters:
evt - the MetaContactEvent that notified us

metaContactRenamed

public void metaContactRenamed(MetaContactRenamedEvent evt)
Refreshes the corresponding node, when a MetaContact has been renamed in the MetaContactListService.

Specified by:
metaContactRenamed in interface MetaContactListListener
Parameters:
evt - the MetaContactRenamedEvent that notified us

metaContactAvatarUpdated

public void metaContactAvatarUpdated(MetaContactAvatarUpdateEvent evt)
Notifies the tree model, when the MetaContact avatar has been modified in the MetaContactListService.

Specified by:
metaContactAvatarUpdated in interface MetaContactListListener
Parameters:
evt - the MetaContactEvent that notified us

protoContactAdded

public void protoContactAdded(ProtoContactEvent evt)
Adds a contact node corresponding to the parent MetaContact if this last is matching the current filter and wasn't previously contained in the contact list.

Specified by:
protoContactAdded in interface MetaContactListListener
Parameters:
evt - the ProtoContactEvent that notified us

protoContactModified

public void protoContactModified(ProtoContactEvent evt)
Notifies the UI representation of the parent MetaContact that this contact has been modified.

Specified by:
protoContactModified in interface MetaContactListListener
Parameters:
evt - the ProtoContactEvent that notified us

protoContactMoved

public void protoContactMoved(ProtoContactEvent evt)
Adds the new MetaContact parent and removes the old one if the first is matching the current filter and the last is no longer matching it.

Specified by:
protoContactMoved in interface MetaContactListListener
Parameters:
evt - the ProtoContactEvent that notified us

protoContactRemoved

public void protoContactRemoved(ProtoContactEvent evt)
Removes the contact node corresponding to the parent MetaContact if the last is no longer matching the current filter and wasn't previously contained in the contact list.

Specified by:
protoContactRemoved in interface MetaContactListListener
Parameters:
evt - the ProtoContactEvent that notified us

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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