ContactData data = datas.get(currentItem);
if(data == null)
return;
final String jid = data.get(JID);
final String nick = data.get(ALIAS);
final MessageBox box = MessageBox.prompt(JabberApp.getConstants().Rename(), JabberApp.getConstants().RenamePrompt()+" "+nick+":");
box.addCallback(new Listener<MessageBoxEvent>()
{
public void handleEvent(MessageBoxEvent be)
{
if(!be.value.isEmpty())
{
if(!be.buttonClicked.getItemId().equals(MessageBox.OK))
return;
if(!nick.equals(be.value))
JabberApp.instance().renameUser(XmppID.parseId(jid), be.value);
}
}
});
}
});
groupMenuItem = new MenuItem(JabberApp.getConstants().Group());
groupMenu = new Menu();
groupMenuItem.setSubMenu(groupMenu);
groupMenuItem.addListener(Events.Activate, new Listener<MenuEvent>()
{
public void handleEvent(MenuEvent be)
{
List<ContactData> datas = store.getModels();
ContactData data = datas.get(currentItem);
if(data == null)
return;
final String jid = data.get(JID);
final String group = data.get(USER_GROUP_DD);
final String nick = data.get(ALIAS);
Menu groupMenu = groupMenuItem.getSubMenu();
groupMenu.removeAll();
for(String g:m_groups)
{
CheckMenuItem gItem = new CheckMenuItem(g);
gItem.setGroup("groups");
if(g.equals(group))
gItem.setChecked(true);
groupMenu.add(gItem);
gItem.addListener(Events.Select, new Listener<MenuEvent>()
{
public void handleEvent(MenuEvent be)
{
MenuItem mItem = (MenuItem)be.item;
String newGroup = mItem.getText();
if(!newGroup.equals(group))
JabberApp.instance().changeGroup(XmppID.parseId(jid),nick, newGroup);
}
});
}
groupMenu.add(new SeparatorMenuItem());
MenuItem newGroupItem = new MenuItem(JabberApp.getConstants().New_Group());
newGroupItem.addListener(Events.Select, new Listener<MenuEvent>()
{
public void handleEvent(MenuEvent be)
{
final MessageBox box = MessageBox.prompt(JabberApp.getConstants().New_Group(), JabberApp.getConstants().NewGroupPrompt());
box.addCallback(new Listener<MessageBoxEvent>()
{
public void handleEvent(MessageBoxEvent be)
{
if(!be.value.isEmpty())
{