// Sample code file: InfoPanel.java

// Warning: This code has been marked up for HTML

/*
   Copyright (c) 2000 Novell, Inc.  All Rights Reserved.

   THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES. 
   USE AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO THE LICENSE AGREEMENT 
   ACCOMPANYING THE SOFTWARE DEVELOPMENT KIT (SDK) THAT CONTAINS THIS WORK. 
   PURSUANT TO THE SDK LICENSE AGREEMENT, NOVELL HEREBY GRANTS TO DEVELOPER A 
   ROYALTY-FREE, NON-EXCLUSIVE LICENSE TO INCLUDE NOVELL'S SAMPLE CODE IN ITS 
   PRODUCT. NOVELL GRANTS DEVELOPER WORLDWIDE DISTRIBUTION RIGHTS TO MARKET, 
   DISTRIBUTE, OR SELL NOVELL'S SAMPLE CODE AS A COMPONENT OF DEVELOPER'S 
   PRODUCTS. NOVELL SHALL HAVE NO OBLIGATIONS TO DEVELOPER OR DEVELOPER'S 
   CUSTOMERS WITH RESPECT TO THIS CODE. 
*/
 



package com.novell.Chat;

//Java imports
import javax.swing.*;
import java.beans.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ResourceBundle;

// ConsoleOne imports
import com.novell.application.console.snapin.*;

/**
 * Displays all of the current user's attached to the Chat Room
 * this panel is display for.
 */
public class InfoPanel extends JPanel
{    
    //GUI components
    ChatRoomUserTable userTable = new ChatRoomUserTable();
        JScrollPane scrollPane = new JScrollPane(userTable);
        JLabel label = new JLabel();        
    
    /**
     * Constructor
     */
    public InfoPanel()
    {
        //Construct panel
        label.setText(Chat.chatRes.getString("User's in room"));
        this.setLayout(new GridBagLayout());
        this.add(label, new SimpleGridBagConstraints(0,0,1,1,0.0,0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,new Insets(9,6,3,6),0,0));
        this.add(scrollPane, new SimpleGridBagConstraints(0,1,1,1,1.0,1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,new Insets(0,6,6,6),0,0));
        
        //Get the width and height of the pane from the resource bundle.
                int width = (new Integer(Chat.chatRes.getString("InfoPanel scrollPane Width"))).intValue();
                int height = (new Integer(Chat.chatRes.getString("InfoPanel scrollPane Height"))).intValue();
                
        scrollPane.setPreferredSize(new Dimension(width, height));      
        scrollPane.setMinimumSize(new Dimension(width, height));    
        scrollPane.setSize(new Dimension(width, height));   
    }  
    
    /**
         * Called when the user list needs to be updated.
         *
         * @param chatRoom The chat room object to get the list from.
         */
        public void updateUserList(ObjectEntry chatRoom)
        {
            String[] users = Chat.getInstance().getMultiValuedAttribute(chatRoom, Chat.ATTRIBUTE_USERLIST);
        userTable.removeAllUsers();
        if(users != null)
            {
                for(int i = 0; i < users.length; i++)
                    userTable.addUser(users[i]);
            } 
        }    
}