mirror of
https://github.com/Mibew/i18n.git
synced 2025-02-02 09:34:41 +03:00
menu with visitors list, info
git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@733 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
parent
e453ed2757
commit
ecb7d3643f
@ -8,10 +8,10 @@ import java.awt.PopupMenu;
|
||||
import java.awt.SystemTray;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.TrayIcon.MessageType;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.net.URL;
|
||||
|
||||
import org.mibew.api.MibewAgent;
|
||||
import org.mibew.api.MibewAgentListener;
|
||||
@ -24,6 +24,7 @@ public class TrayNotifier extends MibewAgentListener {
|
||||
|
||||
private Image online;
|
||||
private Image offline;
|
||||
private ActionListener fExit;
|
||||
|
||||
public TrayNotifier() {
|
||||
}
|
||||
@ -34,20 +35,20 @@ public class TrayNotifier extends MibewAgentListener {
|
||||
SystemTray tray = SystemTray.getSystemTray();
|
||||
online = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("tray_on.png"));
|
||||
offline = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("tray_off.png"));
|
||||
|
||||
PopupMenu popup = new PopupMenu();
|
||||
MenuItem exitItem = new MenuItem("Exit", new MenuShortcut(KeyEvent.VK_X));
|
||||
exitItem.addActionListener(new ActionListener() {
|
||||
fExit = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(agent != null) {
|
||||
agent.stop();
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
popup.add(exitItem);
|
||||
trayIcon = new TrayIcon(offline, "Mibew Notifier", popup);
|
||||
PopupMenu pm = new PopupMenu();
|
||||
MenuItem exitItem = new MenuItem("Exit", new MenuShortcut(KeyEvent.VK_X));
|
||||
exitItem.addActionListener(fExit);
|
||||
pm.add(exitItem);
|
||||
trayIcon = new TrayIcon(offline, "Mibew Notifier", pm);
|
||||
trayIcon.setImageAutoSize(true);
|
||||
|
||||
try {
|
||||
@ -69,6 +70,24 @@ public class TrayNotifier extends MibewAgentListener {
|
||||
|
||||
@Override
|
||||
protected void updated(MibewThread[] all, MibewThread[] created) {
|
||||
PopupMenu pm = new PopupMenu();
|
||||
for(MibewThread mt : all) {
|
||||
MenuItem mi = new MenuItem(mt.fClientName);
|
||||
pm.add(mi);
|
||||
}
|
||||
if(all.length > 0) {
|
||||
pm.addSeparator();
|
||||
}
|
||||
MenuItem exitItem = new MenuItem("Exit", new MenuShortcut(KeyEvent.VK_X));
|
||||
exitItem.addActionListener(fExit);
|
||||
pm.add(exitItem);
|
||||
trayIcon.setPopupMenu(pm);
|
||||
|
||||
if(created.length == 1) {
|
||||
trayIcon.displayMessage("New visitor", created[0].fClientName + "\n" + created[0].fFirstMessage, MessageType.INFO);
|
||||
} else if(created.length > 1) {
|
||||
trayIcon.displayMessage("New visitors", "New " + created.length + " visitors", MessageType.INFO);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAgent(MibewAgent agent) {
|
||||
|
Loading…
Reference in New Issue
Block a user