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

yanas at dev.java.net yanas at dev.java.net
Thu May 3 16:23:22 CEST 2007


User: yanas   
Date: 2007-05-03 14:23:22+0000
Modified:
   sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomsList.java
   sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/JoinChannelDialog.java
   sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomServerRightButtonMenu.java

Log:
 Join Channel dialog - show the list of all available chat rooms

File Changes:

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

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.4&r2=1.5
Delta lines:  +2 -32
--------------------
--- ChatRoomsList.java	2007-04-24 12:28:31+0000	1.4
+++ ChatRoomsList.java	2007-05-03 14:23:20+0000	1.5
@@ -15,8 +15,10 @@
 import javax.swing.event.*;
 
 import net.java.sip.communicator.impl.gui.main.*;
+import net.java.sip.communicator.impl.gui.main.authorization.*;
 import net.java.sip.communicator.impl.gui.main.chat.*;
 import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.protocol.event.*;
 import net.java.sip.communicator.util.*;
 
 /**
@@ -65,38 +67,6 @@
         OperationSetMultiUserChat multiUserChatOperationSet)
     {
         listModel.addElement(pps);
-
-        try
-        {
-            List existingChatRooms
-                = multiUserChatOperationSet.getExistingChatRooms();
-
-            if(existingChatRooms == null)
-                return;
-
-            Iterator i = existingChatRooms.iterator();
-
-            while(i.hasNext())
-            {
-                ChatRoom chatRoom = (ChatRoom) i.next();
-
-                listModel.addElement(chatRoom);
-            }
-
-        }
-        catch (OperationNotSupportedException ex)
-        {
-            logger.error(
-                "Failed to obtain existing chat rooms for the following server: "
-                + pps.getAccountID().getService(), ex);
-        }
-        catch (OperationFailedException ex)
-        {
-            logger.error(
-                "Failed to obtain existing chat rooms for the following server: "
-                + pps.getAccountID().getService(), ex);
-        }
-
     }
 
 

File [changed]: JoinChannelDialog.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/JoinChannelDialog.java?r1=1.4&r2=1.5
Delta lines:  +61 -25
---------------------
--- JoinChannelDialog.java	2007-04-24 12:28:31+0000	1.4
+++ JoinChannelDialog.java	2007-05-03 14:23:20+0000	1.5
@@ -8,12 +8,14 @@
 
 import java.awt.*;
 import java.awt.event.*;
+import java.util.List;
 
 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.impl.gui.utils.*;
 import net.java.sip.communicator.service.protocol.*;
 import net.java.sip.communicator.util.*;
 
@@ -40,12 +42,16 @@
 
     private JTextField channelTextField = new JTextField();
 
-    private JButton okButton
-        = new JButton(Messages.getI18NString("ok").getText());
+    private JButton joinButton
+        = new JButton(Messages.getI18NString("join").getText());
 
     private JButton cancelButton
         = new JButton(Messages.getI18NString("cancel").getText());
 
+    private JScrollPane channelsListScrollPane = new JScrollPane();
+    
+    private JList channelsList;
+    
     private MainFrame mainFrame;
 
     private ProtocolProviderService protocolProvider;
@@ -53,9 +59,9 @@
     public JoinChannelDialog (MainFrame mainFrame,
             ProtocolProviderService protocolProvider)
     {
-        super(mainFrame);
+        super(mainFrame, false);
 
-        this.setSize(400, 300);
+        this.mainPanel.setPreferredSize(new Dimension(500, 150));
 
         this.mainFrame = mainFrame;
 
@@ -65,7 +71,7 @@
 
         this.getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
 
-        buttonsPanel.add(okButton);
+        buttonsPanel.add(joinButton);
 
         buttonsPanel.add(cancelButton);
 
@@ -81,35 +87,34 @@
 
         southPanel.add(channelListButton);
 
-        channelTextField.setText("#");
-
-        okButton.setName("ok");
+        joinButton.setName("ok");
         cancelButton.setName("cancel");
         channelListButton.setName("channelList");
 
-        okButton.addActionListener(this);
+        joinButton.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();
-
+        if(buttonName.equals("ok"))
+        {
             ChatRoom chatRoom = null;
+            String chatRoomName;
+            
+            if(channelsList != null && channelsList.getSelectedValue() != null)
+                chatRoomName = (String) channelsList.getSelectedValue();
+            else
+                chatRoomName = channelTextField.getText();
+            
             try
             {
                 chatRoom = multiChatOpSet.findRoom(chatRoomName);
@@ -134,6 +139,8 @@
                 {
                     chatRoom.join();
 
+                    ConfigurationManager.saveChatRoom(chatRoom);
+
                     ChatRoomsList chatRoomsList
                         = mainFrame.getChatRoomsListPanel().getChatRoomsList();
                     
@@ -143,9 +150,11 @@
                 }
                 catch (OperationFailedException ex)
                 {
+                    logger.error("Failed to join chat room. ", ex);
+                    
                     new ErrorDialog(mainFrame,
                             Messages.getI18NString("failedToJoinChannel",
-                                    new String[]{chatRoomName}).getText(),
+                                    new String[]{chatRoom.getName()}).getText(),
                             ex,
                             Messages.getI18NString("error").getText())
                             .showDialog();
@@ -155,7 +164,7 @@
             {
                 new ErrorDialog(mainFrame,
                         Messages.getI18NString("chatRoomNotExist",
-                                new String[]{chatRoomName,
+                                new String[]{chatRoom.getName(),
                                 protocolProvider.getAccountID().getService()})
                             .getText(),
                         Messages.getI18NString("error").getText()).showDialog();
@@ -167,8 +176,35 @@
         }
         else if(buttonName.equals("channelList"))
         {
+            List list = null;
+            try
+            {
+                list = multiChatOpSet.getExistingChatRooms();
+            }
+            catch (OperationFailedException ex)
+            {
+                logger.error("Could not obtain existing chat rooms.", ex);
+            }
+            catch (OperationNotSupportedException ex)
+            {
+                logger.error("Could not obtain existing chat rooms.", ex);
+            }
 
+            if(list != null && list.size() > 0)
+            {
+                channelsList = new JList(list.toArray());
+                channelsListScrollPane.getViewport().add(channelsList);
+                
+                mainPanel.add(channelsListScrollPane, BorderLayout.SOUTH);
+                
+                mainPanel.revalidate();
+                mainPanel.repaint();
+            }
         }
     }
+    
+    protected void close(boolean isEscaped)
+    {
+    }
 }
 

File [changed]: ChatRoomServerRightButtonMenu.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomServerRightButtonMenu.java?r1=1.2&r2=1.3
Delta lines:  +6 -0
-------------------
--- ChatRoomServerRightButtonMenu.java	2007-04-24 12:28:31+0000	1.2
+++ ChatRoomServerRightButtonMenu.java	2007-05-03 14:23:20+0000	1.3
@@ -133,6 +133,12 @@
                 = new JoinChannelDialog(mainFrame, protocolProvider);
             
             joinChannelDialog.pack();
+            joinChannelDialog.setLocation(
+                Toolkit.getDefaultToolkit().getScreenSize().width/2
+                    - joinChannelDialog.getWidth()/2,
+                Toolkit.getDefaultToolkit().getScreenSize().height/2
+                    - joinChannelDialog.getHeight()/2
+                );
             joinChannelDialog.setVisible(true);
         }
     }   




---------------------------------------------------------------------
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