mirror of https://github.com/sipwise/jitsi.git
more work on implementing ordering contacts and A NEW EVENT scheme for the meta contact list service
parent
b727d2f798
commit
9dd755c12c
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.contactlist.event;
|
||||
|
||||
import net.java.sip.communicator.service.contactlist.*;
|
||||
|
||||
/**
|
||||
* Fired whenever a meta contact has been moved from one parent group to
|
||||
* another. The event contains the old and new parents as well as a reference to
|
||||
* the source contact.
|
||||
*
|
||||
* @author Emil Ivov
|
||||
*/
|
||||
public class MetaContactMovedEvent
|
||||
extends MetaContactPropertyChangeEvent
|
||||
{
|
||||
|
||||
/**
|
||||
* Createas an instance of this <tt>MetaContactMovedEvent</tt> using the
|
||||
* specified arguments.
|
||||
* @param source a reference to the <tt>MetaContact</tt> that this event
|
||||
* is about.
|
||||
* @param oldParent a reference to the <tt>MetaContactGroup</tt> that
|
||||
* contained <tt>sourceContact</tt> before it was moved.
|
||||
* @param newParent a refenrece to the <tt>MetaContactGroup</tt> that
|
||||
* contains <tt>sourceContact</tt> after it was moved.
|
||||
*/
|
||||
public MetaContactMovedEvent(MetaContact sourceContact,
|
||||
MetaContactGroup oldParent,
|
||||
MetaContactGroup newParent)
|
||||
{
|
||||
super(sourceContact, META_CONTACT_MOVED, oldParent, newParent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the old parent of this meta contact.
|
||||
* @return a reference to the <tt>MetaContactGroup</tt> that contained
|
||||
* the source meta contact before it was moved.
|
||||
*/
|
||||
public MetaContactGroup getOldParent()
|
||||
{
|
||||
return (MetaContactGroup)getOldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the new parent of this meta contact.
|
||||
* @return a reference to the <tt>MetaContactGroup</tt> that contains the
|
||||
* source meta contact after it was moved.
|
||||
*/
|
||||
public MetaContactGroup getNewParent()
|
||||
{
|
||||
return (MetaContactGroup)getNewValue();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.contactlist.event;
|
||||
|
||||
import java.beans.*;
|
||||
|
||||
import net.java.sip.communicator.service.contactlist.*;
|
||||
|
||||
/**
|
||||
* An abstract event used for meta contact events indicating moving the meta
|
||||
* contact or changing its name.
|
||||
* <p>
|
||||
* @author Emil Ivov
|
||||
*/
|
||||
public abstract class MetaContactPropertyChangeEvent
|
||||
extends PropertyChangeEvent
|
||||
{
|
||||
/**
|
||||
* Indicates that the source meta contact has moved from one location to
|
||||
* another. The old and new values contain the previous and the new
|
||||
* parent group of this meta contact.
|
||||
*/
|
||||
public static final String META_CONTACT_MOVED = "MetaContactMovedEvent";
|
||||
|
||||
/**
|
||||
* Indicates that the meta contact has been renamed. The old and new value
|
||||
* arguments contain the old and new names of this contact.
|
||||
*/
|
||||
public static final String META_CONTACT_RENAMED = "MetaContactRenamedEvent";
|
||||
|
||||
/**
|
||||
* Indicates that the MetaContactEvent instance was triggered by the
|
||||
* removal of a protocol specific contact from an existing MetaContact.
|
||||
*/
|
||||
public static final String PROTO_CONTACT_REMOVED = "ProtoContactRemoved";
|
||||
|
||||
/**
|
||||
* Indicates that the MetaContactEvent instance was triggered by the
|
||||
* a protocol specific contact to a new MetaContact parent.
|
||||
*/
|
||||
public static final String PROTO_CONTACT_ADDED = "ProtoContactAdded";
|
||||
|
||||
/**
|
||||
* Indicates that the MetaContactEvent instance was triggered by moving
|
||||
* addition of a protocol specific contact to an existing MetaContact.
|
||||
*/
|
||||
public static final String PROTO_CONTACT_MOVED = "ProtoContactMoved";
|
||||
|
||||
/**
|
||||
* Creates an instnace of this event.
|
||||
* @param source the <tt>MetaContact</tt> that this event is about.
|
||||
* @param eventName one of the META_CONTACT_XXXED <tt>String</tt> strings
|
||||
* indicating the exact typ of this event.
|
||||
* @param oldValue the value of the changed property before the change
|
||||
* had occurred.
|
||||
* @param newValue the value of the changed property after the chagne has
|
||||
* occurred.
|
||||
*/
|
||||
public MetaContactPropertyChangeEvent(MetaContact source,
|
||||
String eventName,
|
||||
Object oldValue,
|
||||
Object newValue)
|
||||
{
|
||||
super(source, eventName, oldValue, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the <tt>MetaContact</tt> that this event is about
|
||||
* @return the <tt>MetaContact</tt> that this event is about.
|
||||
*/
|
||||
public MetaContact getSourceMetaContact()
|
||||
{
|
||||
return (MetaContact)getSource();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.contactlist.event;
|
||||
|
||||
import net.java.sip.communicator.service.contactlist.*;
|
||||
|
||||
/**
|
||||
* Indicates that a meta contact has chaned its display name.
|
||||
* @author Emil Ivov
|
||||
*/
|
||||
public class MetaContactRenamedEvent
|
||||
extends MetaContactPropertyChangeEvent
|
||||
{
|
||||
/**
|
||||
* Creates an instance of this event using the specified arguments.
|
||||
* @param source the <tt>MetaContact</tt> that this event is about.
|
||||
* @param oldDisplayName the new display name of this meta contact.
|
||||
* @param newDisplayName the old display name of this meta contact.
|
||||
*/
|
||||
public MetaContactRenamedEvent(MetaContact source,
|
||||
String oldDisplayName,
|
||||
String newDisplayName)
|
||||
{
|
||||
super(source, META_CONTACT_RENAMED, oldDisplayName, newDisplayName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of the source meta contact as it is now, after
|
||||
* the change.
|
||||
* @return the new display name of the meta contact.
|
||||
*/
|
||||
public String getNewDisplayName()
|
||||
{
|
||||
return (String)getOldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of the source meta contact as it was now, before
|
||||
* the change.
|
||||
* @return the meta contact name as it was before the change.
|
||||
*/
|
||||
public String getOldDisplayName()
|
||||
{
|
||||
return (String)getNewValue();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.contactlist.event;
|
||||
|
||||
import net.java.sip.communicator.service.contactlist.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import java.beans.*;
|
||||
|
||||
/**
|
||||
* Event delivered upon addition, removal or change of a protocol specific
|
||||
* contact inside an existing meta contact.
|
||||
*
|
||||
* @author Emil Ivov
|
||||
*/
|
||||
public class ProtoContactEvent
|
||||
extends PropertyChangeEvent
|
||||
{
|
||||
/**
|
||||
* Indicates that the MetaContactEvent instance was triggered by the
|
||||
* removal of a protocol specific contact from an existing MetaContact.
|
||||
*/
|
||||
public static final String PROTO_CONTACT_REMOVED = "ProtoContactRemoved";
|
||||
|
||||
/**
|
||||
* Indicates that the MetaContactEvent instance was triggered by the
|
||||
* a protocol specific contact to a new MetaContact parent.
|
||||
*/
|
||||
public static final String PROTO_CONTACT_ADDED = "ProtoContactAdded";
|
||||
|
||||
/**
|
||||
* Indicates that the MetaContactEvent instance was triggered by moving
|
||||
* addition of a protocol specific contact to an existing MetaContact.
|
||||
*/
|
||||
public static final String PROTO_CONTACT_MOVED = "ProtoContactMoved";
|
||||
|
||||
/**
|
||||
* Creates an instance of this <tt>ProtoContactEvent</tt>.
|
||||
* @param source the proto <tt>Contact</tt> that this event is about.
|
||||
* @param eventName the name of the event, one of the PROTO_CONTACT_XXX
|
||||
* fields.
|
||||
* @param oldParent the <tt>MetaContact</tt> that was parent of the source
|
||||
* contact before the event occurred or null for a new contact or when
|
||||
* irrelevant.
|
||||
* @param newParent the <tt>MetaContact</tt> that is parent of the source
|
||||
* contact after the event occurred or null for a removed contact or when
|
||||
* irrelevant.
|
||||
*/
|
||||
public ProtoContactEvent(Contact source, String eventName,
|
||||
MetaContact oldParent, MetaContact newParent)
|
||||
{
|
||||
super(source, eventName, oldParent, newParent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the protoContact that this event is about.
|
||||
* @return he <tt>Contact</tt> that this event is about.
|
||||
*/
|
||||
public Contact getProtoContact()
|
||||
{
|
||||
return (Contact)getSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>MetaContact</tt> that was parent of the source contact
|
||||
* before the event occurred or null for a new contact or when irrelevant.
|
||||
*
|
||||
* @return the <tt>MetaContact</tt> that was parent of the source contact
|
||||
* before the event occurred or null for a new contact or when irrelevant.
|
||||
*/
|
||||
public MetaContact getOldParent()
|
||||
{
|
||||
return (MetaContact)getOldValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>MetaContact</tt> that is parent of the source contact
|
||||
* after the event occurred or null for a removed contact or when irrelevant.
|
||||
*
|
||||
* @return the <tt>MetaContact</tt> that is parent of the source contact
|
||||
* after the event occurred or null for a removed contact or when irrelevant.
|
||||
*/
|
||||
public MetaContact getNewParent()
|
||||
{
|
||||
return (MetaContact)getNewValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>MetaContact</tt> that is the most relevant parent of
|
||||
* the source proto <tt>Contact</tt>. In the case of a moved or newly
|
||||
* added <tt>Contact</tt> the method would return same as getNewParent()
|
||||
* and would return the contact's old parent in the case of a
|
||||
* <tt>PROTO_CONTACT_REMOVED</tt> event.
|
||||
* @return the <tt>MetaContact</tt> that is most apt to be called parent
|
||||
* to the source <tt>Contact</tt>.
|
||||
*/
|
||||
public MetaContact getParent()
|
||||
{
|
||||
return getNewParent() != null
|
||||
? getNewParent()
|
||||
: getOldParent();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue