diff options
author | Damian Minkov <damencho@jitsi.org> | 2009-04-21 10:09:37 +0000 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2009-04-21 10:09:37 +0000 |
commit | bd4b9a2471e0f04359ae57bd138af1d7338a0155 (patch) | |
tree | 14d35626a3537542766beceb74a776271cebb1a9 /src/net/java/sip/communicator/impl | |
parent | f1be39ed74591a2a8d351bcd55853572ce01f0e2 (diff) | |
download | jitsi-bd4b9a2471e0f04359ae57bd138af1d7338a0155.zip jitsi-bd4b9a2471e0f04359ae57bd138af1d7338a0155.tar.gz jitsi-bd4b9a2471e0f04359ae57bd138af1d7338a0155.tar.bz2 |
Issue #544 (User list in chat rooms not searchable with keyboard).
Diffstat (limited to 'src/net/java/sip/communicator/impl')
4 files changed, 68 insertions, 49 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomMemberListPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomMemberListPanel.java index 5510ea3..c150b5d 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomMemberListPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomMemberListPanel.java @@ -45,6 +45,7 @@ public class ChatRoomMemberListPanel // this.chatPanel = chat; this.memberList.setModel(memberListModel); + this.memberList.addKeyListener(new CListKeySearchListener(memberList)); this.memberList.setCellRenderer(new ChatContactCellRenderer()); JScrollPane contactsScrollPane = new SCScrollPane(); diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/CListKeySearchListener.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/CListKeySearchListener.java index bcbadcc..597ab52 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/CListKeySearchListener.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/CListKeySearchListener.java @@ -11,6 +11,7 @@ import java.awt.event.*; import javax.swing.*; import javax.swing.text.*; +import net.java.sip.communicator.impl.gui.main.chat.conference.*; import net.java.sip.communicator.service.contactlist.*; /** @@ -130,6 +131,16 @@ public class CListKeySearchListener implements KeyListener { .equalsIgnoreCase(keyBuffer.toString()); } } + else if(selectedObject instanceof ConferenceChatContact) { + String selectedContactName = + ((ConferenceChatContact) selectedObject).getName(); + + if (selectedContactName != null) { + selectedSameLetterContact + = selectedContactName.substring(0, 1) + .equalsIgnoreCase(keyBuffer.toString()); + } + } } // The search starts from the beginning if: // 1) the newly entered character is different from the last one @@ -205,7 +216,7 @@ public class CListKeySearchListener implements KeyListener { ContactListModel model = (ContactListModel) contactList.getModel(); - System.out.println("close ? " + model.isGroupClosed(group)); + if (model.isGroupClosed(group)) { model.openGroup(group); diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java index 099c03f..c5329aa 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java @@ -289,54 +289,6 @@ public class ContactList } /** - * Returns the next list element that starts with a prefix. - * - * @param prefix the string to test for a match - * @param startIndex the index for starting the search - * @param bias the search direction, either Position.Bias.Forward or - * Position.Bias.Backward. - * @return the index of the next list element that starts with the prefix; - * otherwise -1 - */ - public int getNextMatch(String prefix, int startIndex, Position.Bias bias) - { - int max = listModel.getSize(); - - if (prefix == null) - throw new IllegalArgumentException("prefix"); - if (startIndex < 0 || startIndex >= max) - throw new IllegalArgumentException("startIndex"); - - prefix = prefix.toUpperCase(); - - // start search from the next element after the selected element - int increment = (bias == Position.Bias.Forward) ? 1 : -1; - int index = startIndex; - do - { - Object o = listModel.getElementAt(index); - - if (o != null) - { - String contactName = null; - - if (o instanceof MetaContact) - { - contactName = ((MetaContact) o).getDisplayName() - .toUpperCase(); - } - - if (contactName != null && contactName.startsWith(prefix)) - { - return index; - } - } - index = (index + increment + max) % max; - } while (index != startIndex); - return -1; - } - - /** * Returns the list of all groups. * * @return The list of all groups. diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java index 528e336..b89e5ae 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java @@ -11,8 +11,10 @@ import java.awt.event.*; import java.util.*; import javax.swing.*; +import javax.swing.text.*; import net.java.sip.communicator.impl.gui.main.chat.*; +import net.java.sip.communicator.impl.gui.main.chat.conference.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.protocol.*; @@ -200,4 +202,57 @@ public class DefaultContactList return null; } + + /** + * Returns the next list element that starts with a prefix. + * + * @param prefix the string to test for a match + * @param startIndex the index for starting the search + * @param bias the search direction, either Position.Bias.Forward or + * Position.Bias.Backward. + * @return the index of the next list element that starts with the prefix; + * otherwise -1 + */ + public int getNextMatch(String prefix, int startIndex, Position.Bias bias) + { + int max = getModel().getSize(); + + if (prefix == null) + throw new IllegalArgumentException("prefix"); + if (startIndex < 0 || startIndex >= max) + throw new IllegalArgumentException("startIndex"); + + prefix = prefix.toUpperCase(); + + // start search from the next element after the selected element + int increment = (bias == Position.Bias.Forward) ? 1 : -1; + int index = startIndex; + do + { + Object o = getModel().getElementAt(index); + + if (o != null) + { + String contactName = null; + + if (o instanceof MetaContact) + { + contactName = ((MetaContact) o).getDisplayName() + .toUpperCase(); + } + else if(o instanceof ConferenceChatContact) + { + contactName = ((ConferenceChatContact) o).getName() + .toUpperCase(); + } + + if (contactName != null && contactName.startsWith(prefix)) + { + return index; + } + } + index = (index + increment + max) % max; + } while (index != startIndex); + return -1; + } } |