/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package net.java.sip.communicator.impl.gui.main.chat.conference;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.main.chat.*;
import net.java.sip.communicator.impl.gui.main.contactlist.*;

/**
 * The <tt>ChatContactListPanel</tt> is the panel added on the right of the
 * chat conversation area, containing information for all contacts
 * participating the chat. It contains a list of <tt>ChatContactPanel</tt>s.
 * Each of these panels is containing the name, status, etc. of only one
 * <tt>MetaContact</tt> or simple <tt>Contact</tt>. There is also a button,
 * which allows to add new contact to the chat.
 *
 * @author Yana Stamcheva
 */
public class ChatRoomMemberListPanel
    extends JPanel
{
    /**
     * The list of members.
     */
    private final DefaultContactList memberList = new DefaultContactList();

    /**
     * The model of the members list.
     */
    private final ChatContactListModel memberListModel
        = new ChatContactListModel();

     private final ChatPanel chatPanel;

    /**
     * Creates an instance of <tt>ChatContactListPanel</tt>.
     * @param chat Currently not used
     */
    public ChatRoomMemberListPanel(final ChatPanel chat)
    {
        super(new BorderLayout());

         this.chatPanel = chat;

        this.memberList.setModel(memberListModel);
        this.memberList.addKeyListener(new CListKeySearchListener(memberList));
        this.memberList.setCellRenderer(new ChatContactCellRenderer());
        this.memberList.addMouseListener(new MouseAdapter()
        {
            public void mouseClicked(MouseEvent e)
            {
                if(e.getButton() == MouseEvent.BUTTON3)
                {
                    new ChatContactRightButtonMenu(
                        chat, (ChatContact)memberList.getSelectedValue()).show(
                            memberList, e.getX(), e.getY());
                }
            }
        });

        JScrollPane contactsScrollPane = new SCScrollPane();
        contactsScrollPane.setHorizontalScrollBarPolicy(
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        contactsScrollPane.setOpaque(false);

        JViewport viewport = contactsScrollPane.getViewport();
        viewport.setOpaque(false);
        viewport.add(memberList);

        this.add(contactsScrollPane);
    }

    /**
     * Adds a <tt>ChatContact</tt> to the list of contacts contained in the
     * chat.
     *
     * @param chatContact the <tt>ChatContact</tt> to add
     */
    public void addContact(ChatContact chatContact)
    {
        memberListModel.addElement(chatContact);
    }

    /**
     * Removes the given <tt>ChatContact</tt> from the list of chat contacts.
     *
     * @param chatContact the <tt>ChatContact</tt> to remove
     */
    public void removeContact(ChatContact chatContact)
    {
        memberListModel.removeElement(chatContact);
    }

    /**
     * In the corresponding <tt>ChatContactPanel</tt> changes the name of the
     * given <tt>Contact</tt>.
     *
     * @param chatContact the <tt>ChatContact</tt> to be renamed
     */
    public void renameContact(ChatContact chatContact)
    {
    }

    /**
     * Opens a web page containing information of the currently selected user.
     *
     * @param evt the action event that has just occurred.
     */
//    public void actionPerformed(ActionEvent evt)
//    {
//        JButton button = (JButton) evt.getSource();
//
//        // first, see if the contact with which we chat supports telephony
//        // and call that one. If he don't, we look for the default
//        // telephony contact in its enclosing metacontact
//        if(button.getName().equals("call"))
//        {
//            ChatTransport telephonyTransport
//                = chatPanel.getChatSession().getTelephonyTransport();
//
//            if (telephonyTransport != null)
//            {
//                // hope an appropriate telephony will be used.
//                CallManager.createCall( telephonyTransport.getProtocolProvider(),
//                                        telephonyTransport.getName());
//            }
//
//            chatPanel.getChatWindow().getMainFrame().toFront();
//        }
//        else if(button.getName().equals("info"))
//        {
//            ChatTransport contactDetailsTransport
//                = chatPanel.getChatSession().getContactDetailsTransport();
//
//            if(contactDetailsTransport != null)
//            {
//                // TODO: Open the contact details dialog.
//            }
//        }
//    }
}

@@ -462,16 +462,69 @@
 tlist.*;
+%0Aimport net.java.sip.communicator.service.protocol.*;
 %0A%0A/**%0A *
@@ -967,16 +967,45 @@
 amcheva%0A
+ * @author Valentin Martinet%0A
  */%0Apubl
@@ -1058,20 +1058,87 @@
 Panel%0A%7B%0A
-    
+%09private static final long serialVersionUID = -8250816784228586068L;%0A%0A%09
 /**%0A    
@@ -1885,32 +1885,393 @@
 rer());%0A        
+%0A        // It's pertinent to add the ChatContactRightButtonMenu only we aren't %0A        // in an ad-hoc multi user chat (which support roles)%0A        if(this.chatPanel.getChatSession().getCurrentChatTransport()%0A        %09%09.getProtocolProvider().getSupportedOperationSets().containsKey(%0A        %09%09%09%09OperationSetMultiUserChat.class.getName()))%0A        %7B%0A        %09
 this.memberList.
@@ -2306,34 +2306,42 @@
 apter()%0A        
+  
-%7B%0A
+  %7B%0A    
             publ
@@ -2379,34 +2379,42 @@
  e)%0A            
+ 
-%7B%0A
+   %7B%0A    
                 
@@ -2461,34 +2461,40 @@
                 
-%7B%0A
+    %7B%0A  
                 
@@ -2497,16 +2497,18 @@
         
+  
 new Chat
@@ -2531,16 +2531,20 @@
 onMenu(%0A
+    
         
@@ -2612,14 +2612,8 @@
 e())
-.show(
 %0A   
@@ -2629,27 +2629,32 @@
             
-   
+%09%09.show(
  memberList,
@@ -2671,24 +2671,28 @@
  e.getY());%0A
+    
             
@@ -2709,26 +2709,33 @@
         
-%7D%0A
+    %7D%0A   
         
 %7D);%0A%0A   
@@ -2730,11 +2730,31 @@
     
+ 
 %7D);
+%0A        %7D%0A        
 %0A%0A  

Disable right click on ad-hoc chatroom member list panel since it's generating exceptions. Not pertinent with ad-hoc too.