|
|
|
|
@ -14,6 +14,8 @@
|
|
|
|
|
import java.awt.event.InputEvent;
|
|
|
|
|
import java.awt.event.MouseEvent;
|
|
|
|
|
import java.awt.event.MouseListener;
|
|
|
|
|
import java.awt.event.WindowAdapter;
|
|
|
|
|
import java.awt.event.WindowEvent;
|
|
|
|
|
import java.util.Hashtable;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
|
|
|
|
|
@ -29,7 +31,9 @@
|
|
|
|
|
import javax.swing.tree.TreePath;
|
|
|
|
|
|
|
|
|
|
import net.java.sip.communicator.impl.gui.main.MainFrame;
|
|
|
|
|
import net.java.sip.communicator.impl.gui.main.message.MessageWindow;
|
|
|
|
|
import net.java.sip.communicator.impl.gui.main.message.ChatPanel;
|
|
|
|
|
import net.java.sip.communicator.impl.gui.main.message.ChatWindow;
|
|
|
|
|
import net.java.sip.communicator.impl.gui.main.utils.Constants;
|
|
|
|
|
import net.java.sip.communicator.service.contactlist.MetaContact;
|
|
|
|
|
import net.java.sip.communicator.service.contactlist.MetaContactGroup;
|
|
|
|
|
import net.java.sip.communicator.service.contactlist.MetaContactListService;
|
|
|
|
|
@ -37,7 +41,7 @@
|
|
|
|
|
/**
|
|
|
|
|
* @author Yana Stamcheva
|
|
|
|
|
*
|
|
|
|
|
* The ContactListPanel contains the contact list.
|
|
|
|
|
* Creates the contactlist panel.
|
|
|
|
|
*/
|
|
|
|
|
public class ContactListPanel extends JScrollPane
|
|
|
|
|
implements MouseListener {
|
|
|
|
|
@ -49,7 +53,14 @@ public class ContactListPanel extends JScrollPane
|
|
|
|
|
private JPanel treePanel = new JPanel(new BorderLayout());
|
|
|
|
|
|
|
|
|
|
private Hashtable contactMsgWindows = new Hashtable();
|
|
|
|
|
|
|
|
|
|
private ChatWindow tabbedChatWindow;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates the contactlist scroll panel defining the parent frame.
|
|
|
|
|
*
|
|
|
|
|
* @param parent The parent frame.
|
|
|
|
|
*/
|
|
|
|
|
public ContactListPanel(MainFrame parent) {
|
|
|
|
|
|
|
|
|
|
this.parent = parent;
|
|
|
|
|
@ -64,6 +75,7 @@ public ContactListPanel(MainFrame parent) {
|
|
|
|
|
|
|
|
|
|
public void mouseClicked(MouseEvent e) {
|
|
|
|
|
|
|
|
|
|
//Expand and collapse groups on double click.
|
|
|
|
|
if(e.getClickCount() > 1){
|
|
|
|
|
|
|
|
|
|
int selectedIndex
|
|
|
|
|
@ -119,6 +131,9 @@ public void mouseExited(MouseEvent e) {
|
|
|
|
|
|
|
|
|
|
public void mousePressed(MouseEvent e) {
|
|
|
|
|
|
|
|
|
|
// Open message window, right button menu or contact info when
|
|
|
|
|
// mouse is pressed. Distinguish on which component was pressed
|
|
|
|
|
// the mouse and make the appropriate work.
|
|
|
|
|
if (this.contactList.getSelectedValue() instanceof MetaContactNode){
|
|
|
|
|
|
|
|
|
|
MetaContactNode contactNode
|
|
|
|
|
@ -143,20 +158,24 @@ public void mousePressed(MouseEvent e) {
|
|
|
|
|
int translatedY = e.getY()
|
|
|
|
|
- selectedCellPoint.y;
|
|
|
|
|
|
|
|
|
|
//get the component under the mouse
|
|
|
|
|
Component component
|
|
|
|
|
= renderer.getComponentAt(translatedX, translatedY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (component instanceof JLabel) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((e.getModifiers() & InputEvent.BUTTON1_MASK)
|
|
|
|
|
== InputEvent.BUTTON1_MASK) {
|
|
|
|
|
|
|
|
|
|
//Left click on the contact label opens Chat window
|
|
|
|
|
SwingUtilities.invokeLater(new RunMessageWindow(
|
|
|
|
|
contactNode.getContact()));
|
|
|
|
|
|
|
|
|
|
} else if ((e.getModifiers() & InputEvent.BUTTON3_MASK)
|
|
|
|
|
== InputEvent.BUTTON3_MASK) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Right click on the contact label opens Popup menu
|
|
|
|
|
ContactRightButtonMenu popupMenu
|
|
|
|
|
= new ContactRightButtonMenu(
|
|
|
|
|
parent, contactNode.getContact());
|
|
|
|
|
@ -169,6 +188,7 @@ public void mousePressed(MouseEvent e) {
|
|
|
|
|
}
|
|
|
|
|
} else if (component instanceof JButton) {
|
|
|
|
|
|
|
|
|
|
//Click on the info button opens the info popup panel
|
|
|
|
|
SwingUtilities.invokeLater
|
|
|
|
|
(new RunInfoWindow(selectedCellPoint,
|
|
|
|
|
contactNode.getContact()));
|
|
|
|
|
@ -180,6 +200,11 @@ public void mouseReleased(MouseEvent e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Runs the chat window for the specified contact.
|
|
|
|
|
*
|
|
|
|
|
* @author Yana Stamcheva
|
|
|
|
|
*/
|
|
|
|
|
private class RunMessageWindow implements Runnable {
|
|
|
|
|
|
|
|
|
|
private MetaContact contactItem;
|
|
|
|
|
@ -190,32 +215,102 @@ private RunMessageWindow(MetaContact contactItem) {
|
|
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
|
|
if (contactMsgWindows.containsKey(this.contactItem)) {
|
|
|
|
|
|
|
|
|
|
MessageWindow msgWindow = (MessageWindow) contactMsgWindows
|
|
|
|
|
.get(this.contactItem);
|
|
|
|
|
|
|
|
|
|
if (msgWindow.getExtendedState() == JFrame.ICONIFIED)
|
|
|
|
|
msgWindow.setExtendedState(JFrame.NORMAL);
|
|
|
|
|
|
|
|
|
|
msgWindow.setVisible(true);
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
MessageWindow msgWindow = new MessageWindow(parent);
|
|
|
|
|
|
|
|
|
|
contactMsgWindows.put(this.contactItem, msgWindow);
|
|
|
|
|
|
|
|
|
|
msgWindow.addContactToChat(this.contactItem);
|
|
|
|
|
|
|
|
|
|
msgWindow.setVisible(true);
|
|
|
|
|
|
|
|
|
|
msgWindow.getWriteMessagePanel().getEditorPane().requestFocus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!Constants.TABBED_CHAT_WINDOW){
|
|
|
|
|
|
|
|
|
|
//If in mode "open all messages in new window"
|
|
|
|
|
|
|
|
|
|
if (contactMsgWindows.containsKey(this.contactItem)) {
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If a chat window for this contact is already opened
|
|
|
|
|
* show it.
|
|
|
|
|
*/
|
|
|
|
|
ChatWindow msgWindow = (ChatWindow) contactMsgWindows
|
|
|
|
|
.get(this.contactItem);
|
|
|
|
|
|
|
|
|
|
if (msgWindow.getExtendedState() == JFrame.ICONIFIED)
|
|
|
|
|
msgWindow.setExtendedState(JFrame.NORMAL);
|
|
|
|
|
|
|
|
|
|
if(!msgWindow.isVisible())
|
|
|
|
|
msgWindow.setVisible(true);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
/*
|
|
|
|
|
* If there's no chat window for the contact
|
|
|
|
|
* create it and show it.
|
|
|
|
|
*/
|
|
|
|
|
ChatWindow msgWindow = new ChatWindow(parent);
|
|
|
|
|
|
|
|
|
|
contactMsgWindows.put(this.contactItem, msgWindow);
|
|
|
|
|
|
|
|
|
|
msgWindow.addChat(this.contactItem);
|
|
|
|
|
|
|
|
|
|
msgWindow.setVisible(true);
|
|
|
|
|
|
|
|
|
|
msgWindow.getWriteMessagePanel()
|
|
|
|
|
.getEditorPane().requestFocus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
// If in mode "group messages in one chat window"
|
|
|
|
|
|
|
|
|
|
if(tabbedChatWindow == null){
|
|
|
|
|
|
|
|
|
|
// If there's no open chat window
|
|
|
|
|
tabbedChatWindow = new ChatWindow(parent);
|
|
|
|
|
|
|
|
|
|
tabbedChatWindow.addWindowListener(new WindowAdapter(){
|
|
|
|
|
|
|
|
|
|
public void windowClosing(WindowEvent e) {
|
|
|
|
|
tabbedChatWindow = null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Get the hashtable containg all tabs and correspondins
|
|
|
|
|
* chat panels.
|
|
|
|
|
*/
|
|
|
|
|
Hashtable contactTabsTable
|
|
|
|
|
= tabbedChatWindow.getContactTabsTable();
|
|
|
|
|
|
|
|
|
|
if(contactTabsTable.get(this.contactItem.getDisplayName())
|
|
|
|
|
== null){
|
|
|
|
|
|
|
|
|
|
// If there's no open tab for the given contact.
|
|
|
|
|
tabbedChatWindow.addChatTab(this.contactItem);
|
|
|
|
|
|
|
|
|
|
if (tabbedChatWindow.getExtendedState() == JFrame.ICONIFIED)
|
|
|
|
|
tabbedChatWindow.setExtendedState(JFrame.NORMAL);
|
|
|
|
|
|
|
|
|
|
if(!tabbedChatWindow.isVisible())
|
|
|
|
|
tabbedChatWindow.setVisible(true);
|
|
|
|
|
|
|
|
|
|
tabbedChatWindow.getWriteMessagePanel()
|
|
|
|
|
.getEditorPane().requestFocus();
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
// If a tab fot the given contact already exists.
|
|
|
|
|
tabbedChatWindow.setSelectedContactTab(this.contactItem);
|
|
|
|
|
|
|
|
|
|
if (tabbedChatWindow.getExtendedState() == JFrame.ICONIFIED)
|
|
|
|
|
tabbedChatWindow.setExtendedState(JFrame.NORMAL);
|
|
|
|
|
|
|
|
|
|
tabbedChatWindow.setVisible(true);
|
|
|
|
|
|
|
|
|
|
tabbedChatWindow.getWriteMessagePanel()
|
|
|
|
|
.getEditorPane().requestFocus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Runs the info window for the specified contact at the
|
|
|
|
|
* appropriate position.
|
|
|
|
|
*
|
|
|
|
|
* @author Yana Stamcheva
|
|
|
|
|
*/
|
|
|
|
|
private class RunInfoWindow implements Runnable {
|
|
|
|
|
|
|
|
|
|
private MetaContact contactItem;
|
|
|
|
|
|