Retain contact groups state between loads.

cusax-fix
Yana Stamcheva 18 years ago
parent 5fbcf0a164
commit 178c27aebc

@ -308,6 +308,37 @@ public MetaContactImpl findMetaContactByMetaUID(String metaUID)
return null;
}
/**
* Returns a meta contact group this group or some of its subgroups,
* that has the specified metaUID. If no such meta contact group exists,
* the method would return null.
*
* @param metaUID the Meta UID of the contact group we're looking for.
* @return the MetaContactGroup with the specified UID or null if no such
* contact exists.
*/
public MetaContactGroupImpl findMetaContactGroupByMetaUID(String metaUID)
{
if (metaUID.equals(groupUID))
return this;
//if we didn't find it here, let's try in the subougroups
Iterator groupsIter = getSubgroups();
while( groupsIter.hasNext() )
{
MetaContactGroupImpl mGroup
= (MetaContactGroupImpl) groupsIter.next();
if (metaUID.equals(mGroup.getMetaUID()))
return mGroup;
else
mGroup.findMetaContactByMetaUID(metaUID);
}
return null;
}
/**
* Returns an iterator over all the protocol specific groups that this

@ -1376,6 +1376,20 @@ public MetaContact findMetaContactByMetaUID(String metaContactID)
return rootMetaGroup.findMetaContactByMetaUID(metaContactID);
}
/**
* Returns the MetaContactGroup that corresponds to the specified
* metaGroupID.
*
* @param metaGroupID
* a String identifier of a meta contact group.
* @return the MetaContactGroup with the specified string identifier or null
* if no such meta contact was found.
*/
public MetaContactGroup findMetaContactGroupByMetaUID(String metaGroupID)
{
return rootMetaGroup.findMetaContactGroupByMetaUID(metaGroupID);
}
/**
* Goes through the server stored ContactList of the specified operation
* set, retrieves all protocol specific contacts it contains and makes sure

@ -7,9 +7,7 @@
package net.java.sip.communicator.impl.gui.main.contactlist;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.*;
import java.awt.*;
import java.util.*;
import javax.swing.*;
@ -68,6 +66,8 @@ public ContactListModel(MetaContactListService contactList)
this.contactList = contactList;
this.rootGroup = this.contactList.getRoot();
this.initGroupsStatus(rootGroup);
}
/**
@ -472,6 +472,10 @@ public void closeGroup(MetaContactGroup group)
}
this.closedGroups.add(group);
ConfigurationManager.storeContactListGroupStatus(
group.getMetaUID(),
true);
}
}
@ -485,6 +489,10 @@ public void openGroup(MetaContactGroup group)
this.closedGroups.remove(group);
contentAdded(this.indexOf(group.getMetaContact(0)), this.indexOf(group
.getMetaContact(countContactsAndSubgroups(group) - 1)));
ConfigurationManager.storeContactListGroupStatus(
group.getMetaUID(),
false);
}
/**
@ -667,4 +675,27 @@ public boolean isContactActive(MetaContact metaContact)
return this.activeContacts.contains(metaContact);
}
}
private void initGroupsStatus(MetaContactGroup group)
{
boolean isClosed = ConfigurationManager
.getContactListGroupStatus(group.getMetaUID());
System.out.println("GROUPATAAAA========" + group.getGroupName()
+ "=========IS CLOSED ==============" + isClosed);
if (isClosed)
{
closedGroups.add(group);
}
Iterator subgroups = group.getSubgroups();
while (subgroups.hasNext())
{
MetaContactGroup subgroup = (MetaContactGroup) subgroups.next();
this.initGroupsStatus(subgroup);
}
}
}

@ -636,6 +636,81 @@ public static String getChatRoomStatus(
return null;
}
public static void storeContactListGroupStatus( String groupID,
boolean status)
{
String prefix = "net.java.sip.communicator.impl.gui.contactlist.groups";
List groups = configService
.getPropertyNamesByPrefix(prefix, true);
Iterator groupsIter = groups.iterator();
boolean isExistingGroup = false;
while(groupsIter.hasNext())
{
String groupRootPropName
= (String) groupsIter.next();
String storedID
= configService.getString(groupRootPropName);
if(storedID.equals(groupID))
{
configService.setProperty( groupRootPropName
+ ".isClosed",
Boolean.toString(status));
isExistingGroup = true;
break;
}
}
if(!isExistingGroup)
{
String groupNodeName
= "group" + Long.toString(System.currentTimeMillis());
String groupPackage = prefix + "." + groupNodeName;
configService.setProperty( groupPackage,
groupID);
configService.setProperty( groupPackage
+ ".isClosed",
Boolean.toString(status));
}
}
public static boolean getContactListGroupStatus(String groupID)
{
String prefix = "net.java.sip.communicator.impl.gui.contactlist.groups";
List groups = configService
.getPropertyNamesByPrefix(prefix, true);
Iterator groupsIter = groups.iterator();
while(groupsIter.hasNext())
{
String groupRootPropName
= (String) groupsIter.next();
String storedID
= configService.getString(groupRootPropName);
if(storedID.equals(groupID))
{
String status = (String) configService
.getProperty( groupRootPropName + ".isClosed");
return new Boolean(status).booleanValue();
}
}
return false;
}
private static class ConfigurationChangeListener
implements PropertyChangeListener
{

Loading…
Cancel
Save