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);
@ -106,12 +108,26 @@ public class ConversationHistoryPlugin implements Plugin {
// Add Listeners
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);
final String contactUsername = SparkManager
.getUserManager().getUserNicknameFromJID(user);
SparkManager.getChatManager().activateChat(user,
contactUsername);
window.dispose();
}
}

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);
@ -92,12 +94,26 @@ public class FrequentContactsPlugin implements Plugin {
// Add Listeners
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);
final String contactUsername = SparkManager
.getUserManager().getUserNicknameFromJID(user);
SparkManager.getChatManager().activateChat(user,
contactUsername);
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.SettingsManager;
public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotificationListener {
public class SysTrayPlugin implements Plugin, NativeHandler,
MessageEventNotificationListener {
private JPopupMenu popupMenu = new JPopupMenu();
private JMenuItem openMenu;
@ -85,30 +86,37 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
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"));
logoutMenu = new JMenuItem(
Res.getString("menuitem.logout.no.status"));
SystemTray tray = SystemTray.getSystemTray();
SparkManager.getNativeManager().addNativeHandler(this);
SparkManager.getMessageEventManager().addMessageEventNotificationListener(this);
SparkManager.getMessageEventManager()
.addMessageEventNotificationListener(this);
if ( Spark.isLinux() ) {
newMessageIcon = SparkRes.getImageIcon(SparkRes.MESSAGE_NEW_TRAY_LINUX);
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);
newMessageIcon = SparkRes
.getImageIcon(SparkRes.MESSAGE_NEW_TRAY);
typingIcon = SparkRes.getImageIcon(SparkRes.TYPING_TRAY);
}
availableIcon = Default.getImageIcon(Default.TRAY_IMAGE);
if ( Spark.isLinux() ) {
if (Spark.isLinux()) {
if (availableIcon == null) {
availableIcon = SparkRes.getImageIcon(SparkRes.TRAY_IMAGE_LINUX);
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);
offlineIcon = SparkRes
.getImageIcon(SparkRes.TRAY_OFFLINE_LINUX);
connectingIcon = SparkRes
.getImageIcon(SparkRes.TRAY_CONNECTING_LINUX);
} else {
if (availableIcon == null) {
availableIcon = SparkRes.getImageIcon(SparkRes.TRAY_IMAGE);
@ -116,7 +124,8 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
awayIcon = SparkRes.getImageIcon(SparkRes.TRAY_AWAY);
dndIcon = SparkRes.getImageIcon(SparkRes.TRAY_DND);
offlineIcon = SparkRes.getImageIcon(SparkRes.TRAY_OFFLINE);
connectingIcon = SparkRes.getImageIcon(SparkRes.TRAY_CONNECTING);
connectingIcon = SparkRes
.getImageIcon(SparkRes.TRAY_CONNECTING);
}
popupMenu.add(openMenu);
@ -153,7 +162,7 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
});
if (Spark.isWindows()) {
if(!Default.getBoolean("DISABLE_EXIT"))
if (!Default.getBoolean("DISABLE_EXIT"))
popupMenu.add(logoutMenu);
logoutMenu.addActionListener(new AbstractAction() {
@ -174,13 +183,14 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
SparkManager.getMainWindow().shutdown();
}
});
if(!Default.getBoolean("DISABLE_EXIT"))
if (!Default.getBoolean("DISABLE_EXIT"))
popupMenu.add(exitMenu);
/**
* If connection closed set offline tray image
*/
SparkManager.getConnection().addConnectionListener(new ConnectionListener() {
SparkManager.getConnection().addConnectionListener(
new ConnectionListener() {
@Override
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
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) {
} 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());
@ -223,9 +235,9 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
}
});
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.addMouseListener(new MouseListener() {
@ -354,8 +366,10 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
+ " - " + customItem.getStatus());
}
};
customAction.putValue(Action.NAME, customItem.getStatus());
customAction.putValue(Action.SMALL_ICON, statusItem.getIcon());
customAction.putValue(Action.NAME,
customItem.getStatus());
customAction.putValue(Action.SMALL_ICON,
statusItem.getIcon());
JMenuItem menuItem = new JMenuItem(customAction);
status.add(menuItem);
}
@ -381,8 +395,7 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
// Info on new Messages
@Override
public void flashWindow(Window window) {
if (pref.isSystemTrayNotificationEnabled())
{
if (pref.isSystemTrayNotificationEnabled()) {
trayIcon.setImage(newMessageIcon.getImage());
}
}
@ -402,7 +415,6 @@ public class SysTrayPlugin implements Plugin, NativeHandler, MessageEventNotific
trayIcon.setImage(availableIcon.getImage());
}
// For Typing
@Override
public void cancelledNotification(String from, String packetID) {

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,6 +261,8 @@ label.transfer.download.directory = &Download Verzeichnis:
label.find = &Finden
label.rename.to = Umbenennen zu
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.time = Zeit: {0}
label.add.conference.service = &Service f<>r Konferenzen hinzuf<75>gen