RosterEntry entry = buddy.getRosterEntry();
entry.setName(buddyAlias);
int c = 0;
Iterator groups = entry.getGroups();
while (groups.hasNext()) {
RosterGroup g = (RosterGroup) groups.next();
if(!g.contains(entry)) continue;
g.removeEntry(entry);
c++;
}
buddy.setTempGroup(groupName);
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
dialog.setVisible(false);
buddy.setRemoved(false);
NMOptionDialog.createMessageDialog(null, resources.getString("addBuddyDialogTitle"), resources.getString("buddyAdded"));
BuddyList.getInstance().getBuddyListTree().addBuddy(
buddy);
}
});
if (groupName != null && !groupName.equals("")) {
RosterGroup newGroup = null;
newGroup = roster.getGroup(groupName);
if (newGroup == null) {
com.valhalla.Logger.debug("had to create new group" + groupName);
newGroup = roster.createGroup(groupName);
} else {
com.valhalla.Logger.debug("found group " + newGroup.getName());
}
if (c != 0) {
com.valhalla.Logger.debug("Moving buddy to " + newGroup.getName());
newGroup.addEntry(entry);
} else {
roster.createEntry(buddyId, buddyAlias,
new String[]{groupName});
}