|
|
|
|
@ -104,14 +104,13 @@ public void applyFilter(FilterQuery filterQuery)
|
|
|
|
|
if (sourceContactList.getDefaultFilter()
|
|
|
|
|
.equals(TreeContactList.presenceFilter))
|
|
|
|
|
{
|
|
|
|
|
final MetaContactQuery defaultQuery = new MetaContactQuery();
|
|
|
|
|
|
|
|
|
|
MetaContactQuery defaultQuery
|
|
|
|
|
= mclSource.queryMetaContactSource(filterPattern);
|
|
|
|
|
|
|
|
|
|
defaultQuery.addContactQueryListener(sourceContactList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// First add the MetaContactListSource
|
|
|
|
|
filterQuery.addContactQuery(defaultQuery);
|
|
|
|
|
|
|
|
|
|
mclSource.startQuery(defaultQuery, filterPattern);
|
|
|
|
|
}
|
|
|
|
|
else if (sourceContactList.getDefaultFilter()
|
|
|
|
|
.equals(TreeContactList.historyFilter))
|
|
|
|
|
@ -156,7 +155,10 @@ else if (sourceContactList.getDefaultFilter()
|
|
|
|
|
if (filterQuery.isCanceled())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
applyFilter(filterSource, filterQuery);
|
|
|
|
|
ContactQuery query = applyFilter(filterSource);
|
|
|
|
|
|
|
|
|
|
if (query.getStatus() == ContactQuery.QUERY_IN_PROGRESS)
|
|
|
|
|
filterQuery.addContactQuery(query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Closes this filter to indicate that we finished adding queries to it.
|
|
|
|
|
@ -171,11 +173,9 @@ else if (!sourceContactList.isEmpty())
|
|
|
|
|
*
|
|
|
|
|
* @param contactSource the <tt>ExternalContactSource</tt> to apply the
|
|
|
|
|
* filter to
|
|
|
|
|
* @param filterQuery the filter query object.
|
|
|
|
|
* @return the <tt>ContactQuery</tt> that tracks this filter
|
|
|
|
|
*/
|
|
|
|
|
protected ContactQuery applyFilter(UIContactSource contactSource,
|
|
|
|
|
FilterQuery filterQuery)
|
|
|
|
|
protected ContactQuery applyFilter(UIContactSource contactSource)
|
|
|
|
|
{
|
|
|
|
|
ContactSourceService sourceService
|
|
|
|
|
= contactSource.getContactSourceService();
|
|
|
|
|
@ -184,19 +184,15 @@ protected ContactQuery applyFilter(UIContactSource contactSource,
|
|
|
|
|
if (sourceService instanceof ExtendedContactSourceService)
|
|
|
|
|
contactQuery
|
|
|
|
|
= ((ExtendedContactSourceService) sourceService)
|
|
|
|
|
.createContactQuery(filterPattern);
|
|
|
|
|
.queryContactSource(filterPattern);
|
|
|
|
|
else
|
|
|
|
|
contactQuery = sourceService.createContactQuery(filterString);
|
|
|
|
|
contactQuery = sourceService.queryContactSource(filterString);
|
|
|
|
|
|
|
|
|
|
// Add first available results.
|
|
|
|
|
this.addMatching(contactQuery.getQueryResults());
|
|
|
|
|
|
|
|
|
|
contactQuery.addContactQueryListener(sourceContactList);
|
|
|
|
|
|
|
|
|
|
if (contactQuery.getStatus() == ContactQuery.QUERY_IN_PROGRESS)
|
|
|
|
|
{
|
|
|
|
|
filterQuery.addContactQuery(contactQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
contactQuery.start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return contactQuery;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -256,6 +252,19 @@ public void setFilterString(String filter)
|
|
|
|
|
| Pattern.UNICODE_CASE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if the given <tt>contact</tt> is matching the current filter.
|
|
|
|
|
* A <tt>SourceContact</tt> would be matching the filter if its display
|
|
|
|
|
* name is matching the search string.
|
|
|
|
|
* @param contact the <tt>ContactListContactDescriptor</tt> to check
|
|
|
|
|
* @return <tt>true</tt> to indicate that the given <tt>contact</tt> is
|
|
|
|
|
* matching the current filter, otherwise returns <tt>false</tt>
|
|
|
|
|
*/
|
|
|
|
|
private boolean isMatching(SourceContact contact)
|
|
|
|
|
{
|
|
|
|
|
return isMatching(contact.getDisplayName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates if the given string matches this filter.
|
|
|
|
|
* @param text the text to check
|
|
|
|
|
@ -269,4 +278,46 @@ private boolean isMatching(String text)
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds the list of <tt>sourceContacts</tt> to the contact list.
|
|
|
|
|
* @param sourceContacts the list of <tt>SourceContact</tt>s to add
|
|
|
|
|
*/
|
|
|
|
|
protected void addMatching(List<SourceContact> sourceContacts)
|
|
|
|
|
{
|
|
|
|
|
Iterator<SourceContact> contactsIter = sourceContacts.iterator();
|
|
|
|
|
|
|
|
|
|
while (contactsIter.hasNext())
|
|
|
|
|
addSourceContact(contactsIter.next());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds the given <tt>sourceContact</tt> to the contact list.
|
|
|
|
|
* @param sourceContact the <tt>SourceContact</tt> to add
|
|
|
|
|
*/
|
|
|
|
|
private void addSourceContact(SourceContact sourceContact)
|
|
|
|
|
{
|
|
|
|
|
ContactSourceService contactSource
|
|
|
|
|
= sourceContact.getContactSource();
|
|
|
|
|
|
|
|
|
|
UIContactSource sourceUI
|
|
|
|
|
= sourceContactList.getContactSource(contactSource);
|
|
|
|
|
|
|
|
|
|
if (sourceUI != null
|
|
|
|
|
// ExtendedContactSourceService has already matched the
|
|
|
|
|
// SourceContact over the pattern
|
|
|
|
|
&& (contactSource instanceof ExtendedContactSourceService)
|
|
|
|
|
|| isMatching(sourceContact))
|
|
|
|
|
{
|
|
|
|
|
boolean isSorted = (sourceContact.getIndex() > -1) ? true : false;
|
|
|
|
|
|
|
|
|
|
sourceContactList.addContact(
|
|
|
|
|
sourceUI.createUIContact(sourceContact),
|
|
|
|
|
sourceUI.getUIGroup(),
|
|
|
|
|
isSorted,
|
|
|
|
|
true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
sourceUI.removeUIContact(sourceContact);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|