}
private Menu createContextMenu()
{
Menu menu = new Menu();
chatItem = new MenuItem(JabberApp.getConstants().openChat());
chatItem.addListener(Events.Select, new Listener<MenuEvent>()
{
public void handleEvent(MenuEvent me)
{
List<ContactData> datas = store.getModels();
ContactData data = datas.get(currentItem);
if(data == null)
return;
String jid = data.get(JID);
ChatWindow.openChat(XmppID.parseId(jid));
}
});
infoItem = new MenuItem(JabberApp.getConstants().userInfo());
infoItem.addListener(Events.Select, new Listener<MenuEvent>()
{
public void handleEvent(MenuEvent me)
{
List<ContactData> datas = store.getModels();
ContactData data = datas.get(currentItem);
if(data == null)
return;
String jid = data.get(JID);
JabberApp.instance().showInfo(XmppID.parseId(jid));
}
});
requestAuth = new MenuItem(JabberApp.getConstants().Rerequset_authorization());
requestAuth.addListener(Events.Select, new Listener<MenuEvent>()
{
public void handleEvent(MenuEvent me)
{
List<ContactData> datas = store.getModels();
ContactData data = datas.get(currentItem);
if(data == null)
return;
String jid = data.get(JID);
JabberApp.instance().dj_authReq(XmppID.parseId(jid),"");
}
});
deleteItem = new MenuItem(JabberApp.getConstants().Delete());
deleteItem.addListener(Events.Select, new Listener<MenuEvent>()
{
public void handleEvent(MenuEvent me)
{
List<ContactData> datas = store.getModels();
ContactData data = datas.get(currentItem);
if(data == null)
return;
final String jid = data.get(JID);
String msg = JabberApp.getConstants().DeleteConfirm() +" "+jid+"?";
MessageBox.confirm("Confirm",msg, new Listener<WindowEvent>()
{
public void handleEvent(WindowEvent be)
{
Dialog dialog = (Dialog) be.component;
Button btn = dialog.getButtonPressed();
if(btn.getItemId().equals(Dialog.YES))
JabberApp.instance().removeUser(XmppID.parseId(jid));
}
});
}
});
onlineOnlyItem = new CheckMenuItem(JabberApp.getConstants().Show_online_only());
onlineOnlyItem.setChecked(iJabPrefs.instance().showOnlineOnly);
onlineOnlyItem.addListener(Events.Select, new Listener<MenuEvent>()
{
public void handleEvent(MenuEvent me)
{
CheckMenuItem item = (CheckMenuItem)me.item;
if(item.isChecked())
iJabPrefs.instance().showOnlineOnly = true;
else
iJabPrefs.instance().showOnlineOnly = false;
grid.getSelectionModel().deselectAll();
store.clearFilters();
store.applyFilters("");
}
});
renameItem = new MenuItem(JabberApp.getConstants().Rename());
renameItem.addListener(Events.Select, new Listener<MenuEvent>()
{
public void handleEvent(MenuEvent me)
{
List<ContactData> datas = store.getModels();
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>()