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

View File

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

View File

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

View File

@ -25,11 +25,11 @@ import java.awt.event.ActionListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.Vector;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import org.jivesoftware.resource.Res; import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes; import org.jivesoftware.resource.SparkRes;
@ -87,7 +87,9 @@ public class ReconnectPanelSmall extends ContactGroup implements
@Override @Override
public void mouseClicked(MouseEvent e) { 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 x = e.getX();
int y = e.getY(); int y = e.getY();

View File

@ -19,6 +19,7 @@
*/ */
package org.jivesoftware.sparkimpl.plugin.history; package org.jivesoftware.sparkimpl.plugin.history;
import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes; import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
@ -65,6 +66,7 @@ import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import javax.swing.ListCellRenderer; import javax.swing.ListCellRenderer;
import javax.swing.SwingUtilities;
/** /**
* Allows users to see the last 10 people they have talked with. * 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 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.setFont(new Font("Dialog", Font.BOLD, 11));
titleLabel.setHorizontalAlignment(JLabel.CENTER); titleLabel.setHorizontalAlignment(JLabel.CENTER);
mainPanel.add(titleLabel, BorderLayout.NORTH); mainPanel.add(titleLabel, BorderLayout.NORTH);
@ -106,12 +108,26 @@ public class ConversationHistoryPlugin implements Plugin {
// Add Listeners // Add Listeners
contacts.addMouseListener(new MouseAdapter() { contacts.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) { 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) { if (e.getClickCount() == 2) {
final JLabel label = (JLabel) contacts.getSelectedValue(); final JLabel label = (JLabel) contacts.getSelectedValue();
String user = jidMap.get(label); String user = jidMap.get(label);
if (user != null) { if (user != null) {
final String contactUsername = SparkManager.getUserManager().getUserNicknameFromJID(user); final String contactUsername = SparkManager
SparkManager.getChatManager().activateChat(user, contactUsername); .getUserManager().getUserNicknameFromJID(user);
SparkManager.getChatManager().activateChat(user,
contactUsername);
window.dispose(); window.dispose();
} }
} }

View File

@ -19,6 +19,7 @@
*/ */
package org.jivesoftware.sparkimpl.plugin.history; package org.jivesoftware.sparkimpl.plugin.history;
import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes; import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.spark.SparkManager; import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.plugin.Plugin; import org.jivesoftware.spark.plugin.Plugin;
@ -55,6 +56,7 @@ import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import javax.swing.ListCellRenderer; import javax.swing.ListCellRenderer;
import javax.swing.SwingUtilities;
/** /**
* Adds a simple feature to list your most "Popular" contacts. Popular contacts is basically who * 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 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.setFont(new Font("Dialog", Font.BOLD, 11));
titleLabel.setHorizontalAlignment(JLabel.CENTER); titleLabel.setHorizontalAlignment(JLabel.CENTER);
mainPanel.add(titleLabel, BorderLayout.NORTH); mainPanel.add(titleLabel, BorderLayout.NORTH);
@ -92,12 +94,26 @@ public class FrequentContactsPlugin implements Plugin {
// Add Listeners // Add Listeners
contacts.addMouseListener(new MouseAdapter() { contacts.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) { 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) { if (e.getClickCount() == 2) {
final JLabel label = (JLabel) contacts.getSelectedValue(); final JLabel label = (JLabel) contacts.getSelectedValue();
String user = jidMap.get(label); String user = jidMap.get(label);
if (user != null) { if (user != null) {
final String contactUsername = SparkManager.getUserManager().getUserNicknameFromJID(user); final String contactUsername = SparkManager
SparkManager.getChatManager().activateChat(user, contactUsername); .getUserManager().getUserNicknameFromJID(user);
SparkManager.getChatManager().activateChat(user,
contactUsername);
window.dispose(); window.dispose();
} }
} }

View File

@ -52,7 +52,8 @@ import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences; import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager; import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotificationListener { public class SysTrayPlugin implements Plugin, NativeHandler,
MessageEventNotificationListener {
private JPopupMenu popupMenu = new JPopupMenu(); private JPopupMenu popupMenu = new JPopupMenu();
private JMenuItem openMenu; private JMenuItem openMenu;
@ -85,30 +86,37 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
minimizeMenu = new JMenuItem(Res.getString("menuitem.hide")); minimizeMenu = new JMenuItem(Res.getString("menuitem.hide"));
exitMenu = new JMenuItem(Res.getString("menuitem.exit")); exitMenu = new JMenuItem(Res.getString("menuitem.exit"));
statusMenu = new JMenu(Res.getString("menuitem.status")); statusMenu = new JMenu(Res.getString("menuitem.status"));
logoutMenu = new JMenuItem(Res.getString("menuitem.logout.no.status")); logoutMenu = new JMenuItem(
Res.getString("menuitem.logout.no.status"));
SystemTray tray = SystemTray.getSystemTray(); SystemTray tray = SystemTray.getSystemTray();
SparkManager.getNativeManager().addNativeHandler(this); SparkManager.getNativeManager().addNativeHandler(this);
SparkManager.getMessageEventManager().addMessageEventNotificationListener(this); SparkManager.getMessageEventManager()
.addMessageEventNotificationListener(this);
if ( Spark.isLinux() ) { if (Spark.isLinux()) {
newMessageIcon = SparkRes.getImageIcon(SparkRes.MESSAGE_NEW_TRAY_LINUX); newMessageIcon = SparkRes
.getImageIcon(SparkRes.MESSAGE_NEW_TRAY_LINUX);
typingIcon = SparkRes.getImageIcon(SparkRes.TYPING_TRAY_LINUX); typingIcon = SparkRes.getImageIcon(SparkRes.TYPING_TRAY_LINUX);
} else { } else {
newMessageIcon = SparkRes.getImageIcon(SparkRes.MESSAGE_NEW_TRAY); newMessageIcon = SparkRes
.getImageIcon(SparkRes.MESSAGE_NEW_TRAY);
typingIcon = SparkRes.getImageIcon(SparkRes.TYPING_TRAY); typingIcon = SparkRes.getImageIcon(SparkRes.TYPING_TRAY);
} }
availableIcon = Default.getImageIcon(Default.TRAY_IMAGE); availableIcon = Default.getImageIcon(Default.TRAY_IMAGE);
if ( Spark.isLinux() ) { if (Spark.isLinux()) {
if (availableIcon == null) { if (availableIcon == null) {
availableIcon = SparkRes.getImageIcon(SparkRes.TRAY_IMAGE_LINUX); availableIcon = SparkRes
.getImageIcon(SparkRes.TRAY_IMAGE_LINUX);
Log.error(availableIcon.toString()); Log.error(availableIcon.toString());
} }
awayIcon = SparkRes.getImageIcon(SparkRes.TRAY_AWAY_LINUX); awayIcon = SparkRes.getImageIcon(SparkRes.TRAY_AWAY_LINUX);
dndIcon = SparkRes.getImageIcon(SparkRes.TRAY_DND_LINUX); dndIcon = SparkRes.getImageIcon(SparkRes.TRAY_DND_LINUX);
offlineIcon = SparkRes.getImageIcon(SparkRes.TRAY_OFFLINE_LINUX); offlineIcon = SparkRes
connectingIcon = SparkRes.getImageIcon(SparkRes.TRAY_CONNECTING_LINUX); .getImageIcon(SparkRes.TRAY_OFFLINE_LINUX);
connectingIcon = SparkRes
.getImageIcon(SparkRes.TRAY_CONNECTING_LINUX);
} else { } else {
if (availableIcon == null) { if (availableIcon == null) {
availableIcon = SparkRes.getImageIcon(SparkRes.TRAY_IMAGE); availableIcon = SparkRes.getImageIcon(SparkRes.TRAY_IMAGE);
@ -116,7 +124,8 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
awayIcon = SparkRes.getImageIcon(SparkRes.TRAY_AWAY); awayIcon = SparkRes.getImageIcon(SparkRes.TRAY_AWAY);
dndIcon = SparkRes.getImageIcon(SparkRes.TRAY_DND); dndIcon = SparkRes.getImageIcon(SparkRes.TRAY_DND);
offlineIcon = SparkRes.getImageIcon(SparkRes.TRAY_OFFLINE); offlineIcon = SparkRes.getImageIcon(SparkRes.TRAY_OFFLINE);
connectingIcon = SparkRes.getImageIcon(SparkRes.TRAY_CONNECTING); connectingIcon = SparkRes
.getImageIcon(SparkRes.TRAY_CONNECTING);
} }
popupMenu.add(openMenu); popupMenu.add(openMenu);
@ -153,7 +162,7 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
}); });
if (Spark.isWindows()) { if (Spark.isWindows()) {
if(!Default.getBoolean("DISABLE_EXIT")) if (!Default.getBoolean("DISABLE_EXIT"))
popupMenu.add(logoutMenu); popupMenu.add(logoutMenu);
logoutMenu.addActionListener(new AbstractAction() { logoutMenu.addActionListener(new AbstractAction() {
@ -174,13 +183,14 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
SparkManager.getMainWindow().shutdown(); SparkManager.getMainWindow().shutdown();
} }
}); });
if(!Default.getBoolean("DISABLE_EXIT")) if (!Default.getBoolean("DISABLE_EXIT"))
popupMenu.add(exitMenu); popupMenu.add(exitMenu);
/** /**
* If connection closed set offline tray image * If connection closed set offline tray image
*/ */
SparkManager.getConnection().addConnectionListener(new ConnectionListener() { SparkManager.getConnection().addConnectionListener(
new ConnectionListener() {
@Override @Override
public void connectionClosed() { public void connectionClosed() {
@ -208,12 +218,14 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
} }
}); });
SparkManager.getSessionManager().addPresenceListener(new PresenceListener() { SparkManager.getSessionManager().addPresenceListener(
new PresenceListener() {
@Override @Override
public void presenceChanged(Presence presence) { public void presenceChanged(Presence presence) {
if (presence.getMode() == Presence.Mode.available) { if (presence.getMode() == Presence.Mode.available) {
trayIcon.setImage(availableIcon.getImage()); trayIcon.setImage(availableIcon.getImage());
} else if (presence.getMode() == Presence.Mode.away || presence.getMode() == Presence.Mode.xa) { } else if (presence.getMode() == Presence.Mode.away
|| presence.getMode() == Presence.Mode.xa) {
trayIcon.setImage(awayIcon.getImage()); trayIcon.setImage(awayIcon.getImage());
} else if (presence.getMode() == Presence.Mode.dnd) { } else if (presence.getMode() == Presence.Mode.dnd) {
trayIcon.setImage(dndIcon.getImage()); trayIcon.setImage(dndIcon.getImage());
@ -223,9 +235,9 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
} }
}); });
try { try {
trayIcon = new TrayIcon(availableIcon.getImage(), Default.getString(Default.APPLICATION_NAME), null); trayIcon = new TrayIcon(availableIcon.getImage(),
Default.getString(Default.APPLICATION_NAME), null);
trayIcon.setImageAutoSize(true); trayIcon.setImageAutoSize(true);
trayIcon.addMouseListener(new MouseListener() { trayIcon.addMouseListener(new MouseListener() {
@ -354,8 +366,10 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
+ " - " + customItem.getStatus()); + " - " + customItem.getStatus());
} }
}; };
customAction.putValue(Action.NAME, customItem.getStatus()); customAction.putValue(Action.NAME,
customAction.putValue(Action.SMALL_ICON, statusItem.getIcon()); customItem.getStatus());
customAction.putValue(Action.SMALL_ICON,
statusItem.getIcon());
JMenuItem menuItem = new JMenuItem(customAction); JMenuItem menuItem = new JMenuItem(customAction);
status.add(menuItem); status.add(menuItem);
} }
@ -381,8 +395,7 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
// Info on new Messages // Info on new Messages
@Override @Override
public void flashWindow(Window window) { public void flashWindow(Window window) {
if (pref.isSystemTrayNotificationEnabled()) if (pref.isSystemTrayNotificationEnabled()) {
{
trayIcon.setImage(newMessageIcon.getImage()); trayIcon.setImage(newMessageIcon.getImage());
} }
} }
@ -402,7 +415,6 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
trayIcon.setImage(availableIcon.getImage()); trayIcon.setImage(availableIcon.getImage());
} }
// For Typing // For Typing
@Override @Override
public void cancelledNotification(String from, String packetID) { public void cancelledNotification(String from, String packetID) {

View File

@ -394,6 +394,8 @@ label.company = Company
label.confirm.password = &Confirm password label.confirm.password = &Confirm password
label.conflict.error = Unable to login due to account already signed in label.conflict.error = Unable to login due to account already signed in
label.contact.to.find = Find contact 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.avatarsize = Contact list avatar &size:
label.contactlist.fontsize = &Contact List font size: label.contactlist.fontsize = &Contact List font size:
label.country = Country label.country = Country

View File

@ -261,6 +261,8 @@ label.transfer.download.directory = &Download Verzeichnis:
label.find = &Finden label.find = &Finden
label.rename.to = Umbenennen zu label.rename.to = Umbenennen zu
label.contact.to.find = Kontakt finden? label.contact.to.find = Kontakt finden?
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.available.users.in.roster = &Verf<72>gbare Teilnehmer in der Kontaktliste
label.time = Zeit: {0} label.time = Zeit: {0}
label.add.conference.service = &Service f<>r Konferenzen hinzuf<75>gen label.add.conference.service = &Service f<>r Konferenzen hinzuf<75>gen