From a16b56bc238ed8b673d8dc6abd718e88f737f6b8 Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Wed, 3 May 2006 09:26:12 +0000 Subject: [PATCH] Received messages from different contacts appear in the same tab - the current one. Trying to solve the problem. --- .../main/contactlist/ContactListPanel.java | 8 +++---- .../impl/gui/main/message/ChatWindow.java | 22 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java index 18c45232e..fe7e10653 100755 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java @@ -287,7 +287,7 @@ public void windowClosing(WindowEvent e) { Hashtable contactTabsTable = tabbedChatWindow.getContactTabsTable(); - if(contactTabsTable.get(this.contactItem.getDisplayName()) + if(contactTabsTable.get(this.contactItem.getMetaUID()) == null){ // If there's no open tab for the given contact. @@ -433,7 +433,7 @@ public void windowClosing(WindowEvent e) { Hashtable contactTabsTable = tabbedChatWindow.getContactTabsTable(); - if(contactTabsTable.get(metaContact.getDisplayName()) + if(contactTabsTable.get(metaContact.getMetaUID()) == null){ // If there's no open tab for the given contact. tabbedChatWindow.addChatTab(metaContact, contactStatus); @@ -560,7 +560,7 @@ else if(tabbedChatWindow != null){ Hashtable contactTabsTable = tabbedChatWindow.getContactTabsTable(); - if(contactTabsTable.get(metaContact.getDisplayName()) + if(contactTabsTable.get(metaContact.getMetaUID()) != null){ tabbedChatWindow.getChatPanel(metaContact) @@ -589,7 +589,7 @@ else if(tabbedChatWindow != null && tabbedChatWindow.getTabCount() > 0){ = tabbedChatWindow.getContactTabsTable(); ChatPanel chatPanel - = (ChatPanel)contactTabsTable.get(metaContact.getDisplayName()); + = (ChatPanel)contactTabsTable.get(metaContact.getMetaUID()); if(chatPanel != null){ int contactTabIndex = tabbedChatWindow.getTabInex(metaContact); diff --git a/src/net/java/sip/communicator/impl/gui/main/message/ChatWindow.java b/src/net/java/sip/communicator/impl/gui/main/message/ChatWindow.java index d444ec52d..46e337d30 100755 --- a/src/net/java/sip/communicator/impl/gui/main/message/ChatWindow.java +++ b/src/net/java/sip/communicator/impl/gui/main/message/ChatWindow.java @@ -255,7 +255,7 @@ public void closeOperation(MouseEvent e){ //Set the tab index even it's not yet shown in tabbed pane this.currentChatPanel.setTabIndex(0); - this.contactTabsTable.put(contact.getDisplayName(), + this.contactTabsTable.put(contact.getMetaUID(), currentChatPanel); this.setTitle(contact.getDisplayName()); @@ -280,7 +280,7 @@ public void closeOperation(MouseEvent e){ this.currentChatPanel .setTabIndex(chatTabbedPane.getTabCount() - 1); - this.contactTabsTable.put(contact.getDisplayName(), + this.contactTabsTable.put(contact.getMetaUID(), currentChatPanel); } else{ @@ -306,7 +306,7 @@ public void closeOperation(MouseEvent e){ currentChatPanel .setTabIndex(chatTabbedPane.getTabCount() - 1); - this.contactTabsTable.put(contact.getDisplayName(), + this.contactTabsTable.put(contact.getMetaUID(), currentChatPanel); } @@ -325,7 +325,7 @@ public void setSelectedContactTab(MetaContact contact){ if(this.contactTabsTable != null && !this.contactTabsTable.isEmpty()){ ChatPanel chatPanel = ((ChatPanel)this.contactTabsTable - .get(contact.getDisplayName())); + .get(contact.getMetaUID())); this.chatTabbedPane.setSelectedIndex(chatPanel.getTabIndex()); chatPanel.getWriteMessagePanel() @@ -358,9 +358,11 @@ public void removeContactTab(int index){ String title = chatTabbedPane.getTitleAt(index); + ChatPanel selectedChat = (ChatPanel)chatTabbedPane.getComponentAt(index); + if(title != null){ if(chatTabbedPane.getTabCount() > 1) - this.contactTabsTable.remove(title); + this.contactTabsTable.remove(selectedChat.getDefaultContact().getMetaUID()); Enumeration contactTabs = this.contactTabsTable.elements(); @@ -388,13 +390,13 @@ public void removeContactTab(int index){ String onlyTabtitle = chatTabbedPane.getTitleAt(0); + ChatPanel chatPanel + = (ChatPanel)this.chatTabbedPane.getComponentAt(0); + this.getContentPane().remove(chatTabbedPane); this.chatTabbedPane.removeAll(); - ChatPanel chatPanel - = (ChatPanel)this.contactTabsTable.get(onlyTabtitle); - this.getContentPane().add(chatPanel, BorderLayout.CENTER); this.setCurrentChatPanel(chatPanel); @@ -450,7 +452,7 @@ public int getTabCount(){ */ public int getTabInex(MetaContact contact){ return ((ChatPanel)this.contactTabsTable - .get(contact.getDisplayName())).getTabIndex(); + .get(contact.getMetaUID())).getTabIndex(); } /** @@ -469,7 +471,7 @@ public void highlightTab(MetaContact contact){ * @return ChatPanel The ChatPanel for the given MetaContact. */ public ChatPanel getChatPanel(MetaContact contact){ - return (ChatPanel)this.contactTabsTable.get(contact.getDisplayName()); + return (ChatPanel)this.contactTabsTable.get(contact.getMetaUID()); } /**