more work on implementing ordering contacts and A NEW EVENT scheme for the meta contact list service

cusax-fix
Emil Ivov 20 years ago
parent b727d2f798
commit 9dd755c12c

@ -19,7 +19,7 @@
* <p>
* @author Emil Ivov
*/
public interface MetaContact
public interface MetaContact extends Comparable
{
/**
* Returns the default protocol specific <tt>Contact</tt> to use when

@ -237,6 +237,20 @@ public void moveMetaContact(MetaContact metaContact,
MetaContactGroup newGroup)
throws MetaContactListException;
/**
* Sets the display name for <tt>metaContact</tt> to be <tt>newName</tt>.
* The method will not in any way change any of the contacts wrapped by
* this meta contact.
* <p>
* @param metaContact the <tt>MetaContact</tt> that we are renaming
* @param newName a <tt>String</tt> containing the new display name for
* <tt>metaContact</tt>.
* @throws IllegalArgumentException if <tt>metaContact</tt> is not an
* instance that belongs to the underlying implementation.
*/
public void renameMetaContact(MetaContact metaContact, String newName)
throws IllegalArgumentException;
/**
* Removes the specified <tt>metaContact</tt> as well as all of its
* underlying contacts.
@ -262,7 +276,7 @@ public void removeMetaContact(MetaContact metaContact)
* @throws MetaContactListException with an appropriate code if the
* operation fails for some reason.
*/
public void createMetaContactGroup(MetaContactGroup parent,
public void createMetaContactGroup(MetaContactGroup parentGroup,
String groupName)
throws MetaContactListException;
@ -272,15 +286,17 @@ public void createMetaContactGroup(MetaContactGroup parent,
* The operation would only affect the local meta group and would not
* "touch" any encapsulated protocol specific group.
* <p>
* @param group the <tt>MetaContactGroup</tt> to rename.
* @param newGroupName the new name of the <tt>MetaContactGroup</tt> to
* rename.
*
* @throws MetaContactListException with an appropriate code if the
* operation fails for some reason.
*/
public void renameMetaContactGroup(MetaContactGroup group,
String newGroupName)
throws MetaContactListException;
/**
* Removes the specified meta contact group, all its corresponding protocol
* specific groups and all their children. If some of the children belong to

@ -10,11 +10,12 @@
import net.java.sip.communicator.service.contactlist.MetaContact;
import net.java.sip.communicator.service.contactlist.MetaContactGroup;
import net.java.sip.communicator.service.protocol.ProtocolProviderService;
/**
*
* Parent class for meta contact events indicating addition and removal of
* meta contacts in a meta contact list.
* @author Yana Stamcheva
* @author Emil Ivov
*/
public class MetaContactEvent
extends EventObject
@ -39,57 +40,25 @@ public class MetaContactEvent
*/
public static final int META_CONTACT_MOVED = 3;
/**
* Indicates that the MetaContactEvent instance was triggered by the
* removal of a protocol specific contact from an existing MetaContact.
*/
public static final int PROTO_CONTACT_REMOVED = 4;
/**
* Indicates that the MetaContactEvent instance was triggered by the
* a protocol specific contact to a new MetaContact parent.
*/
public static final int PROTO_CONTACT_ADDED = 5;
/**
* Indicates that the MetaContactEvent instance was triggered by moving
* addition of a protocol specific contact to an existing MetaContact.
*/
public static final int PROTO_CONTACT_MOVED = 6;
private ProtocolProviderService sourceProvider = null;
private MetaContactGroup parentGroup = null;
/**
* Creates a new MetaContact event according to the specified parameters.
* @param source the MetaContact instance that is added to the MetaContactList
* @param provider the ProtocolProviderService instance where this event
* occurred
* @param parentGroup the MetaContactGroup underwhich the corresponding
* MetaContact is located
* @param eventID one of the METACONTACT_XXX static fields indicating the
* nature of the event.
*/
public MetaContactEvent( MetaContact source,
ProtocolProviderService provider,
MetaContactGroup parentGroup,
int eventID)
{
super(source);
this.sourceProvider = provider;
this.parentGroup = parentGroup;
this.eventID = eventID;
}
/**
* Returns the provider that the source contact belongs to.
* @return the provider that the source contact belongs to.
*/
public ProtocolProviderService getSourceProvider()
{
return sourceProvider;
}
/**
* Returns the source MetaContact.
* @return the source MetaContact.

@ -39,6 +39,13 @@ public class MetaContactGroupEvent
*/
public static final int CONTACT_GROUP_REMOVED_FROM_META_GROUP = 3;
/**
* Indicates that the MetaContactGroupEvent instance was triggered by the
* fact that child contacts were reordered in the source group.
*/
public static final int CHILD_CONTACTS_REORDERED = 4;
/**
* Indicates that the MetaContactGroupEvent instance was triggered by the
* renaming of a protocol specific ContactGroup in the source

@ -19,7 +19,6 @@
public interface MetaContactListListener
extends EventListener
{
/**
* Indicates that a MetaContact has been successfully added
* to the MetaContact list.
@ -31,8 +30,32 @@ public interface MetaContactListListener
* Indicates that a MetaContact has been modified.
* @param evt the MetaContactListEvent containing the corresponding contact
*/
public void metaContactModified(MetaContactEvent evt);
public void metaContactRenamed(MetaContactRenamedEvent evt);
/**
* Indicates that a protocol specific <tt>Contact</tt> instance has been
* added to the list of protocol specific buddies in this
* <tt>MetaContact</tt>
* @param evt a reference to the corresponding
* <tt>ProtoContactEvent</tt>
*/
public void protoContactAdded(ProtoContactEvent evt);
/**
* Indicates that a protocol specific <tt>Contact</tt> instance has been
* removed from the list of protocol specific buddies in this
* <tt>MetaContact</tt>
* @param evt a reference to the corresponding
* <tt>ProtoContactEvent</tt>
*/
public void protoContactRemoved(ProtoContactEvent evt);
/**
* Indicates that a protocol specific <tt>Contact</tt> instance has been
* moved from within one <tt>MetaContact</tt> to another.
* @param evt a reference to the <tt>ProtoContactMovedEvent</tt> instance.
*/
public void protoContactMoved(ProtoContactEvent evt);
/**
* Indicates that a MetaContact has been removed from the MetaContact list.
@ -44,8 +67,9 @@ public interface MetaContactListListener
* Indicates that a MetaContact has been moved inside the MetaContact list.
* @param evt the MetaContactListEvent containing the corresponding contact
*/
public void metaContactMoved(MetaContactEvent evt);
public void metaContactMoved(MetaContactMovedEvent evt);
//-------------------- events on groups. ----------------------------------
/**
* Indicates that a MetaContactGroup has been successfully added
@ -64,9 +88,18 @@ public interface MetaContactListListener
/**
* Indicates that a MetaContactGroup has been removed from the MetaContact list.
* Indicates that a MetaContactGroup has been removed from the MetaContact
* list.
* @param evt the MetaContactListEvent containing the corresponding contact
*/
public void metaContactGroupRemoved(MetaContactGroupEvent evt);
/**
* Indicates that the order under which the child contacts were ordered
* inside the source group has changed.
* @param evt the <tt>MetaContactGroupEvent</tt> containind details of this
* event.
*/
public void childContactsReordered(MetaContactGroupEvent evt);
}

@ -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…
Cancel
Save