diff --git a/src/java/org/jivesoftware/spark/UserManager.java b/src/java/org/jivesoftware/spark/UserManager.java index 284011de..7b4440d1 100644 --- a/src/java/org/jivesoftware/spark/UserManager.java +++ b/src/java/org/jivesoftware/spark/UserManager.java @@ -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(); diff --git a/src/java/org/jivesoftware/spark/component/JContactItemField.java b/src/java/org/jivesoftware/spark/component/JContactItemField.java index 87020370..1cadd596 100644 --- a/src/java/org/jivesoftware/spark/component/JContactItemField.java +++ b/src/java/org/jivesoftware/spark/component/JContactItemField.java @@ -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())); } diff --git a/src/java/org/jivesoftware/spark/ui/ContactList.java b/src/java/org/jivesoftware/spark/ui/ContactList.java index 365c253f..68ec2171 100644 --- a/src/java/org/jivesoftware/spark/ui/ContactList.java +++ b/src/java/org/jivesoftware/spark/ui/ContactList.java @@ -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) { diff --git a/src/java/org/jivesoftware/spark/ui/ReconnectPanelSmall.java b/src/java/org/jivesoftware/spark/ui/ReconnectPanelSmall.java index aaa9b081..d811a68c 100644 --- a/src/java/org/jivesoftware/spark/ui/ReconnectPanelSmall.java +++ b/src/java/org/jivesoftware/spark/ui/ReconnectPanelSmall.java @@ -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(); diff --git a/src/java/org/jivesoftware/sparkimpl/plugin/history/ConversationHistoryPlugin.java b/src/java/org/jivesoftware/sparkimpl/plugin/history/ConversationHistoryPlugin.java index 45a4d515..38d5c94e 100644 --- a/src/java/org/jivesoftware/sparkimpl/plugin/history/ConversationHistoryPlugin.java +++ b/src/java/org/jivesoftware/sparkimpl/plugin/history/ConversationHistoryPlugin.java @@ -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) { diff --git a/src/java/org/jivesoftware/sparkimpl/plugin/history/FrequentContactsPlugin.java b/src/java/org/jivesoftware/sparkimpl/plugin/history/FrequentContactsPlugin.java index dc17c7f3..b8e262ae 100644 --- a/src/java/org/jivesoftware/sparkimpl/plugin/history/FrequentContactsPlugin.java +++ b/src/java/org/jivesoftware/sparkimpl/plugin/history/FrequentContactsPlugin.java @@ -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) { diff --git a/src/java/org/jivesoftware/sparkimpl/plugin/systray/SysTrayPlugin.java b/src/java/org/jivesoftware/sparkimpl/plugin/systray/SysTrayPlugin.java index ca03662a..44ce644c 100644 --- a/src/java/org/jivesoftware/sparkimpl/plugin/systray/SysTrayPlugin.java +++ b/src/java/org/jivesoftware/sparkimpl/plugin/systray/SysTrayPlugin.java @@ -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(); - - private JMenuItem openMenu; - private JMenuItem minimizeMenu; - private JMenuItem exitMenu; - private JMenu statusMenu; - private JMenuItem logoutMenu; +public class SysTrayPlugin implements Plugin, NativeHandler, + MessageEventNotificationListener { + private JPopupMenu popupMenu = new JPopupMenu(); - private LocalPreferences pref = SettingsManager.getLocalPreferences(); - private ImageIcon availableIcon; - private ImageIcon dndIcon; - private ImageIcon awayIcon; + 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 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); - } - - 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() { + 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); + } - private static final long serialVersionUID = 1L; + 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); + } - @Override - public void actionPerformed(ActionEvent event) { - SparkManager.getMainWindow().setVisible(true); - SparkManager.getMainWindow().toFront(); - } + popupMenu.add(openMenu); + openMenu.addActionListener(new AbstractAction() { - }); - popupMenu.add(minimizeMenu); - minimizeMenu.addActionListener(new AbstractAction() { - private static final long serialVersionUID = 1L; + 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(true); + SparkManager.getMainWindow().toFront(); + } - @Override - public void actionPerformed(ActionEvent event) { + }); + 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; - if (Spark.isWindows()) { - if(!Default.getBoolean("DISABLE_EXIT")) - popupMenu.add(logoutMenu); - - logoutMenu.addActionListener(new AbstractAction() { - private static final long serialVersionUID = 1L; + @Override + public void actionPerformed(ActionEvent event) { - @Override - public void actionPerformed(ActionEvent e) { - SparkManager.getMainWindow().logout(false); - } - }); + } + }); + + if (Spark.isWindows()) { + if (!Default.getBoolean("DISABLE_EXIT")) + popupMenu.add(logoutMenu); + + logoutMenu.addActionListener(new AbstractAction() { + private static final long serialVersionUID = 1L; + + @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 void flashWindowStopWhenFocused(Window window) { + trayIcon.setImage(availableIcon.getImage()); + } - @Override - public boolean handleNotification() { - return true; - } + @Override + public boolean handleNotification() { + return true; + } - @Override - public void stopFlashing(Window window) { - trayIcon.setImage(availableIcon.getImage()); - } + @Override + public void stopFlashing(Window window) { + trayIcon.setImage(availableIcon.getImage()); + } - - // For Typing - @Override - public void cancelledNotification(String from, String packetID) { - 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 composingNotification(String from, String packetID) { + if (pref.isTypingNotificationShown()) { + trayIcon.setImage(typingIcon.getImage()); } + } - @Override - public void deliveredNotification(String from, String packetID) { - // Nothing - } + @Override + public void deliveredNotification(String from, String packetID) { + // Nothing + } - @Override - public void displayedNotification(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 + } } diff --git a/src/resources/i18n/spark_i18n.properties b/src/resources/i18n/spark_i18n.properties index aa00fd3d..bf5fc165 100644 --- a/src/resources/i18n/spark_i18n.properties +++ b/src/resources/i18n/spark_i18n.properties @@ -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 diff --git a/src/resources/i18n/spark_i18n_de.properties b/src/resources/i18n/spark_i18n_de.properties index 51d82269..eedcee94 100644 --- a/src/resources/i18n/spark_i18n_de.properties +++ b/src/resources/i18n/spark_i18n_de.properties @@ -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ügbare Teilnehmer in der Kontaktliste +label.recent.conversation = Kürzliche Konversationen +label.frequent.contacts = Meistgenutzte Kontakte +label.available.users.in.roster = &Verfügbare Teilnehmer in der Kontaktliste label.time = Zeit: {0} label.add.conference.service = &Service für Konferenzen hinzufügen label.add.jid = &JID hinzufügen