MetaContactList events

cusax-fix
Yana Stamcheva 20 years ago
parent b71990105e
commit cda4393933

@ -0,0 +1,112 @@
/*
* 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.util.EventObject;
import net.java.sip.communicator.service.contactlist.MetaContact;
import net.java.sip.communicator.service.contactlist.MetaContactGroup;
import net.java.sip.communicator.service.protocol.ProtocolProviderService;
/**
*
* @author Emil Ivov
*/
public class MetaContactEvent
extends EventObject
{
private int eventID = -1;
/**
* Indicates that the MetaContactEvent instance was triggered by
* adding a MetaContact.
*/
public static final int METACONTACT_ADDED = 1;
/**
* Indicates that the MetaContactEvent instance was triggered by the
* removal of an existing MetaContact.
*/
public static final int METACONTACT_REMOVED = 2;
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.
*/
public MetaContact getSourceContact()
{
return (MetaContact)getSource();
}
/**
* Returns the MetaContactGroup that the MetaContact belongs to.
* @return the MetaContactGroup that the MetaContact belongs to.
*/
public MetaContactGroup getParentGroup()
{
return parentGroup;
}
/**
* Returns a String representation of this MetaContactEvent
*
* @return A String representation of this
* MetaContactListEvent.
*/
public String toString()
{
StringBuffer buff
= new StringBuffer("MetaContactEvent-[ ContactID=");
buff.append(getSourceContact().getDisplayName());
buff.append(", eventID=").append(getEventID());
if(getParentGroup() != null)
buff.append(", ParentGroup=").append(getParentGroup().getGroupName());
return buff.toString();
}
/**
* Returns an event id specifying whether the type of this event (e.g.
* METACONTACT_ADDED, METACONTACT_REMOVED and etc.)
* @return one of the METACONTACT_XXX int fields of this class.
*/
public int getEventID(){
return eventID;
}
}

@ -0,0 +1,96 @@
/*
* 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.util.EventObject;
import net.java.sip.communicator.service.contactlist.MetaContactGroup;
import net.java.sip.communicator.service.protocol.ProtocolProviderService;
/**
*
* @author Emil Ivov
*/
public class MetaContactGroupEvent
extends EventObject
{
private int eventID = -1;
/**
* Indicates that the MetaContactGroupEvent instance was triggered by
* adding a MetaContactGroup.
*/
public static final int METACONTACT_GROUP_ADDED = 1;
/**
* Indicates that the MetaContactGroupEvent instance was triggered by the
* removal of an existing MetaContactGroup.
*/
public static final int METACONTACT_GROUP_REMOVED = 2;
private ProtocolProviderService sourceProvider = null;
/**
* Creates a new MetaContactGroup event according to the specified parameters.
* @param source the MetaContactGroup instance that is added to the MetaContactList
* @param provider the ProtocolProviderService instance where this event
* occurred
* @param eventID one of the METACONTACT_XXX static fields indicating the
* nature of the event.
*/
public MetaContactGroupEvent( MetaContactGroup source,
ProtocolProviderService provider,
int eventID)
{
super(source);
this.sourceProvider = provider;
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 MetaContactGroup.
* @return the source MetaContactGroup.
*/
public MetaContactGroup getSourceContactGroup()
{
return (MetaContactGroup)getSource();
}
/**
* Returns a String representation of this MetaContactGroupEvent
*
* @return A String representation of this
* MetaContactGroupEvent.
*/
public String toString()
{
StringBuffer buff
= new StringBuffer("MetaContactGroupEvent-[ GroupName=");
buff.append(getSourceContactGroup().getGroupName());
buff.append(", eventID=").append(getEventID());
return buff.toString();
}
/**
* Returns an event id specifying whether the type of this event (e.g.
* METACONTACT_GROUP_ADDED, METACONTACT_GROUP_REMOVED and etc.)
* @return one of the METACONTACT_GROUP_XXX int fields of this class.
*/
public int getEventID(){
return eventID;
}
}

@ -1,22 +0,0 @@
/*
* 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.util.*;
/**
*
* @author Emil Ivov
*/
public class MetaContactListEvent
extends EventObject
{
public MetaContactListEvent(Object source)
{
super(source);
}
}

@ -6,7 +6,7 @@
*/
package net.java.sip.communicator.service.contactlist.event;
import java.util.*;
import java.util.EventListener;
/**
*
@ -15,4 +15,31 @@
public interface MetaContactListListener
extends EventListener
{
/**
* Indicates that a MetaContact has been successfully added
* to the MetaContact list.
* @param evt the MetaContactListEvent containing the corresponding contact
*/
public void metaContactAdded(MetaContactEvent evt);
/**
* Indicates that a MetaContact has been removed from the MetaContact list.
* @param evt the MetaContactListEvent containing the corresponding contact
*/
public void metaContactRemoved(MetaContactEvent evt);
/**
* Indicates that a MetaContactGroup has been successfully added
* to the MetaContact list.
* @param evt the MetaContactListEvent containing the corresponding contact
*/
public void metaContactGroupAdded(MetaContactGroupEvent evt);
/**
* Indicates that a MetaContactGroup has been removed from the MetaContact list.
* @param evt the MetaContactListEvent containing the corresponding contact
*/
public void metaContactGroupRemoved(MetaContactGroupEvent evt);
}

Loading…
Cancel
Save