join chat room for multi chat

cusax-fix
Yana Stamcheva 20 years ago
parent 9cc40d9532
commit 49753a5678

@ -38,6 +38,7 @@ callList=Call list
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 @@ general=General
generalError=General error
group=Group
groupName=Group name
failedToJoinChannel=Failed to join channel {0}.
file=&File
finish=&Finish
first=First
@ -92,6 +94,7 @@ identifier=Identifier
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 @@ sendMessage=&Send a message
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

@ -20,6 +20,7 @@
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
@ -28,7 +29,7 @@
*
* @author Yana Stamcheva
*/
public class ChatRoomsListRightButtonMenu
public class ChatRoomServerRightButtonMenu
extends JPopupMenu
implements ActionListener,
PluginComponentListener
@ -36,27 +37,32 @@ public class ChatRoomsListRightButtonMenu
private I18NString createChatRoomString
= Messages.getI18NString("createChatRoom");
private I18NString searchForChatRoomsString
= Messages.getI18NString("searchForChatRooms");
private I18NString joinChannelString
= Messages.getI18NString("joinChatRoom");
private JMenuItem createChatRoomItem = new JMenuItem(
createChatRoomString.getText(),
new ImageIcon(ImageLoader.getImage(ImageLoader.CHAT_ROOM_16x16_ICON)));
private JMenuItem searchForChatRoomsItem = new JMenuItem(
searchForChatRoomsString.getText(),
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 ChatRoomsListRightButtonMenu(MainFrame mainFrame)
public ChatRoomServerRightButtonMenu(MainFrame mainFrame,
ProtocolProviderService protocolProvider)
{
super();
this.mainFrame = mainFrame;
this.protocolProvider = protocolProvider;
this.setLocation(getLocation());
@ -69,20 +75,20 @@ public ChatRoomsListRightButtonMenu(MainFrame mainFrame)
private void init()
{
this.add(createChatRoomItem);
this.add(searchForChatRoomsItem);
this.add(joinChannelItem);
this.initPluginComponents();
this.createChatRoomItem.setName("createChatRoom");
this.searchForChatRoomsItem.setName("searchForChatRooms");
this.joinChannelItem.setName("joinChatRoom");
this.createChatRoomItem
.setMnemonic(createChatRoomString.getMnemonic());
this.searchForChatRoomsItem
.setMnemonic(searchForChatRoomsString.getMnemonic());
this.joinChannelItem
.setMnemonic(joinChannelString.getMnemonic());
this.createChatRoomItem.addActionListener(this);
this.searchForChatRoomsItem.addActionListener(this);
this.joinChannelItem.addActionListener(this);
}
/**
@ -121,9 +127,13 @@ public void actionPerformed(ActionEvent e){
createChatRoomWizard.setVisible(true);
}
else if (itemName.equals("searchForChatRooms"))
else if (itemName.equals("joinChatRoom"))
{
JoinChannelDialog joinChannelDialog
= new JoinChannelDialog(mainFrame, protocolProvider);
joinChannelDialog.pack();
joinChannelDialog.setVisible(true);
}
}

@ -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 @@ public ChatRoomsList(MainFrame mainFrame)
this.setModel(listModel);
this.setCellRenderer(new ChatRoomsListCellRenderer());
this.addListSelectionListener(this);
this.addMouseListener(this);
}
/**
@ -124,6 +128,51 @@ public void valueChanged(ListSelectionEvent e)
ChatPanel chatPanel = chatWindowManager.getChatRoom(chatRoom);
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)
{}
}

@ -29,7 +29,7 @@ public class ChatRoomsListPanel
private JPanel treePanel = new JPanel(new BorderLayout());
private ChatRoomsListRightButtonMenu rightButtonMenu;
private ChatRoomServerRightButtonMenu rightButtonMenu;
/**
* Creates the scroll panel containing the chat rooms list.
@ -45,25 +45,7 @@ public ChatRoomsListPanel(MainFrame frame)
this.treePanel.add(chatRoomsList, BorderLayout.NORTH);
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(

@ -0,0 +1,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"))
{
}
}
}
Loading…
Cancel
Save