if (JOptionPane.showConfirmDialog(main, MessageFormat.format(I18N.gettext("main.popup.Really_remove_{0}?_All_JIDs_in_this_group_will_be_removed!"), new Object[] {currentGroup}),
I18N.gettext("main.popup.Remove_Group"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
{
for (Iterator i = currentJIDStatusGroup.iterator(); i.hasNext();)
{
PrimaryJIDStatus primary = (PrimaryJIDStatus) i.next();
if (primary.hasMultiple())
{
for (Iterator j = primary.getOtherJidStatussen(); j.hasNext();)
{
groupRemove((JIDStatus) j.next());
}
}
groupRemove(primary.getJIDPrimaryStatus());
}
}
}
private void groupRemove(JIDStatus jidStatus)
{
JID to = jidStatus.getJID();
if (jidStatus.groupCount() == 1)
{
if (JOptionPane.showConfirmDialog(main,
MessageFormat.format(I18N.gettext(
"main.popup.{0}_is_in_the_last_group,_remove_completely?")
, new Object[] {to.toString()})
, I18N.gettext("main.main.rostermenu.Remove")
, JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
IQXRoster roster = new IQXRoster(new RosterItem(to, null, "remove", null, null));
backend.send(new InfoQuery("set", roster));
}
}
else
{
List groups = jidStatus.getGroupsCopy();
groups.remove(currentGroup);
IQXRoster roster = new IQXRoster(new RosterItem(to, jidStatus.getNick(), null, null, groups));
backend.send(new InfoQuery("set", roster));
}
}
});
groupPopupMenu.add(menuItem);
menuItem = new JMenuItem();
I18N.setTextAndMnemonic("main.main.rostermenu.Rename",menuItem,true);
menuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String groupName = JOptionPane.showInputDialog(main, MessageFormat.format(I18N.gettext("main.popup.Rename_{0}_to"),new Object[] {currentGroup}));
if (groupName == null) return;
for (Iterator i = currentJIDStatusGroup.iterator(); i.hasNext();)
{
PrimaryJIDStatus primary = (PrimaryJIDStatus) i.next();
if (primary.hasMultiple())
{
for (Iterator j = primary.getOtherJidStatussen(); j.hasNext();)
{
renameGroup(groupName, (JIDStatus) j.next());
}
}
renameGroup(groupName, primary.getJIDPrimaryStatus());
}
}
private void renameGroup(String groupName, JIDStatus jidStatus)
{