diff options
author | Yana Stamcheva <yana@jitsi.org> | 2007-09-11 17:52:39 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2007-09-11 17:52:39 +0000 |
commit | 6b49e913b68ea477a12437f0629177bc47df3262 (patch) | |
tree | cbe22b713568984bd83c95bb61a682ec8aecfa90 /src | |
parent | 12e3c7162ecb31f0f87f588ca4808c3109623a2b (diff) | |
download | jitsi-6b49e913b68ea477a12437f0629177bc47df3262.zip jitsi-6b49e913b68ea477a12437f0629177bc47df3262.tar.gz jitsi-6b49e913b68ea477a12437f0629177bc47df3262.tar.bz2 |
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
Diffstat (limited to 'src')
3 files changed, 81 insertions, 14 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomDialog.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomDialog.java index 5e1103c..6964a5c 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomDialog.java @@ -12,10 +12,12 @@ import java.util.*; 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 class JoinChatRoomDialog 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 class JoinChatRoomDialog 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 class JoinChatRoomDialog * <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 class JoinChatRoomDialog public void run() { ChatRoom chatRoom = null; - + String chatRoomName = namePanel.getChatRoomName(); - + try { chatRoom = multiUserChatOpSet @@ -147,7 +153,7 @@ public class JoinChatRoomDialog + chatRoomName, e1); } catch (OperationNotSupportedException e1) - { + { logger.error("Failed to find chat room with name:" + chatRoomName, e1); } @@ -163,7 +169,10 @@ public class JoinChatRoomDialog .showDialog(); } else - { + { + mainFrame.getChatRoomsListPanel().getChatRoomsList() + .addChatRoom(new ChatRoomWrapper(chatRoom)); + mainFrame.getMultiUserChatManager() .joinChatRoom(chatRoom); } @@ -185,7 +194,7 @@ public class JoinChatRoomDialog * Loads the list of existing server chat rooms. */ public void loadChatRoomsList() - { + { OperationSetMultiUserChat multiUserChat = (OperationSetMultiUserChat) protocolProvider .getOperationSet(OperationSetMultiUserChat.class); @@ -216,6 +225,32 @@ public class JoinChatRoomDialog 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()); } } }
\ No newline at end of file diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomPanel.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomPanel.java index 9f95052..e0a74a9 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/JoinChatRoomPanel.java @@ -60,12 +60,12 @@ public class 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 class JoinChatRoomPanel { 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(); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/SearchChatRoomPanel.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/SearchChatRoomPanel.java index 20ad051..b00fbec 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/SearchChatRoomPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/SearchChatRoomPanel.java @@ -57,8 +57,26 @@ public class SearchChatRoomPanel 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)); } } |