public String getToolTipText(MouseEvent ev) { if (ev == null) return null; TreePath path = getPathForLocation(ev.getX(), ev.getY()); if (path != null) { JIDStatus jidStatus = null; Object o = path.getLastPathComponent(); if (o instanceof PrimaryJIDStatus) { jidStatus = ((PrimaryJIDStatus) o).getJIDPrimaryStatus(); } if (o instanceof JIDStatus) { jidStatus = ((JIDStatus) o); } else { return null; } String statusMsg; if (jidStatus.getStatus() != null) { statusMsg = I18N.gettext("main.main.statusmenu.Status_message:") + " " + jidStatus.getStatus() + "</p><p>"; } else { statusMsg = ""; } String waitingStatus = jidStatus.getWaiting(); if (jidStatus.getWaiting() != null) { waitingStatus = "<p>" + I18N.gettext("main.main.roster.Waiting_Status:") + " " + jidStatus.getWaiting() + "</p>"; } else { waitingStatus = ""; } return "<HTML><P>" + I18N.gettext("main.main.roster.Status:") + " " + Presence.toLongShow(jidStatus.getShow()) + "</p><p>" + statusMsg + "JID: " + jidStatus.getCompleteJID() + "</p><p>" + I18N.gettext("main.main.roster.Subscription:") + " " + jidStatus.getSubscription() + "</p>" + waitingStatus + "</p></HTML>"; } return null; }
/** Create a submenu with teh different messages for one status. */ private static JMenu createSubMenu(final int status) { JMenu subMenu = new JMenu(); I18N.setTextAndMnemonic(Presence.getI18NKey(status), subMenu); subMenu.setIcon(StatusIcons.getStatusIcon(status)); List messages = Preferences.getStatusMessages(status); for (Iterator it = messages.iterator(); it.hasNext(); ) { final String messageText = (String) it.next(); JMenuItem menuItem = new JMenuItem(messageText); menuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { changeStatus(status, messageText); } }); subMenu.add(menuItem); } return subMenu; }
/** Callback which is called when my presence status has changed. */ public void ownPresenceChanged(int astatus, String amessage) { this.status = astatus; if (amessage != null) { this.message = amessage; } else { this.message = Presence.toLongShow(astatus); } Runnable updateAComponent = new Runnable() { public void run() { ImageIcon icon = StatusIcons.getStatusIcon(status); StatusButton.this.setIcon(icon); String sid = null; switch (status) { case Presence.AVAILABLE: sid = "Available"; break; case Presence.FREE_FOR_CHAT: sid = "FreeforChat"; break; case Presence.AWAY: sid = "Away"; break; case Presence.XA: sid = "XA"; break; case Presence.DND: sid = "DND"; break; case Presence.UNAVAILABLE: sid = "Offline"; break; case Presence.INVISIBLE: sid = "Invisible"; break; } I18N.setTextAndMnemonic("main.main.presencebutton." + sid, StatusButton.this); txtStatus.setText(message); } }; SwingUtilities.invokeLater(updateAComponent); }