[sip-comm-cvs] CVS update: /sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/, /sip-communicator/src/net/java/sip/communicator/impl/gui/...

yanas at dev.java.net yanas at dev.java.net
Fri Apr 20 16:18:22 CEST 2007


User: yanas   
Date: 2007-04-20 14:18:22+0000
Removed:
   sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomsListRightButtonMenu.java

Added:
   sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomServerRightButtonMenu.java
   sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/JoinChannelDialog.java

Modified:
   sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomsListPanel.java
   sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomsList.java
   sip-communicator/src/net/java/sip/communicator/impl/gui/i18n/messages.properties

Log:
 join chat room for multi chat

File Changes:

Directory: /sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/
=======================================================================================

File [added]: ChatRoomServerRightButtonMenu.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomServerRightButtonMenu.java?rev=1.1&content-type=text/vnd.viewcvs-markup
Added lines: 163
----------------
/*
 * 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.chatroomslist;

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

import javax.swing.*;

import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.chatroomslist.chatroomwizard.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.gui.event.*;
import net.java.sip.communicator.service.protocol.*;

/**
 * The <tt>ChatRoomsListRightButtonMenu</tt> is the menu, opened when user clicks
 * with the right mouse button on the chat rooms list panel. It's the one that
 * contains the create chat room item.
 *
 * @author Yana Stamcheva
 */
public class ChatRoomServerRightButtonMenu
    extends JPopupMenu
    implements  ActionListener,
                PluginComponentListener
{
    private I18NString createChatRoomString
        = Messages.getI18NString("createChatRoom");
    
    private I18NString joinChannelString
        = Messages.getI18NString("joinChatRoom");
    
    private JMenuItem createChatRoomItem = new JMenuItem(
        createChatRoomString.getText(),
        new ImageIcon(ImageLoader.getImage(ImageLoader.CHAT_ROOM_16x16_ICON)));

    private JMenuItem joinChannelItem = new JMenuItem(
        joinChannelString.getText(),
        new ImageIcon(ImageLoader.getImage(ImageLoader.SEARCH_ICON_16x16)));

    private MainFrame mainFrame;
    
    private ProtocolProviderService protocolProvider;
        
    /**
     * Creates an instance of <tt>ChatRoomsListRightButtonMenu</tt>.
     */
    public ChatRoomServerRightButtonMenu(MainFrame mainFrame,
            ProtocolProviderService protocolProvider)
    {
        super();

        this.mainFrame = mainFrame;
     
        this.protocolProvider = protocolProvider;
        
        this.setLocation(getLocation());

        this.init();
    }

    /**
     * Initializes the menu, by adding all containing menu items.
     */
    private void init()
    {
        this.add(createChatRoomItem);
        this.add(joinChannelItem);
        
        this.initPluginComponents();

        this.createChatRoomItem.setName("createChatRoom");
        this.joinChannelItem.setName("joinChatRoom");
        
        this.createChatRoomItem
            .setMnemonic(createChatRoomString.getMnemonic());
        this.joinChannelItem
            .setMnemonic(joinChannelString.getMnemonic());
        
        this.createChatRoomItem.addActionListener(this);
        this.joinChannelItem.addActionListener(this);
    }
    
    /**
     * Adds all already registered plugin components to this menu.
     */
    private void initPluginComponents()
    {
        Iterator pluginComponents = GuiActivator.getUIService()
            .getComponentsForContainer(
                UIService.CONTAINER_CONTACT_RIGHT_BUTTON_MENU);
        
        if(pluginComponents.hasNext())
            this.addSeparator();
        
        while (pluginComponents.hasNext())
        {
            Component o = (Component)pluginComponents.next();
            
            this.add(o);
        }
    }
    
    /**
     * Handles the <tt>ActionEvent</tt>. Determines which menu item was
     * selected and makes the appropriate operations.
     */
    public void actionPerformed(ActionEvent e){

        JMenuItem menuItem = (JMenuItem) e.getSource();
        String itemName = menuItem.getName();

        if (itemName.equals("createChatRoom"))
        {
            CreateChatRoomWizard createChatRoomWizard
                = new CreateChatRoomWizard(mainFrame);
            
            createChatRoomWizard.setVisible(true);
        }
        else if (itemName.equals("joinChatRoom"))
        {
            JoinChannelDialog joinChannelDialog
                = new JoinChannelDialog(mainFrame, protocolProvider);
            
            joinChannelDialog.pack();
            joinChannelDialog.setVisible(true);
        }
    }   
    
    /**
     * Implements the <tt>PluginComponentListener.pluginComponentAdded</tt>
     * method, in order to add the given plugin component in this container.
     */
    public void pluginComponentAdded(PluginComponentEvent event)
    {
        Component c = (Component) event.getSource();
        
        this.add(c);
                
        this.repaint();
    }

    /**
     * Implements the <tt>PluginComponentListener.pluginComponentRemoved</tt>
     * method, in order to remove the given component from this container.
     */
    public void pluginComponentRemoved(PluginComponentEvent event)
    {
        Component c = (Component) event.getSource();
        
        this.remove(c);
    }
}

File [added]: JoinChannelDialog.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/JoinChannelDialog.java?rev=1.1&content-type=text/vnd.viewcvs-markup
Added lines: 140
----------------
package net.java.sip.communicator.impl.gui.main.chatroomslist;

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.i18n.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.service.protocol.*;

public class JoinChannelDialog
    extends SIPCommDialog
    implements ActionListener
{
    private JPanel mainPanel = new JPanel(new BorderLayout(5, 5));
    
    private JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    
    private JPanel centerPanel = new JPanel(new BorderLayout(5, 5));
    
    private JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    
    private JButton channelListButton
        = new JButton(Messages.getI18NString("showChannelsList").getText());
    
    private JLabel channelLabel
        = new JLabel(Messages.getI18NString("joinChatRoom").getText() + ":");
    
    private JTextField channelTextField = new JTextField();
    
    private JButton okButton
        = new JButton(Messages.getI18NString("ok").getText());
    
    private JButton cancelButton
        = new JButton(Messages.getI18NString("cancel").getText());
    
    private MainFrame mainFrame;
    
    private ProtocolProviderService protocolProvider;
    
    public JoinChannelDialog (MainFrame mainFrame,
            ProtocolProviderService protocolProvider)
    {
        super(mainFrame);
    
        this.setSize(400, 300);
        
        this.mainFrame = mainFrame;
        
        this.protocolProvider = protocolProvider;
        
        this.getContentPane().add(mainPanel, BorderLayout.CENTER);
        
        this.getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
        
        buttonsPanel.add(okButton);
        
        buttonsPanel.add(cancelButton);
        
        mainPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
        
        mainPanel.add(centerPanel, BorderLayout.NORTH);
        
        mainPanel.add(southPanel, BorderLayout.CENTER);
        
        centerPanel.add(channelLabel, BorderLayout.WEST);
        
        centerPanel.add(channelTextField, BorderLayout.CENTER);
        
        southPanel.add(channelListButton);
        
        channelTextField.setText("#");
        
        okButton.setName("ok");
        cancelButton.setName("cancel");
        channelListButton.setName("channelList");
        
        okButton.addActionListener(this);
        cancelButton.addActionListener(this);
        channelListButton.addActionListener(this);
    }
    
    protected void close(boolean isEscaped)
    {   
    }

    public void actionPerformed(ActionEvent e)
    {
        JButton button = (JButton) e.getSource();
        String buttonName = button.getName();
        
        if(buttonName.equals("ok"))
        {
            OperationSetMultiUserChat multiChatOpSet
                = (OperationSetMultiUserChat) protocolProvider.getOperationSet(
                        OperationSetMultiUserChat.class);
            
            String chatRoomName = channelTextField.getText();
            
            ChatRoom chatRoom = multiChatOpSet.findRoom(chatRoomName);
            
            if(chatRoom != null)
            {
                try
                {
                    chatRoom.join();
                }
                catch (OperationFailedException ex)
                {
                    new ErrorDialog(mainFrame,
                            Messages.getI18NString("failedToJoinChannel",
                                    new String[]{chatRoomName}).getText(),
                            ex,
                            Messages.getI18NString("error").getText())
                            .showDialog();
                }
            }
            else
            {
                new ErrorDialog(mainFrame,
                        Messages.getI18NString("chatRoomNotExist",
                                new String[]{chatRoomName,
                                protocolProvider.getAccountID().getService()})
                            .getText(),
                        Messages.getI18NString("error").getText()).showDialog();
            }
        }
        else if(buttonName.equals("cancel"))
        {
            this.dispose();            
        }
        else if(buttonName.equals("channelList"))
        {
            
        }
    }
}


File [removed]: ChatRoomsListRightButtonMenu.java

File [changed]: ChatRoomsListPanel.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomsListPanel.java?r1=1.1&r2=1.2
Delta lines:  +2 -20
--------------------
--- ChatRoomsListPanel.java	2007-03-12 17:40:57+0000	1.1
+++ ChatRoomsListPanel.java	2007-04-20 14:18:19+0000	1.2
@@ -29,7 +29,7 @@
      
     private JPanel treePanel = new JPanel(new BorderLayout());
 
-    private ChatRoomsListRightButtonMenu rightButtonMenu;
+    private ChatRoomServerRightButtonMenu rightButtonMenu;
         
     /**
      * Creates the scroll panel containing the chat rooms list.
@@ -46,24 +46,6 @@
         
         this.treePanel.setBackground(Color.WHITE);
         
-        this.treePanel.addMouseListener(new MouseAdapter() {
-            public void mousePressed(MouseEvent e)
-            {
-                if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0)
-                {
-                    rightButtonMenu = new ChatRoomsListRightButtonMenu(mainFrame);
-
-                    rightButtonMenu.setInvoker(treePanel);
-
-                    rightButtonMenu.setLocation(e.getX()
-                            + mainFrame.getX() + 5, e.getY() + mainFrame.getY()
-                            + 105);
-
-                    rightButtonMenu.setVisible(true);
-                }
-            }
-        });
-        
         this.getViewport().add(treePanel);
         
         this.setHorizontalScrollBarPolicy(

File [changed]: ChatRoomsList.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomsList.java?r1=1.1&r2=1.2
Delta lines:  +50 -1
--------------------
--- ChatRoomsList.java	2007-03-12 17:40:57+0000	1.1
+++ ChatRoomsList.java	2007-04-20 14:18:19+0000	1.2
@@ -7,6 +7,7 @@
 package net.java.sip.communicator.impl.gui.main.chatroomslist;
 
 import java.awt.*;
+import java.awt.event.*;
 import java.util.*;
 import java.util.List;
 
@@ -25,7 +26,8 @@
  */
 public class ChatRoomsList
     extends JList
-    implements  ListSelectionListener
+    implements  ListSelectionListener,
+                MouseListener
 {
     private Logger logger = Logger.getLogger(ChatRoomsList.class);
     
@@ -47,6 +49,8 @@
         this.setModel(listModel);
         this.setCellRenderer(new ChatRoomsListCellRenderer());
         this.addListSelectionListener(this);
+        
+        this.addMouseListener(this);
     }
     
     /**
@@ -126,4 +130,49 @@
             chatWindowManager.openChat(chatPanel, true);
         }
     }
+
+    public void mouseClicked(MouseEvent e)
+    {}
+
+    public void mouseEntered(MouseEvent e)
+    {}
+
+    public void mouseExited(MouseEvent e)
+    {}
+
+    public void mousePressed(MouseEvent e)
+    {
+        // Select the contact under the right button click.
+        if ((e.getModifiers() & InputEvent.BUTTON2_MASK) != 0
+            || (e.getModifiers() & InputEvent.BUTTON3_MASK) != 0
+            || (e.isControlDown() && !e.isMetaDown()))
+        {
+            this.setSelectedIndex(locationToIndex(e.getPoint()));
+        }
+
+        Object selectedValue = this.getSelectedValue();
+
+        if(selectedValue instanceof ProtocolProviderService)
+        {
+            ProtocolProviderService pps
+                = (ProtocolProviderService) selectedValue;
+            
+            if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0)
+            {
+                ChatRoomServerRightButtonMenu rightButtonMenu
+                    = new ChatRoomServerRightButtonMenu(mainFrame, pps);
+
+                rightButtonMenu.setInvoker(this);
+
+                rightButtonMenu.setLocation(e.getX()
+                        + mainFrame.getX() + 5, e.getY() + mainFrame.getY()
+                        + 105);
+
+                rightButtonMenu.setVisible(true);       
+            }
+        }
+    }
+
+    public void mouseReleased(MouseEvent e)
+    {}
 }

Directory: /sip-communicator/src/net/java/sip/communicator/impl/gui/i18n/
=========================================================================

File [changed]: messages.properties
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/i18n/messages.properties?r1=1.60&r2=1.61
Delta lines:  +4 -0
-------------------
--- messages.properties	2007-03-12 17:51:19+0000	1.60
+++ messages.properties	2007-04-20 14:18:19+0000	1.61
@@ -38,6 +38,7 @@
 cancel=&Cancel
 chatRoomName=Chat room name
 chatRoomNameInfo=In the field below enter the name of the chat room that you would like to create.
+chatRoomNotExist=The {0} room was not found in the {1} server. Please verify if the name you typed is correct.
 chatRooms=Chat rooms
 close=Cl&ose
 closeChatAfterNewMsg=You have received a new message less than 2 seconds ago. Are you sure you want to close this chat?
@@ -79,6 +80,7 @@
 generalError=General error
 group=Group
 groupName=Group name
+failedToJoinChannel=Failed to join channel {0}.
 file=&File
 finish=&Finish
 first=First
@@ -92,6 +94,7 @@
 ignore=Ignore
 insertSmiley=Insert smiley
 invalidCall=Invalid call
+joinChatRoom=&Join chat room
 last=Last
 launchBrowserError=Error attempting to launch web browser.
 launchOnStartUp=Launch on start up
@@ -177,6 +180,7 @@
 sendVia=Send via
 settings=&Settings
 showCallPanel=Show call panel
+showChannelsList=Show channels list
 showOfflineUsers=Hide/Show offline users
 sipCommunicator=SIPCommunicator
 soundOnOff=Turn sound on/off




---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe at sip-communicator.dev.java.net
For additional commands, e-mail: cvs-help at sip-communicator.dev.java.net





More information about the commits mailing list