Moves the chat room contact group on the top of the contact list for the

presence filter and after the meta contacts for the search filter.
cusax-fix
hristoterezov 12 years ago
parent 5a1703dfe8
commit 9bdd23d95c

@ -82,6 +82,9 @@ service.gui.TAB_TITLE_SELECTED=000000
# Background color for even records in call history
service.gui.CALL_HISTORY_EVEN_ROW_COLOR=EFEFEF
# Background color for even records in call history
service.gui.CHAT_ROOM_ROW_COLOR=F6F6F6
# Selection color for all lists (contact list, call list, chat rooms list, etc.)
service.gui.LIST_SELECTION_COLOR=9ae8fc

@ -3659,4 +3659,14 @@ public void supportedOperationSetsChanged(ContactCapabilitiesEvent event)
metaContactImpl,
metaContactImpl);
}
/**
* Returns the index of the contact source in the result list.
*
* @return the index of the contact source in the result list
*/
public int getSourceIndex()
{
return 1;
}
}

@ -425,7 +425,14 @@ public Component getTreeCellRendererComponent(JTree tree, Object value,
{
UIContactImpl contact
= ((ContactNode) value).getContactDescriptor();
if((contact.getDescriptor() instanceof SourceContact) &&
((SourceContact)contact.getDescriptor())
.getPreferredContactDetail(OperationSetMultiUserChat.class)
!= null)
{
setBackground(Constants.CHAT_ROOM_ROW_COLOR);
}
String displayName = contact.getDisplayName();
if ((displayName == null

@ -396,18 +396,6 @@ private static class NodeComparator
*/
public int compare(ContactListNode node1, ContactListNode node2)
{
// Child groups are shown after child contacts.
if (node1 instanceof GroupNode)
{
if (node2 instanceof ContactNode)
return 1;
}
else if (node1 instanceof ContactNode)
{
if (node2 instanceof GroupNode)
return -1;
}
int index1 = node1.getSourceIndex();
int index2 = node2.getSourceIndex();

@ -42,6 +42,14 @@ public class PresenceFilter
* directly to the contact list without firing events.
*/
private static final int INITIAL_CONTACT_COUNT = 30;
/**
* Preferences for the external contact sources. Lists the type of contact
* contact sources that will be displayed in the filter and the order of the
* contact sources.
*/
private static Map<Integer, Integer> contactSourcePreferences
= new HashMap<Integer, Integer>();
/**
* Creates an instance of <tt>PresenceFilter</tt>.
@ -49,8 +57,21 @@ public class PresenceFilter
public PresenceFilter()
{
isShowOffline = ConfigurationUtils.isShowOffline();
initContactSourcePreferences();
}
/**
* Initializes the contact source preferences. The preferences are for the
* visibility of the contact source and their order.
*/
private void initContactSourcePreferences()
{
//This entry will be used to set the index for chat room contact sources
//The index is used to order the contact sources in the contact list.
//The chat room sources will be ordered before the meta contact list.
contactSourcePreferences.put(ContactSourceService.CHAT_ROOM_TYPE, 0);
}
/**
* Applies this filter. This filter is applied over the
* <tt>MetaContactListService</tt>.
@ -66,21 +87,33 @@ public void applyFilter(FilterQuery filterQuery)
filterQuery.addContactQuery(query);
List<ContactQuery> contactQueryList = new ArrayList<ContactQuery>();
Iterator<UIContactSource> filterSources
= GuiActivator.getContactList().getContactSources(
ContactSourceService.PRESENCE_TYPE).iterator();
while (filterSources.hasNext())
for(int cssType : contactSourcePreferences.keySet())
{
UIContactSource filterSource = filterSources.next();
ContactSourceService sourceService
= filterSource.getContactSourceService();
ContactQuery contactQuery = sourceService.queryContactSource(null);
contactQueryList.add(contactQuery);
// Add this query to the filterQuery.
filterQuery.addContactQuery(contactQuery);
Iterator<UIContactSource> filterSources
= GuiActivator.getContactList().getContactSources(cssType)
.iterator();
while (filterSources.hasNext())
{
UIContactSource filterSource = filterSources.next();
Integer prefValue = contactSourcePreferences.get(cssType);
//We are setting the index from contactSourcePreferences map to
//the contact source. This index is set to reorder the sources
//in the contact list.
if(prefValue != null)
filterSource.setContactSourceIndex(prefValue);
ContactSourceService sourceService
= filterSource.getContactSourceService();
ContactQuery contactQuery = sourceService.queryContactSource(null);
contactQueryList.add(contactQuery);
// Add this query to the filterQuery.
filterQuery.addContactQuery(contactQuery);
}
}
// Closes this filter to indicate that we finished adding queries to it.

@ -51,6 +51,12 @@ public class SearchFilter
protected String DISABLE_CALL_HISTORY_SEARCH_PROP
= "net.java.sip.communicator.impl.gui"
+ ".DISABLE_CALL_HISTORY_SEARCH_IN_CONTACT_LIST";
/**
* Defines custom order for the contact sources.
*/
private static Map<Integer, Integer> contactSourceOrder
= new HashMap<Integer, Integer>();
/**
* Creates an instance of <tt>SearchFilter</tt>.
@ -58,6 +64,7 @@ public class SearchFilter
public SearchFilter(MetaContactListSource contactListSource)
{
this.mclSource = contactListSource;
initContactSourceOrder();
}
/**
@ -67,6 +74,19 @@ public SearchFilter(ContactList sourceContactList)
{
this.mclSource = null;
this.sourceContactList = sourceContactList;
initContactSourceOrder();
}
/**
* Initializes the custom contact source order map.
*/
private void initContactSourceOrder()
{
//This entry will be used to set the index for chat room contact sources
//The index is used to order the contact sources in the contact list.
//The chat room sources will be ordered after the meta contact list.
contactSourceOrder.put(ContactSourceService.CHAT_ROOM_TYPE,
GuiActivator.getContactListService().getSourceIndex() + 1);
}
/**
@ -108,7 +128,7 @@ else if (sourceContactList.getDefaultFilter()
{
final UIContactSource filterSource
= filterSources.next();
// Don't search in history sources if this is disabled from the
// corresponding configuration property.
if (sourceContactList.getDefaultFilter()
@ -119,6 +139,18 @@ else if (sourceContactList.getDefaultFilter()
== ContactSourceService.HISTORY_TYPE)
continue;
if (sourceContactList.getDefaultFilter()
.equals(TreeContactList.presenceFilter))
{
Integer contactSourceIndex = contactSourceOrder.get(
filterSource.getContactSourceService().getType());
if(contactSourceIndex != null)
{
//We are setting the index from contactSourceOrder map. This
//index is set to reorder the sources in the contact list.
filterSource.setContactSourceIndex(contactSourceIndex);
}
}
// If we have stopped filtering in the mean time we return here.
if (filterQuery.isCanceled())
return;

@ -16,6 +16,8 @@
import net.java.sip.communicator.service.customcontactactions.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.Logger;
import org.osgi.framework.*;
import java.awt.*;
@ -74,6 +76,11 @@ public class ExternalContactSource
customServiceActionButtons;
private final JTree contactListTree;
/**
* The index of the contact source used to order the contact sources.
*/
private int contactSourceIndex;
/**
* Creates an <tt>ExternalContactSource</tt> based on the given
@ -87,6 +94,7 @@ public ExternalContactSource( ContactSourceService contactSource,
{
this.contactSource = contactSource;
this.contactListTree = contactListTree;
contactSourceIndex = contactSource.getIndex();
sourceUIGroup = new SourceUIGroup(contactSource.getDisplayName(), this);
}
@ -592,6 +600,16 @@ public void actionPerformed(ActionEvent event)
return contactActionsServices;
}
/**
* Sets the contact source index.
*
* @param contactSourceIndex the contact source index to set
*/
public void setContactSourceIndex(int contactSourceIndex)
{
this.contactSourceIndex = contactSourceIndex;
}
/**
* The <tt>SourceUIGroup</tt> is the implementation of the UIGroup for the
* <tt>ExternalContactSource</tt>. It takes the name of the source and
@ -646,10 +664,8 @@ public UIGroup getParentGroup()
@Override
public int getSourceIndex()
{
int sourceIndex = contactSource.getIndex();
if (sourceIndex >= 0)
return sourceIndex;
if (contactSourceIndex >= 0)
return contactSourceIndex * MAX_GROUPS;
if (contactSource.getType() == ContactSourceService.HISTORY_TYPE)
return Integer.MAX_VALUE;

@ -154,9 +154,18 @@ public int getSourceIndex()
{
MetaContactGroup parentMetaContactGroup =
metaContact.getParentMetaContactGroup();
int groupSourceIndex = 0;
if (parentMetaContactGroup == null)
return -1;
return parentMetaContactGroup.indexOf(metaContact);
MetaContactGroup parentGroup
= parentMetaContactGroup.getParentMetaContactGroup();
if(parentGroup != null)
groupSourceIndex = parentGroup.indexOf(parentMetaContactGroup)
* UIGroup.MAX_CONTACTS;
return GuiActivator.getContactListService().getSourceIndex()
* UIGroup.MAX_GROUPS + groupSourceIndex +
parentMetaContactGroup.indexOf(metaContact);
}
/**

@ -67,7 +67,10 @@ public Object getDescriptor()
@Override
public int getSourceIndex()
{
return metaGroup.getParentMetaContactGroup().indexOf(metaGroup);
return GuiActivator.getContactListService().getSourceIndex()
* MAX_GROUPS +
(metaGroup.getParentMetaContactGroup().indexOf(metaGroup) + 1)
* MAX_CONTACTS;
}
/**

@ -118,7 +118,10 @@ public void setParentGroup(UIGroup parentGroup) {}
@Override
public int getSourceIndex()
{
return sourceContact.getIndex();
int contactIndex = sourceContact.getIndex();
int groupIndex = getParentGroup().getSourceIndex();
return ((contactIndex == -1) ? -1 :
((groupIndex == -1) ? contactIndex : groupIndex + contactIndex));
}
/**

@ -57,6 +57,13 @@ public class Constants
public static Color CALL_HISTORY_EVEN_ROW_COLOR
= new Color(GuiActivator.getResources().
getColor("service.gui.CALL_HISTORY_EVEN_ROW_COLOR"));
/**
* Background color for chat room contact rows.
*/
public static Color CHAT_ROOM_ROW_COLOR
= new Color(GuiActivator.getResources().
getColor("service.gui.CHAT_ROOM_ROW_COLOR"));
/**
* The start color used to paint a gradient selected background of some

@ -22,7 +22,7 @@ public class ChatRoomContactSourceService
*/
public int getType()
{
return PRESENCE_TYPE;
return CHAT_ROOM_TYPE;
}
/**
@ -69,6 +69,7 @@ public ContactQuery queryContactSource(String queryString, int contactCount)
return contactQuery;
}
/**
* Returns the index of the contact source in the result list.
*
@ -77,7 +78,7 @@ public ContactQuery queryContactSource(String queryString, int contactCount)
@Override
public int getIndex()
{
return -1;
return 0;
}
}

@ -397,4 +397,11 @@ public void removeMetaContactGroup(MetaContactGroup groupToRemove)
* beginning the tests with an empty local contact list.
*/
public void purgeLocallyStoredContactListCopy();
/**
* Returns the index of the contact source in the result list.
*
* @return the index of the contact source in the result list
*/
public int getSourceIndex();
}

@ -31,9 +31,9 @@ public interface ContactSourceService
public static final int HISTORY_TYPE = 2;
/**
* Type of a presence source. Queries when presence should be shown.
* Type of a chat room source.
*/
public static final int PRESENCE_TYPE = 3;
public static final int CHAT_ROOM_TYPE = 3;
/**
* Returns the type of this contact source.

@ -57,4 +57,11 @@ public interface UIContactSource
* @return the corresponding <tt>ContactSourceService</tt>
*/
public ContactSourceService getContactSourceService();
/**
* Sets the contact source index.
*
* @param contactSourceIndex the contact source index to set
*/
public void setContactSourceIndex(int contactSourceIndex);
}

@ -27,6 +27,16 @@ public abstract class UIGroup
* The display details of this group.
*/
private String displayDetails = "";
/**
* The maximum number of contacts in the contact source.
*/
public static int MAX_GROUPS = 10000000;
/**
* The maximum number of contacts in the group.
*/
public static int MAX_CONTACTS = 10000;
/**
* Returns the descriptor of the group. This would be the underlying object

Loading…
Cancel
Save