aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2012-08-22 13:56:09 +0000
committerDamian Minkov <damencho@jitsi.org>2012-08-22 13:56:09 +0000
commitb9ec3d74bb83c882d916ab7d0c90d4e1a2900821 (patch)
tree6d2f0a88ab17a4b64724b625e2dd3c833e4d0617 /src/net/java
parent59d61ccd9670949dec01dc510e45f2d7e0e9d84c (diff)
downloadjitsi-b9ec3d74bb83c882d916ab7d0c90d4e1a2900821.zip
jitsi-b9ec3d74bb83c882d916ab7d0c90d4e1a2900821.tar.gz
jitsi-b9ec3d74bb83c882d916ab7d0c90d4e1a2900821.tar.bz2
Adds remove of contact sources from ui.
Diffstat (limited to 'src/net/java')
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java57
1 files changed, 52 insertions, 5 deletions
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 b20e7ae..e11ad77 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
@@ -207,7 +207,32 @@ public class TreeContactList
* about the received <tt>SourceContact</tt>
*/
public void contactRemoved(ContactRemovedEvent event)
- {}
+ {
+ final SourceContact sourceContact = event.getContact();
+
+ ContactSourceService contactSource
+ = sourceContact.getContactSource();
+
+ ExternalContactSource sourceUI
+ = TreeContactList.getContactSource(contactSource);
+
+ if (sourceUI == null)
+ return;
+
+ UIContact uiContact
+ = ExternalContactSource.getUIContact(sourceContact);
+
+ if(uiContact == null)
+ return;
+
+ // ExtendedContactSourceService has already matched the
+ // SourceContact over the pattern
+ if((contactSource instanceof ExtendedContactSourceService)
+ || currentFilter.isMatching(uiContact))
+ {
+ removeContact(uiContact, false);
+ }
+ }
/**
* Indicates that a <tt>MetaContact</tt> has been received for a search in
@@ -499,8 +524,9 @@ public class TreeContactList
* Removes the node corresponding to the given <tt>MetaContact</tt> from
* this list.
* @param contact the <tt>UIContact</tt> to remove
+ * @param removeEmptyGroup whether we should delete the group if is empty
*/
- public void removeContact(final UIContact contact)
+ public void removeContact(final UIContact contact, final boolean removeEmptyGroup)
{
if (!SwingUtilities.isEventDispatchThread())
{
@@ -508,7 +534,7 @@ public class TreeContactList
{
public void run()
{
- removeContact(contact);
+ removeContact(contact, removeEmptyGroup);
}
});
return;
@@ -528,7 +554,7 @@ public class TreeContactList
parentGroupNode.removeContact(contact);
// If the parent group is empty remove it.
- if (parentGroupNode.getChildCount() == 0)
+ if (removeEmptyGroup && parentGroupNode.getChildCount() == 0)
{
GroupNode parent = (GroupNode) parentGroupNode.getParent();
@@ -538,6 +564,16 @@ public class TreeContactList
}
/**
+ * Removes the node corresponding to the given <tt>MetaContact</tt> from
+ * this list.
+ * @param contact the <tt>UIContact</tt> to remove
+ */
+ public void removeContact(UIContact contact)
+ {
+ removeContact(contact, true);
+ }
+
+ /**
* Indicates that the information corresponding to the given
* <tt>contact</tt> has changed.
*
@@ -1732,7 +1768,7 @@ public class TreeContactList
* Listens for adding and removing of <tt>ContactSourceService</tt>
* implementations.
*/
- private static class ContactSourceServiceListener
+ private class ContactSourceServiceListener
implements ServiceListener
{
public void serviceChanged(ServiceEvent event)
@@ -1751,20 +1787,31 @@ public class TreeContactList
if (!(service instanceof ContactSourceService))
return;
+ boolean changed = false;
switch (event.getType())
{
case ServiceEvent.REGISTERED:
ExternalContactSource contactSource
= new ExternalContactSource((ContactSourceService) service);
contactSources.add(contactSource);
+ changed = true;
break;
case ServiceEvent.UNREGISTERING:
ExternalContactSource cSource
= getContactSource((ContactSourceService) service);
if (cSource != null)
contactSources.remove(cSource);
+ changed = true;
break;
}
+
+ if(changed)
+ {
+ if(currentFilter.equals(defaultFilter))
+ applyDefaultFilter();
+ else
+ applyFilter(currentFilter);
+ }
}
}