mirror of
https://github.com/Mibew/i18n.git
synced 2025-02-02 17:44:42 +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.SystemTray;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.TrayIcon;
|
import java.awt.TrayIcon;
|
||||||
|
import java.awt.TrayIcon.MessageType;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
import org.mibew.api.MibewAgent;
|
import org.mibew.api.MibewAgent;
|
||||||
import org.mibew.api.MibewAgentListener;
|
import org.mibew.api.MibewAgentListener;
|
||||||
@ -24,6 +24,7 @@ public class TrayNotifier extends MibewAgentListener {
|
|||||||
|
|
||||||
private Image online;
|
private Image online;
|
||||||
private Image offline;
|
private Image offline;
|
||||||
|
private ActionListener fExit;
|
||||||
|
|
||||||
public TrayNotifier() {
|
public TrayNotifier() {
|
||||||
}
|
}
|
||||||
@ -34,20 +35,20 @@ public class TrayNotifier extends MibewAgentListener {
|
|||||||
SystemTray tray = SystemTray.getSystemTray();
|
SystemTray tray = SystemTray.getSystemTray();
|
||||||
online = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("tray_on.png"));
|
online = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("tray_on.png"));
|
||||||
offline = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("tray_off.png"));
|
offline = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("tray_off.png"));
|
||||||
|
fExit = new ActionListener() {
|
||||||
PopupMenu popup = new PopupMenu();
|
|
||||||
MenuItem exitItem = new MenuItem("Exit", new MenuShortcut(KeyEvent.VK_X));
|
|
||||||
exitItem.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if(agent != null) {
|
if(agent != null) {
|
||||||
agent.stop();
|
agent.stop();
|
||||||
}
|
}
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
popup.add(exitItem);
|
PopupMenu pm = new PopupMenu();
|
||||||
trayIcon = new TrayIcon(offline, "Mibew Notifier", popup);
|
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);
|
trayIcon.setImageAutoSize(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -69,6 +70,24 @@ public class TrayNotifier extends MibewAgentListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updated(MibewThread[] all, MibewThread[] created) {
|
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) {
|
public void setAgent(MibewAgent agent) {
|
||||||
|
Loading…
Reference in New Issue
Block a user