jidPopupMenu.add(new JSeparator());
} //if connected
//BSPresenceInfo pi = presenceBean.getResourcePresence(jid);
//if (pi == null) pi = new BSPresenceInfo(jid, false, null, null);
JIDStatus j = Roster.getJIDStatus(jid);
int show=0;
String status=null;
String nick=null;
if(j!=null)
{
show = j.getShow();
status = j.getStatus();
nick = j.getNick();
}
else show = Presence.NONE;
Icon img = getIconForPresence(show);
presenceMenuItem.setIcon(img);
if (status == null) status = "";
if(nick==null)nick ="?";
presenceMenuItem.setText(nick + " - " + status);
jidPopupMenu.add(presenceMenuItem);
jidPopupMenu.show(e.getComponent(), e.getX(), e.getY());
//adjustPopupPosition(jidPopupMenu);
}
// else if we clicked on cluster label
else if (src instanceof BSClusterLabel) {
clusterPopupMenu.removeAll();
Enumeration jids = ((BSClusterLabel)src).getJIDs();
// for all jid in cluster
while (jids.hasMoreElements()) {
JID j = (JID) jids.nextElement();
//BSPresenceInfo pi = presenceBean.getResourcePresence(j);
JIDStatus js = Roster.getJIDStatus(j);
int show=0;
String nick=null;
if(js!=null)
{
show = js.getShow();
nick = js.getNick();
}
else show = Presence.NONE;
Icon img = getIconForPresence(show);
if(nick==null)nick ="?";
JMenu jidSubmenu = new JMenu(nick + " (" + j.toString() + ")");
jidSubmenu.setIcon(img);
clusterPopupMenu.add(jidSubmenu);
if (connected) {
BSJIDActionMenuItem mi;
mi = new BSJIDActionMenuItem(CHAT_MENU_STR, j);
mi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mapPanel.openChat(((BSJIDActionMenuItem)e.getSource()).getJID());
}
});
jidSubmenu.add(mi);
mi = new BSJIDActionMenuItem(MSG_MENU_STR, j);
mi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mapPanel.sendMessage(((BSJIDActionMenuItem)e.getSource()).getJID());
}
});
jidSubmenu.add(mi);
mi = new BSJIDActionMenuItem(SUBSCRIBE_MENU_STR, j);
mi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mapPanel.sendSubscriptionRequest(((BSJIDActionMenuItem)e.getSource()).getJID());
}
});
jidSubmenu.add(mi);
/*
if (mapPanel.supportsPlans()) {
mi = new BSJIDActionMenuItem(GET_PLAN_MENU_STR, j);
mi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mapPanel.getPlan(((BSJIDActionMenuItem)e.getSource()).getJID());
}
});
jidSubmenu.add(mi);
}
*/
jidSubmenu.add(new JSeparator());
} // if connected
if (js == null) js = new UnknownJIDStatus(j);
String status = js.getStatus();
if (status == null) status = "";
JMenuItem presenceMI = new JMenuItem(Presence.toLongShow(js.getShow()) + " - " + status);
presenceMI.setIcon(img);
jidSubmenu.add(presenceMI);
} //while
clusterPopupMenu.show(e.getComponent(), e.getX(), e.getY());