diff options
6 files changed, 94 insertions, 24 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/UIFilterQuery.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/UIFilterQuery.java index d17bbe6..c18b825 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/UIFilterQuery.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/UIFilterQuery.java @@ -369,8 +369,7 @@ public class UIFilterQuery List<SourceContact> queryResults = filterQueries.get(query); queryResults.add(contact); - - if (getMaxResultShown() > -1 + if (getMaxResultShown() > -1 && event.isShowMoreEnabled() && queryResults.size() == getMaxResultShown()) { query.removeContactQueryListener(contactList); diff --git a/src/net/java/sip/communicator/impl/muc/ChatRoomContactSourceService.java b/src/net/java/sip/communicator/impl/muc/ChatRoomContactSourceService.java index 16e212f..24b0870 100644 --- a/src/net/java/sip/communicator/impl/muc/ChatRoomContactSourceService.java +++ b/src/net/java/sip/communicator/impl/muc/ChatRoomContactSourceService.java @@ -69,7 +69,7 @@ public class ChatRoomContactSourceService if (queryString == null) queryString = ""; ChatRoomQuery contactQuery - = new ChatRoomQuery(queryString, contactCount, this); + = new ChatRoomQuery(queryString, this); synchronized (queries) { diff --git a/src/net/java/sip/communicator/impl/muc/ChatRoomQuery.java b/src/net/java/sip/communicator/impl/muc/ChatRoomQuery.java index a7b2bcb..b794823 100644 --- a/src/net/java/sip/communicator/impl/muc/ChatRoomQuery.java +++ b/src/net/java/sip/communicator/impl/muc/ChatRoomQuery.java @@ -31,11 +31,6 @@ public class ChatRoomQuery private String queryString;
/**
- * The contact count.
- */
- private int count = 0;
-
- /**
* List with the current results for the query.
*/
private Set<ChatRoomSourceContact> contactResults
@@ -55,13 +50,12 @@ public class ChatRoomQuery * @param queryString the query string to match
* @param count the maximum result contact count
*/
- public ChatRoomQuery(String queryString,
- int count, ChatRoomContactSourceService contactSource)
+ public ChatRoomQuery(String queryString,
+ ChatRoomContactSourceService contactSource)
{
super(contactSource,
Pattern.compile(queryString, Pattern.CASE_INSENSITIVE
| Pattern.LITERAL), true);
- this.count = count;
this.queryString = queryString;
for(ProtocolProviderService pps : MUCActivator.getChatRoomProviders())
{
@@ -116,12 +110,6 @@ public class ChatRoomQuery for(int i = 0; i < provider.countChatRooms(); i++)
{
- if(count > 0 && getQueryResultCount() > count)
- {
- if (getStatus() != QUERY_CANCELED)
- setStatus(QUERY_COMPLETED);
- return;
- }
ChatRoomWrapper chatRoom = provider.getChatRoom(i);
addChatRoom( provider.getProtocolProvider(),
chatRoom.getChatRoomName(), chatRoom.getChatRoomID(),
@@ -225,11 +213,11 @@ public class ChatRoomQuery if(addQueryResult)
{
- addQueryResult(contact);
+ addQueryResult(contact, false);
}
else
{
- fireContactReceived(contact);
+ fireContactReceived(contact, false);
}
}
}
@@ -261,11 +249,11 @@ public class ChatRoomQuery if(addQueryResult)
{
- addQueryResult(contact);
+ addQueryResult(contact, false);
}
else
{
- fireContactReceived(contact);
+ fireContactReceived(contact, false);
}
}
}
@@ -343,7 +331,6 @@ public class ChatRoomQuery if(contact.equals(it.next()))
{
return i;
-
}
i++;
}
diff --git a/src/net/java/sip/communicator/service/contactsource/AbstractContactQuery.java b/src/net/java/sip/communicator/service/contactsource/AbstractContactQuery.java index 523e350..716cd7e 100644 --- a/src/net/java/sip/communicator/service/contactsource/AbstractContactQuery.java +++ b/src/net/java/sip/communicator/service/contactsource/AbstractContactQuery.java @@ -98,8 +98,11 @@ public abstract class AbstractContactQuery<T extends ContactSourceService> * @param contact the <tt>SourceContact</tt> which has been received and
* which the registered <tt>ContactQueryListener</tt>s are to be notified
* about
+ * @param showMoreEnabled indicates whether show more label should be shown
+ * or not.
*/
- protected void fireContactReceived(SourceContact contact)
+ protected void fireContactReceived(SourceContact contact,
+ boolean showMoreEnabled)
{
ContactQueryListener[] ls;
@@ -108,10 +111,27 @@ public abstract class AbstractContactQuery<T extends ContactSourceService> ls = listeners.toArray(new ContactQueryListener[listeners.size()]);
}
- ContactReceivedEvent ev = new ContactReceivedEvent(this, contact);
+ ContactReceivedEvent ev
+ = new ContactReceivedEvent(this, contact, showMoreEnabled);
for (ContactQueryListener l : ls)
+ {
l.contactReceived(ev);
+ }
+ }
+
+ /**
+ * Notifies the <tt>ContactQueryListener</tt>s registered with this
+ * <tt>ContactQuery</tt> that a new <tt>SourceContact</tt> has been
+ * received.
+ *
+ * @param contact the <tt>SourceContact</tt> which has been received and
+ * which the registered <tt>ContactQueryListener</tt>s are to be notified
+ * about
+ */
+ protected void fireContactReceived(SourceContact contact)
+ {
+ fireContactReceived(contact, true);
}
/**
diff --git a/src/net/java/sip/communicator/service/contactsource/AsyncContactQuery.java b/src/net/java/sip/communicator/service/contactsource/AsyncContactQuery.java index 3ce2506..21fa13c 100644 --- a/src/net/java/sip/communicator/service/contactsource/AsyncContactQuery.java +++ b/src/net/java/sip/communicator/service/contactsource/AsyncContactQuery.java @@ -99,6 +99,33 @@ public abstract class AsyncContactQuery<T extends ContactSourceService> *
* @param sourceContact the <tt>SourceContact</tt> to be added to the
* <tt>queryResults</tt> of this <tt>ContactQuery</tt>
+ * @param showMoreEnabled indicates whether show more label should be shown
+ * or not.
+ * @return <tt>true</tt> if the <tt>queryResults</tt> of this
+ * <tt>ContactQuery</tt> has changed in response to the call
+ */
+ protected boolean addQueryResult(SourceContact sourceContact,
+ boolean showMoreEnabled)
+ {
+ boolean changed;
+
+ synchronized (queryResults)
+ {
+ changed = queryResults.add(sourceContact);
+ }
+ if (changed)
+ fireContactReceived(sourceContact, showMoreEnabled);
+
+ return changed;
+ }
+
+ /**
+ * Adds a specific <tt>SourceContact</tt> to the list of
+ * <tt>SourceContact</tt>s to be returned by this <tt>ContactQuery</tt> in
+ * response to {@link #getQueryResults()}.
+ *
+ * @param sourceContact the <tt>SourceContact</tt> to be added to the
+ * <tt>queryResults</tt> of this <tt>ContactQuery</tt>
* @return <tt>true</tt> if the <tt>queryResults</tt> of this
* <tt>ContactQuery</tt> has changed in response to the call
*/
diff --git a/src/net/java/sip/communicator/service/contactsource/ContactReceivedEvent.java b/src/net/java/sip/communicator/service/contactsource/ContactReceivedEvent.java index 0adb9a9..37123ac 100644 --- a/src/net/java/sip/communicator/service/contactsource/ContactReceivedEvent.java +++ b/src/net/java/sip/communicator/service/contactsource/ContactReceivedEvent.java @@ -26,6 +26,11 @@ public class ContactReceivedEvent * The contact that has been received. */ private final SourceContact contact; + + /** + * Indicates whether show more label should be shown or not. + */ + private final boolean showMoreEnabled; /** * Creates a <tt>ContactReceivedEvent</tt> by specifying the contact search @@ -39,6 +44,27 @@ public class ContactReceivedEvent super(source); this.contact = contact; + + showMoreEnabled = true; + } + + /** + * Creates a <tt>ContactReceivedEvent</tt> by specifying the contact search + * source and the received <tt>searchContact</tt>. + * @param source the source that triggered this event + * @param contact the received contact + * @param showMoreEnabled indicates whether show more label should be shown + * or not. + */ + public ContactReceivedEvent(ContactQuery source, + SourceContact contact, + boolean showMoreEnabled) + { + super(source); + + this.contact = contact; + + this.showMoreEnabled = showMoreEnabled; } /** @@ -58,4 +84,15 @@ public class ContactReceivedEvent { return contact; } + + /** + * Returns <tt>true</tt> if show more label should be shown and + * <tt>false</tt> if not. + * @return <tt>true</tt> if show more label should be shown and + * <tt>false</tt> if not. + */ + public boolean isShowMoreEnabled() + { + return showMoreEnabled; + } } |