SPARK-1235, added Functions to CTRL-E and CTRL-T dialogs

use SwingUtilities.isRightMouseButton rather than MouseEvent.Button3 (are there still people without scrollwheel around?)

reformatting SysTrayPlugin.java, to prevent eye-cancer

added leftclick to ReconnectPanelSmall


adding new Locale Strings for CTRL-E and CTRL-T:
label.recent.conversation = Recent Conversations
label.frequent.contacts = Frequent Contacts


git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12171 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Wolf Posdorfer
2011-03-24 09:13:27 +00:00
committed by wolf.posdorfer
parent ae2870d869
commit 1de57b7ecd
9 changed files with 415 additions and 364 deletions

View File

@ -41,6 +41,7 @@ import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Component;
@ -422,7 +423,7 @@ public class UserManager {
contactField.getList().addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if(e.getButton() == MouseEvent.BUTTON3)
if(SwingUtilities.isRightMouseButton(e))
{
contactField.setSelectetIndex(e);
ContactItem item = contactField.getSelectedContactItem();

View File

@ -310,8 +310,7 @@ public class JContactItemField extends JPanel {
*/
public void setSelectetIndex(MouseEvent mouseevent)
{
Point p = mouseevent.getPoint();
list.setSelectedIndex(list.locationToIndex(p));
list.setSelectedIndex(list.locationToIndex(mouseevent.getPoint()));
}

View File

@ -1526,6 +1526,7 @@ public final class ContactList extends JPanel implements ActionListener,
*
* @param e the MouseEvent
* @param item the ContactItem
* @param component the owning component
*/
public void showPopup(Component component, MouseEvent e, final ContactItem item) {
if (item.getJID() == null) {

View File

@ -25,11 +25,11 @@ import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.TimerTask;
import java.util.Vector;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
@ -87,7 +87,9 @@ public class ReconnectPanelSmall extends ContactGroup implements
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3) {
if (SwingUtilities.isLeftMouseButton(e)) {
reconnect();
} else if (SwingUtilities.isRightMouseButton(e)) {
int x = e.getX();
int y = e.getY();

View File

@ -19,6 +19,7 @@
*/
package org.jivesoftware.sparkimpl.plugin.history;
import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.util.StringUtils;
@ -65,6 +66,7 @@ import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.ListCellRenderer;
import javax.swing.SwingUtilities;
/**
* Allows users to see the last 10 people they have talked with.
@ -94,7 +96,7 @@ public class ConversationHistoryPlugin implements Plugin {
final JPanel mainPanel = new JPanel(new BorderLayout());
final JLabel titleLabel = new JLabel("Recent Conversations");
final JLabel titleLabel = new JLabel(Res.getString("label.recent.conversation"));
titleLabel.setFont(new Font("Dialog", Font.BOLD, 11));
titleLabel.setHorizontalAlignment(JLabel.CENTER);
mainPanel.add(titleLabel, BorderLayout.NORTH);
@ -104,19 +106,33 @@ public class ConversationHistoryPlugin implements Plugin {
window.add(mainPanel);
// Add Listeners
contacts.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
final JLabel label = (JLabel) contacts.getSelectedValue();
String user = jidMap.get(label);
if (user != null) {
final String contactUsername = SparkManager.getUserManager().getUserNicknameFromJID(user);
SparkManager.getChatManager().activateChat(user, contactUsername);
window.dispose();
}
}
}
});
contacts.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
contacts.setSelectedIndex(contacts.locationToIndex(e
.getPoint()));
String user = jidMap.get((JLabel) contacts
.getSelectedValue());
ContactItem contact = SparkManager.getContactList()
.getContactItemByJID(user);
SparkManager.getContactList().showPopup(contacts, e,
contact);
}
if (e.getClickCount() == 2) {
final JLabel label = (JLabel) contacts.getSelectedValue();
String user = jidMap.get(label);
if (user != null) {
final String contactUsername = SparkManager
.getUserManager().getUserNicknameFromJID(user);
SparkManager.getChatManager().activateChat(user,
contactUsername);
window.dispose();
}
}
}
});
contacts.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {

View File

@ -19,6 +19,7 @@
*/
package org.jivesoftware.sparkimpl.plugin.history;
import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.plugin.Plugin;
@ -55,6 +56,7 @@ import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.ListCellRenderer;
import javax.swing.SwingUtilities;
/**
* Adds a simple feature to list your most "Popular" contacts. Popular contacts is basically who
@ -80,7 +82,7 @@ public class FrequentContactsPlugin implements Plugin {
final JPanel mainPanel = new JPanel(new BorderLayout());
final JLabel titleLabel = new JLabel("Frequent Contacts");
final JLabel titleLabel = new JLabel(Res.getString("label.frequent.contacts"));
titleLabel.setFont(new Font("Dialog", Font.BOLD, 11));
titleLabel.setHorizontalAlignment(JLabel.CENTER);
mainPanel.add(titleLabel, BorderLayout.NORTH);
@ -90,19 +92,33 @@ public class FrequentContactsPlugin implements Plugin {
window.add(mainPanel);
// Add Listeners
contacts.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
final JLabel label = (JLabel) contacts.getSelectedValue();
String user = jidMap.get(label);
if (user != null) {
final String contactUsername = SparkManager.getUserManager().getUserNicknameFromJID(user);
SparkManager.getChatManager().activateChat(user, contactUsername);
window.dispose();
}
}
}
});
contacts.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
contacts.setSelectedIndex(contacts.locationToIndex(e
.getPoint()));
String user = jidMap.get((JLabel) contacts
.getSelectedValue());
ContactItem contact = SparkManager.getContactList()
.getContactItemByJID(user);
SparkManager.getContactList().showPopup(contacts, e,
contact);
}
if (e.getClickCount() == 2) {
final JLabel label = (JLabel) contacts.getSelectedValue();
String user = jidMap.get(label);
if (user != null) {
final String contactUsername = SparkManager
.getUserManager().getUserNicknameFromJID(user);
SparkManager.getChatManager().activateChat(user,
contactUsername);
window.dispose();
}
}
}
});
contacts.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {

View File

@ -52,383 +52,395 @@ import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotificationListener {
private JPopupMenu popupMenu = new JPopupMenu();
public class SysTrayPlugin implements Plugin, NativeHandler,
MessageEventNotificationListener {
private JPopupMenu popupMenu = new JPopupMenu();
private JMenuItem openMenu;
private JMenuItem minimizeMenu;
private JMenuItem exitMenu;
private JMenu statusMenu;
private JMenuItem logoutMenu;
private JMenuItem openMenu;
private JMenuItem minimizeMenu;
private JMenuItem exitMenu;
private JMenu statusMenu;
private JMenuItem logoutMenu;
private LocalPreferences pref = SettingsManager.getLocalPreferences();
private ImageIcon availableIcon;
private ImageIcon dndIcon;
private ImageIcon awayIcon;
private LocalPreferences pref = SettingsManager.getLocalPreferences();
private ImageIcon availableIcon;
private ImageIcon dndIcon;
private ImageIcon awayIcon;
private ImageIcon offlineIcon;
private ImageIcon connectingIcon;
private ImageIcon newMessageIcon;
private ImageIcon typingIcon;
private TrayIcon trayIcon;
private ImageIcon newMessageIcon;
private ImageIcon typingIcon;
private TrayIcon trayIcon;
@Override
public boolean canShutDown() {
return true;
}
public boolean canShutDown() {
return true;
}
@Override
public void initialize() {
public void initialize() {
if (SystemTray.isSupported()) {
if (SystemTray.isSupported()) {
openMenu = new JMenuItem(Res.getString("menuitem.open"));
minimizeMenu = new JMenuItem(Res.getString("menuitem.hide"));
exitMenu = new JMenuItem(Res.getString("menuitem.exit"));
statusMenu = new JMenu(Res.getString("menuitem.status"));
logoutMenu = new JMenuItem(Res.getString("menuitem.logout.no.status"));
openMenu = new JMenuItem(Res.getString("menuitem.open"));
minimizeMenu = new JMenuItem(Res.getString("menuitem.hide"));
exitMenu = new JMenuItem(Res.getString("menuitem.exit"));
statusMenu = new JMenu(Res.getString("menuitem.status"));
logoutMenu = new JMenuItem(
Res.getString("menuitem.logout.no.status"));
SystemTray tray = SystemTray.getSystemTray();
SparkManager.getNativeManager().addNativeHandler(this);
SparkManager.getMessageEventManager().addMessageEventNotificationListener(this);
SystemTray tray = SystemTray.getSystemTray();
SparkManager.getNativeManager().addNativeHandler(this);
SparkManager.getMessageEventManager()
.addMessageEventNotificationListener(this);
if ( Spark.isLinux() ) {
newMessageIcon = SparkRes.getImageIcon(SparkRes.MESSAGE_NEW_TRAY_LINUX);
typingIcon = SparkRes.getImageIcon(SparkRes.TYPING_TRAY_LINUX);
} else {
newMessageIcon = SparkRes.getImageIcon(SparkRes.MESSAGE_NEW_TRAY);
typingIcon = SparkRes.getImageIcon(SparkRes.TYPING_TRAY);
}
if (Spark.isLinux()) {
newMessageIcon = SparkRes
.getImageIcon(SparkRes.MESSAGE_NEW_TRAY_LINUX);
typingIcon = SparkRes.getImageIcon(SparkRes.TYPING_TRAY_LINUX);
} else {
newMessageIcon = SparkRes
.getImageIcon(SparkRes.MESSAGE_NEW_TRAY);
typingIcon = SparkRes.getImageIcon(SparkRes.TYPING_TRAY);
}
availableIcon = Default.getImageIcon(Default.TRAY_IMAGE);
if ( Spark.isLinux() ) {
if (availableIcon == null) {
availableIcon = SparkRes.getImageIcon(SparkRes.TRAY_IMAGE_LINUX);
Log.error(availableIcon.toString());
}
awayIcon = SparkRes.getImageIcon(SparkRes.TRAY_AWAY_LINUX);
dndIcon = SparkRes.getImageIcon(SparkRes.TRAY_DND_LINUX);
offlineIcon = SparkRes.getImageIcon(SparkRes.TRAY_OFFLINE_LINUX);
connectingIcon = SparkRes.getImageIcon(SparkRes.TRAY_CONNECTING_LINUX);
} else {
if (availableIcon == null) {
availableIcon = SparkRes.getImageIcon(SparkRes.TRAY_IMAGE);
}
awayIcon = SparkRes.getImageIcon(SparkRes.TRAY_AWAY);
dndIcon = SparkRes.getImageIcon(SparkRes.TRAY_DND);
offlineIcon = SparkRes.getImageIcon(SparkRes.TRAY_OFFLINE);
connectingIcon = SparkRes.getImageIcon(SparkRes.TRAY_CONNECTING);
}
availableIcon = Default.getImageIcon(Default.TRAY_IMAGE);
if (Spark.isLinux()) {
if (availableIcon == null) {
availableIcon = SparkRes
.getImageIcon(SparkRes.TRAY_IMAGE_LINUX);
Log.error(availableIcon.toString());
}
awayIcon = SparkRes.getImageIcon(SparkRes.TRAY_AWAY_LINUX);
dndIcon = SparkRes.getImageIcon(SparkRes.TRAY_DND_LINUX);
offlineIcon = SparkRes
.getImageIcon(SparkRes.TRAY_OFFLINE_LINUX);
connectingIcon = SparkRes
.getImageIcon(SparkRes.TRAY_CONNECTING_LINUX);
} else {
if (availableIcon == null) {
availableIcon = SparkRes.getImageIcon(SparkRes.TRAY_IMAGE);
}
awayIcon = SparkRes.getImageIcon(SparkRes.TRAY_AWAY);
dndIcon = SparkRes.getImageIcon(SparkRes.TRAY_DND);
offlineIcon = SparkRes.getImageIcon(SparkRes.TRAY_OFFLINE);
connectingIcon = SparkRes
.getImageIcon(SparkRes.TRAY_CONNECTING);
}
popupMenu.add(openMenu);
openMenu.addActionListener(new AbstractAction() {
popupMenu.add(openMenu);
openMenu.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent event) {
SparkManager.getMainWindow().setVisible(true);
SparkManager.getMainWindow().toFront();
}
@Override
public void actionPerformed(ActionEvent event) {
SparkManager.getMainWindow().setVisible(true);
SparkManager.getMainWindow().toFront();
}
});
popupMenu.add(minimizeMenu);
minimizeMenu.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
});
popupMenu.add(minimizeMenu);
minimizeMenu.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent event) {
SparkManager.getMainWindow().setVisible(false);
}
});
popupMenu.addSeparator();
addStatusMessages();
popupMenu.add(statusMenu);
statusMenu.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent event) {
SparkManager.getMainWindow().setVisible(false);
}
});
popupMenu.addSeparator();
addStatusMessages();
popupMenu.add(statusMenu);
statusMenu.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent event) {
@Override
public void actionPerformed(ActionEvent event) {
}
});
}
});
if (Spark.isWindows()) {
if(!Default.getBoolean("DISABLE_EXIT"))
popupMenu.add(logoutMenu);
if (Spark.isWindows()) {
if (!Default.getBoolean("DISABLE_EXIT"))
popupMenu.add(logoutMenu);
logoutMenu.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
logoutMenu.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent e) {
SparkManager.getMainWindow().logout(false);
}
});
@Override
public void actionPerformed(ActionEvent e) {
SparkManager.getMainWindow().logout(false);
}
});
}
// Exit Menu
exitMenu.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent e) {
SparkManager.getMainWindow().shutdown();
}
});
if (!Default.getBoolean("DISABLE_EXIT"))
popupMenu.add(exitMenu);
/**
* If connection closed set offline tray image
*/
SparkManager.getConnection().addConnectionListener(
new ConnectionListener() {
@Override
public void connectionClosed() {
trayIcon.setImage(offlineIcon.getImage());
}
// Exit Menu
exitMenu.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent e) {
SparkManager.getMainWindow().shutdown();
}
});
if(!Default.getBoolean("DISABLE_EXIT"))
popupMenu.add(exitMenu);
/**
* If connection closed set offline tray image
*/
SparkManager.getConnection().addConnectionListener(new ConnectionListener() {
@Override
public void connectionClosed() {
trayIcon.setImage(offlineIcon.getImage());
}
@Override
public void connectionClosedOnError(Exception arg0) {
trayIcon.setImage(offlineIcon.getImage());
}
@Override
public void reconnectingIn(int arg0) {
trayIcon.setImage(connectingIcon.getImage());
}
@Override
public void reconnectionSuccessful() {
trayIcon.setImage(availableIcon.getImage());
}
@Override
public void reconnectionFailed(Exception arg0) {
trayIcon.setImage(offlineIcon.getImage());
}
});
SparkManager.getSessionManager().addPresenceListener(new PresenceListener() {
@Override
public void presenceChanged(Presence presence) {
if (presence.getMode() == Presence.Mode.available) {
trayIcon.setImage(availableIcon.getImage());
} else if (presence.getMode() == Presence.Mode.away || presence.getMode() == Presence.Mode.xa) {
trayIcon.setImage(awayIcon.getImage());
} else if (presence.getMode() == Presence.Mode.dnd) {
trayIcon.setImage(dndIcon.getImage());
} else {
trayIcon.setImage(availableIcon.getImage());
}
}
});
try {
trayIcon = new TrayIcon(availableIcon.getImage(), Default.getString(Default.APPLICATION_NAME), null);
trayIcon.setImageAutoSize(true);
trayIcon.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent event) {
if (event.getButton() == MouseEvent.BUTTON1
&& event.getClickCount() == 1) {
if (SparkManager.getMainWindow().isVisible()) {
SparkManager.getMainWindow().setVisible(false);
} else {
SparkManager.getMainWindow().setVisible(true);
SparkManager.getMainWindow().toFront();
}
} else if (event.getButton() == MouseEvent.BUTTON1) {
SparkManager.getMainWindow().toFront();
// SparkManager.getMainWindow().requestFocus();
} else if (event.getButton() == MouseEvent.BUTTON3) {
popupMenu.setLocation(event.getX(), event.getY());
popupMenu.setInvoker(popupMenu);
popupMenu.setVisible(true);
}
}
@Override
public void mouseEntered(MouseEvent event) {
}
@Override
public void mouseExited(MouseEvent event) {
}
@Override
public void mousePressed(MouseEvent event) {
}
@Override
public void mouseReleased(MouseEvent event) {
}
});
tray.add(trayIcon);
} catch (Exception e) {
// Not Supported
@Override
public void connectionClosedOnError(Exception arg0) {
trayIcon.setImage(offlineIcon.getImage());
}
} else {
Log.error("Tray don't supports on this platform.");
}
@Override
public void reconnectingIn(int arg0) {
trayIcon.setImage(connectingIcon.getImage());
}
@Override
public void reconnectionSuccessful() {
trayIcon.setImage(availableIcon.getImage());
}
@Override
public void reconnectionFailed(Exception arg0) {
trayIcon.setImage(offlineIcon.getImage());
}
});
SparkManager.getSessionManager().addPresenceListener(
new PresenceListener() {
@Override
public void presenceChanged(Presence presence) {
if (presence.getMode() == Presence.Mode.available) {
trayIcon.setImage(availableIcon.getImage());
} else if (presence.getMode() == Presence.Mode.away
|| presence.getMode() == Presence.Mode.xa) {
trayIcon.setImage(awayIcon.getImage());
} else if (presence.getMode() == Presence.Mode.dnd) {
trayIcon.setImage(dndIcon.getImage());
} else {
trayIcon.setImage(availableIcon.getImage());
}
}
});
try {
trayIcon = new TrayIcon(availableIcon.getImage(),
Default.getString(Default.APPLICATION_NAME), null);
trayIcon.setImageAutoSize(true);
trayIcon.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent event) {
if (event.getButton() == MouseEvent.BUTTON1
&& event.getClickCount() == 1) {
if (SparkManager.getMainWindow().isVisible()) {
SparkManager.getMainWindow().setVisible(false);
} else {
SparkManager.getMainWindow().setVisible(true);
SparkManager.getMainWindow().toFront();
}
} else if (event.getButton() == MouseEvent.BUTTON1) {
SparkManager.getMainWindow().toFront();
// SparkManager.getMainWindow().requestFocus();
} else if (event.getButton() == MouseEvent.BUTTON3) {
popupMenu.setLocation(event.getX(), event.getY());
popupMenu.setInvoker(popupMenu);
popupMenu.setVisible(true);
}
}
@Override
public void mouseEntered(MouseEvent event) {
}
@Override
public void mouseExited(MouseEvent event) {
}
@Override
public void mousePressed(MouseEvent event) {
}
@Override
public void mouseReleased(MouseEvent event) {
}
});
tray.add(trayIcon);
} catch (Exception e) {
// Not Supported
}
} else {
Log.error("Tray don't supports on this platform.");
}
}
public void addStatusMessages() {
StatusBar statusBar = SparkManager.getWorkspace().getStatusBar();
for (Object o : statusBar.getStatusList()) {
final StatusItem statusItem = (StatusItem) o;
public void addStatusMessages() {
StatusBar statusBar = SparkManager.getWorkspace().getStatusBar();
for (Object o : statusBar.getStatusList()) {
final StatusItem statusItem = (StatusItem) o;
final AbstractAction action = new AbstractAction() {
private static final long serialVersionUID = 1L;
final AbstractAction action = new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent e) {
@Override
public void actionPerformed(ActionEvent e) {
StatusBar statusBar = SparkManager.getWorkspace()
.getStatusBar();
StatusBar statusBar = SparkManager.getWorkspace()
.getStatusBar();
SparkManager.getSessionManager().changePresence(
statusItem.getPresence());
statusBar.setStatus(statusItem.getText());
}
SparkManager.getSessionManager().changePresence(
statusItem.getPresence());
statusBar.setStatus(statusItem.getText());
}
};
action.putValue(Action.NAME, statusItem.getText());
action.putValue(Action.SMALL_ICON, statusItem.getIcon());
boolean hasChildren = false;
for (Object aCustom : SparkManager.getWorkspace().getStatusBar()
.getCustomStatusList()) {
final CustomStatusItem cItem = (CustomStatusItem) aCustom;
String type = cItem.getType();
if (type.equals(statusItem.getText())) {
hasChildren = true;
}
}
if (!hasChildren) {
JMenuItem status = new JMenuItem(action);
statusMenu.add(status);
} else {
final JMenu status = new JMenu(action);
statusMenu.add(status);
status.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent mouseEvent) {
action.actionPerformed(null);
popupMenu.setVisible(false);
}
});
for (Object aCustom : SparkManager.getWorkspace()
.getStatusBar().getCustomStatusList()) {
final CustomStatusItem customItem = (CustomStatusItem) aCustom;
String type = customItem.getType();
if (type.equals(statusItem.getText())) {
AbstractAction customAction = new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent e) {
StatusBar statusBar = SparkManager
.getWorkspace().getStatusBar();
Presence oldPresence = statusItem.getPresence();
Presence presence = StatusBar
.copyPresence(oldPresence);
presence.setStatus(customItem.getStatus());
presence.setPriority(customItem.getPriority());
SparkManager.getSessionManager()
.changePresence(presence);
statusBar.setStatus(statusItem.getName()
+ " - " + customItem.getStatus());
}
};
action.putValue(Action.NAME, statusItem.getText());
action.putValue(Action.SMALL_ICON, statusItem.getIcon());
boolean hasChildren = false;
for (Object aCustom : SparkManager.getWorkspace().getStatusBar()
.getCustomStatusList()) {
final CustomStatusItem cItem = (CustomStatusItem) aCustom;
String type = cItem.getType();
if (type.equals(statusItem.getText())) {
hasChildren = true;
}
}
if (!hasChildren) {
JMenuItem status = new JMenuItem(action);
statusMenu.add(status);
} else {
final JMenu status = new JMenu(action);
statusMenu.add(status);
status.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent mouseEvent) {
action.actionPerformed(null);
popupMenu.setVisible(false);
}
});
for (Object aCustom : SparkManager.getWorkspace()
.getStatusBar().getCustomStatusList()) {
final CustomStatusItem customItem = (CustomStatusItem) aCustom;
String type = customItem.getType();
if (type.equals(statusItem.getText())) {
AbstractAction customAction = new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent e) {
StatusBar statusBar = SparkManager
.getWorkspace().getStatusBar();
Presence oldPresence = statusItem.getPresence();
Presence presence = StatusBar
.copyPresence(oldPresence);
presence.setStatus(customItem.getStatus());
presence.setPriority(customItem.getPriority());
SparkManager.getSessionManager()
.changePresence(presence);
statusBar.setStatus(statusItem.getName()
+ " - " + customItem.getStatus());
}
};
customAction.putValue(Action.NAME, customItem.getStatus());
customAction.putValue(Action.SMALL_ICON, statusItem.getIcon());
JMenuItem menuItem = new JMenuItem(customAction);
status.add(menuItem);
}
}
}
customAction.putValue(Action.NAME,
customItem.getStatus());
customAction.putValue(Action.SMALL_ICON,
statusItem.getIcon());
JMenuItem menuItem = new JMenuItem(customAction);
status.add(menuItem);
}
}
}
}
}
@Override
public void shutdown() {
if (SystemTray.isSupported()) {
SystemTray tray = SystemTray.getSystemTray();
tray.remove(trayIcon);
}
public void shutdown() {
if (SystemTray.isSupported()) {
SystemTray tray = SystemTray.getSystemTray();
tray.remove(trayIcon);
}
}
@Override
public void uninstall() {
public void uninstall() {
}
// Info on new Messages
@Override
public void flashWindow(Window window) {
if (pref.isSystemTrayNotificationEnabled()) {
trayIcon.setImage(newMessageIcon.getImage());
}
}
// Info on new Messages
@Override
public void flashWindow(Window window) {
if (pref.isSystemTrayNotificationEnabled())
{
trayIcon.setImage(newMessageIcon.getImage());
}
@Override
public void flashWindowStopWhenFocused(Window window) {
trayIcon.setImage(availableIcon.getImage());
}
@Override
public boolean handleNotification() {
return true;
}
@Override
public void stopFlashing(Window window) {
trayIcon.setImage(availableIcon.getImage());
}
// For Typing
@Override
public void cancelledNotification(String from, String packetID) {
trayIcon.setImage(availableIcon.getImage());
}
@Override
public void composingNotification(String from, String packetID) {
if (pref.isTypingNotificationShown()) {
trayIcon.setImage(typingIcon.getImage());
}
}
@Override
public void flashWindowStopWhenFocused(Window window) {
trayIcon.setImage(availableIcon.getImage());
}
@Override
public void deliveredNotification(String from, String packetID) {
// Nothing
}
@Override
public boolean handleNotification() {
return true;
}
@Override
public void displayedNotification(String from, String packetID) {
// Nothing
}
@Override
public void stopFlashing(Window window) {
trayIcon.setImage(availableIcon.getImage());
}
// For Typing
@Override
public void cancelledNotification(String from, String packetID) {
trayIcon.setImage(availableIcon.getImage());
}
@Override
public void composingNotification(String from, String packetID) {
if (pref.isTypingNotificationShown()) {
trayIcon.setImage(typingIcon.getImage());
}
}
@Override
public void deliveredNotification(String from, String packetID) {
// Nothing
}
@Override
public void displayedNotification(String from, String packetID) {
// Nothing
}
@Override
public void offlineNotification(String from, String packetID) {
// Nothing
}
@Override
public void offlineNotification(String from, String packetID) {
// Nothing
}
}

View File

@ -394,6 +394,8 @@ label.company = Company
label.confirm.password = &Confirm password
label.conflict.error = Unable to login due to account already signed in
label.contact.to.find = Find contact
label.recent.conversation = Recent Conversations
label.frequent.contacts = Frequent Contacts
label.contactlist.avatarsize = Contact list avatar &size:
label.contactlist.fontsize = &Contact List font size:
label.country = Country

View File

@ -261,7 +261,9 @@ label.transfer.download.directory = &Download Verzeichnis:
label.find = &Finden
label.rename.to = Umbenennen zu
label.contact.to.find = Kontakt finden?
label.available.users.in.roster = &Verf<72>gbare Teilnehmer in der Kontaktliste
label.recent.conversation = K<EFBFBD>rzliche Konversationen
label.frequent.contacts = Meistgenutzte Kontakte
label.available.users.in.roster = &Verf<72>gbare Teilnehmer in der Kontaktliste
label.time = Zeit: {0}
label.add.conference.service = &Service f<>r Konferenzen hinzuf<75>gen
label.add.jid = &JID hinzuf<75>gen