From f43ef94f586fb2cac0cca8c62cf8d2c84861ee4b Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Tue, 21 Aug 2012 15:03:33 +0000 Subject: [PATCH] Adds contact removed to the ContactQuery listener, that will give the option to remove a contact once it has been shown in the ui after a query. --- .../gui/main/contactlist/FilterQuery.java | 8 +++ .../gui/main/contactlist/TreeContactList.java | 17 ++++++ .../contactsource/ContactQueryListener.java | 7 +++ .../contactsource/ContactRemovedEvent.java | 61 +++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 src/net/java/sip/communicator/service/contactsource/ContactRemovedEvent.java diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/FilterQuery.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/FilterQuery.java index b1892421a..4ac17b9e0 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/FilterQuery.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/FilterQuery.java @@ -330,6 +330,14 @@ public void contactReceived(ContactReceivedEvent event) contactReceived(event.getQuerySource(), event.getContact()); } + /** + * Indicates that a contact has been removed after a search. + * @param event the ContactQueryEvent containing information + * about the received SourceContact + */ + public void contactRemoved(ContactRemovedEvent event) + {} + public void metaContactReceived(MetaContactQueryEvent event) {} public void metaGroupReceived(MetaGroupQueryEvent event) {} diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java index 29c9b719a..b20e7aef5 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java @@ -201,6 +201,14 @@ public void contactReceived(ContactReceivedEvent event) } } + /** + * Indicates that a contact has been removed after a search. + * @param event the ContactQueryEvent containing information + * about the received SourceContact + */ + public void contactRemoved(ContactRemovedEvent event) + {} + /** * Indicates that a MetaContact has been received for a search in * the MetaContactListService. @@ -1536,6 +1544,15 @@ public void contactReceived(ContactReceivedEvent event) imageSearchCanceled = true; } } + + /** + * Indicates that a contact has been removed after a search. + * @param event the ContactQueryEvent containing + * information + * about the received SourceContact + */ + public void contactRemoved(ContactRemovedEvent event) + {} }); // If the image search has been canceled from one of the diff --git a/src/net/java/sip/communicator/service/contactsource/ContactQueryListener.java b/src/net/java/sip/communicator/service/contactsource/ContactQueryListener.java index dc1aa9079..0610331db 100644 --- a/src/net/java/sip/communicator/service/contactsource/ContactQueryListener.java +++ b/src/net/java/sip/communicator/service/contactsource/ContactQueryListener.java @@ -28,4 +28,11 @@ public interface ContactQueryListener * about the status change */ public void queryStatusChanged(ContactQueryStatusEvent event); + + /** + * Indicates that a contact has been removed after a search. + * @param event the ContactQueryEvent containing information + * about the received SourceContact + */ + public void contactRemoved(ContactRemovedEvent event); } diff --git a/src/net/java/sip/communicator/service/contactsource/ContactRemovedEvent.java b/src/net/java/sip/communicator/service/contactsource/ContactRemovedEvent.java new file mode 100644 index 000000000..10c42661b --- /dev/null +++ b/src/net/java/sip/communicator/service/contactsource/ContactRemovedEvent.java @@ -0,0 +1,61 @@ +/* + * Jitsi, 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.contactsource; + +import java.util.*; + +/** + * The ContactRemovedEvent indicates that a + * SourceContact has been removed from the result of a + * ContactQuery. + * @author Yana Stamcheva + */ +public class ContactRemovedEvent + extends EventObject +{ + /** + * Serial version UID. + */ + private static final long serialVersionUID = 0L; + + /** + * The contact that has been removed. + */ + private final SourceContact contact; + + /** + * Creates a ContactRemovedEvent by specifying the contact search + * source and the removed searchContact. + * @param source the source that triggered this event + * @param contact the removed contact + */ + public ContactRemovedEvent(ContactQuery source, + SourceContact contact) + { + super(source); + + this.contact = contact; + } + + /** + * Returns the ContactQuery that triggered this event. + * @return the ContactQuery that triggered this event + */ + public ContactQuery getQuerySource() + { + return (ContactQuery) source; + } + + /** + * Returns the removed contact. + * @return the removed contact + */ + public SourceContact getContact() + { + return contact; + } +}