Modifications in the join chat room dialog:

- run the search in a new thread
	- set a wait cursor while the search is processed
	- when a chat room is selected in the list set the name in the above text area
cusax-fix
Yana Stamcheva 19 years ago
parent 12e3c7162e
commit 6b49e913b6

@ -12,10 +12,12 @@
import java.util.List;
import javax.swing.*;
import javax.swing.event.*;
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.main.chat.conference.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
@ -78,8 +80,8 @@ public JoinChatRoomDialog(MainFrame mainFrame,
this.multiUserChatOpSet
= (OperationSetMultiUserChat) protocolProvider
.getOperationSet(OperationSetMultiUserChat.class);
searchPanel = new SearchChatRoomPanel(this);
this.searchPanel = new SearchChatRoomPanel(this);
this.setTitle(Messages.getI18NString("joinChatRoom").getText());
@ -114,6 +116,9 @@ public JoinChatRoomDialog(MainFrame mainFrame,
this.getContentPane().add(iconLabel, BorderLayout.WEST);
this.getContentPane().add(mainPanel, BorderLayout.CENTER);
this.getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
this.chatRoomsList.addListSelectionListener(
new ChatRoomListSelectionListener());
}
/**
@ -122,10 +127,11 @@ public JoinChatRoomDialog(MainFrame mainFrame,
* <br>
* Note: No specific properties are set right now!
*/
public void actionPerformed(ActionEvent e) {
public void actionPerformed(ActionEvent e)
{
JButton button = (JButton)e.getSource();
String name = button.getName();
if (name.equals("join"))
{
new Thread()
@ -133,9 +139,9 @@ public void actionPerformed(ActionEvent e) {
public void run()
{
ChatRoom chatRoom = null;
String chatRoomName = namePanel.getChatRoomName();
try
{
chatRoom = multiUserChatOpSet
@ -147,7 +153,7 @@ public void run()
+ chatRoomName, e1);
}
catch (OperationNotSupportedException e1)
{
{
logger.error("Failed to find chat room with name:"
+ chatRoomName, e1);
}
@ -163,7 +169,10 @@ public void run()
.showDialog();
}
else
{
{
mainFrame.getChatRoomsListPanel().getChatRoomsList()
.addChatRoom(new ChatRoomWrapper(chatRoom));
mainFrame.getMultiUserChatManager()
.joinChatRoom(chatRoom);
}
@ -185,7 +194,7 @@ protected void close(boolean isEscaped)
* Loads the list of existing server chat rooms.
*/
public void loadChatRoomsList()
{
{
OperationSetMultiUserChat multiUserChat
= (OperationSetMultiUserChat) protocolProvider
.getOperationSet(OperationSetMultiUserChat.class);
@ -216,6 +225,32 @@ public void loadChatRoomsList()
this.mainPanel.add(chatRoomsScrollPane);
this.pack();
// When we're finished we replace the "wait cursor"
// by the default cursor.
this.setCursor(Cursor.getDefaultCursor());
}
}
/**
* The <tt>ListSelectionListener</tt> of the chat rooms list. When a chat
* room is selected in the list, we update the text field containing the
* name of the chat room to join.
*/
private class ChatRoomListSelectionListener
implements ListSelectionListener
{
/**
* When a chat room is selected in the list, we update the text field
* containing the name of the chat room to join.
*/
public void valueChanged(ListSelectionEvent e)
{
if(e.getValueIsAdjusting())
return;
namePanel.setChatRoomName(
chatRoomsList.getSelectedValue().toString());
}
}
}

@ -60,12 +60,12 @@ public JoinChatRoomPanel()
this.infoTitleLabel.setFont(Constants.FONT.deriveFont(Font.BOLD, 18));
this.labelsPanel.add(infoTitleLabel);
this.labelsPanel.add(infoLabel);
this.labelsPanel.add(infoLabel);
this.labelsPanel.add(dataPanel);
this.rightPanel.add(labelsPanel, BorderLayout.NORTH);
this.add(rightPanel, BorderLayout.CENTER);
this.add(rightPanel, BorderLayout.CENTER);
}
/**
@ -76,8 +76,22 @@ public String getChatRoomName()
{
return textField.getText();
}
public void requestFocusInField() {
/**
* Sets the given chat room name to the text field, contained in this panel.
*
* @param chatRoomName the chat room name to set to the text field
*/
public void setChatRoomName(String chatRoomName)
{
textField.setText(chatRoomName);
}
/**
* Requests the focus in the name text field.
*/
public void requestFocusInField()
{
this.textField.requestFocus();
}
}

@ -57,8 +57,26 @@ public SearchChatRoomPanel(JoinChatRoomDialog joinChatRoomDialog)
this.add(searchPanel);
}
/**
* Invoked when the Search button is clicked.
*/
public void actionPerformed(ActionEvent e)
{
joinChatRoomDialog.loadChatRoomsList();
new Thread()
{
public void run()
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
joinChatRoomDialog.loadChatRoomsList();
}
});
}
}.start();
joinChatRoomDialog.setCursor(
Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
}

Loading…
Cancel
Save