1) methods to add and remove more than one contacts removed

2) ChatPanel implements ChatConversationContainer
cusax-fix
Yana Stamcheva 20 years ago
parent c44a1cac43
commit 70bf4411da

@ -85,7 +85,7 @@ private void init() {
* Adds a <tt>MetaContact</tt> to the chat.
* @param contactItem The <tt>MetaContact</tt> to be added.
*/
public void addContactToChat(MetaContact contactItem) {
public void setChatMetaContact(MetaContact contactItem) {
this.chatContactPanel = new ChatContactPanel(contactItem);
@ -98,7 +98,7 @@ public void addContactToChat(MetaContact contactItem) {
* @param contactItem The <tt>MetaContact</tt> to be added.
* @param status The <tt>PresenceStatus</tt> of the contact.
*/
public void addContactToChat(MetaContact contactItem,
public void setChatMetaContact(MetaContact contactItem,
PresenceStatus status) {
chatContactPanel = new ChatContactPanel(contactItem, status);

@ -0,0 +1,16 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.main.message;
import java.awt.Window;
public interface ChatConversationContainer {
public void setStatusMessage(String message);
public Window getWindow();
}

@ -75,7 +75,7 @@ public class ChatConversationPanel extends JScrollPane implements
private HTMLDocument document;
private ChatPanel chatPanel;
private ChatConversationContainer chatContainer;
private ChatRightButtonMenu rightButtonMenu;
@ -105,14 +105,14 @@ public class ChatConversationPanel extends JScrollPane implements
* Creates an instance of <tt>ChatConversationPanel</tt>.
* @param chatPanel The parent <tt>ChatPanel</tt>.
*/
public ChatConversationPanel(ChatPanel chatPanel) {
public ChatConversationPanel(ChatConversationContainer chatContainer) {
super();
this.chatPanel = chatPanel;
this.chatContainer = chatContainer;
this.rightButtonMenu
= new ChatRightButtonMenu(chatPanel.getChatWindow());
= new ChatRightButtonMenu(this);
this.document = (HTMLDocument) editorKit.createDefaultDocument();
@ -127,7 +127,7 @@ public ChatConversationPanel(ChatPanel chatPanel) {
Constants.loadSimpleStyle(document.getStyleSheet());
this.initEditor();
//this.initEditor();
this.chatEditorPane.addHyperlinkListener(this);
this.chatEditorPane.addMouseListener(this);
@ -375,7 +375,7 @@ public void hyperlinkUpdate(HyperlinkEvent e) {
} else if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
String href = e.getDescription();
this.chatPanel.setChatStatusMessage(href);
this.chatContainer.setStatusMessage(href);
this.currentHref = href;
/*
@ -396,7 +396,7 @@ public void hyperlinkUpdate(HyperlinkEvent e) {
} else if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
this.chatPanel.setChatStatusMessage("");
this.chatContainer.setStatusMessage("");
this.currentHref = "";
/*
* Tooltip on hyperlinks - JDK1.5+
@ -495,4 +495,17 @@ public void mouseExited(MouseEvent e) {
public void lostOwnership(Clipboard clipboard, Transferable contents) {
}
public ChatConversationContainer getChatContainer() {
return chatContainer;
}
/**
* Copies the selected conversation panel content to the clipboard.
*/
public void copyConversation(){
JEditorPane editorPane = this.getChatEditorPane();
editorPane.copy();
}
}

@ -11,6 +11,7 @@
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.io.IOException;
@ -51,7 +52,7 @@
* @author Yana Stamcheva
*/
public class ChatPanel extends JPanel
implements ExportedDialog {
implements ExportedDialog, ChatConversationContainer {
private static final Logger logger = Logger
.getLogger(ChatPanel.class.getName());
@ -69,8 +70,6 @@ public class ChatPanel extends JPanel
private ChatSendPanel sendPanel;
private Vector chatContacts = new Vector();
private ChatWindow chatWindow;
private OperationSetBasicInstantMessaging imOperationSet;
@ -79,6 +78,8 @@ public class ChatPanel extends JPanel
private Contact protocolContact;
private MetaContact metaContact;
private boolean isVisible = false;
@ -89,12 +90,16 @@ public class ChatPanel extends JPanel
* @param protocolContact The subContact which is selected ins
* the chat.
*/
public ChatPanel(ChatWindow chatWindow, Contact protocolContact) {
public ChatPanel( ChatWindow chatWindow,
MetaContact metaContact,
Contact protocolContact) {
super(new BorderLayout());
this.chatWindow = chatWindow;
this.metaContact = metaContact;
this.protocolContact = protocolContact;
this.imOperationSet = this.chatWindow.getMainFrame().getProtocolIM(
protocolContact.getProtocolProvider());
this.tnOperationSet = this.chatWindow.getMainFrame()
@ -115,6 +120,8 @@ public ChatPanel(ChatWindow chatWindow, Contact protocolContact) {
this.init();
this.setChatMetaContact(metaContact, protocolContact.getPresenceStatus());
addComponentListener(new TabSelectionFocusGainListener());
}
@ -140,13 +147,13 @@ private void init() {
* @param contactItem The MetaContact to add.
* @param status The current presence status of the contact.
*/
public void addContactToChat(MetaContact contactItem,
private void setChatMetaContact(MetaContact metaContact,
PresenceStatus status) {
this.chatContacts.add(contactItem);
this.metaContact = metaContact;
this.chatConferencePanel.addContactToChat(contactItem, status);
this.chatConferencePanel.setChatMetaContact(metaContact, status);
this.sendPanel.addProtocolContacts(contactItem);
this.sendPanel.addProtocolContacts(metaContact);
this.sendPanel.setSelectedProtocolContact(this.protocolContact);
}
@ -156,42 +163,13 @@ public void addContactToChat(MetaContact contactItem,
*
* @param contactItem The <tt>MetaContact</tt> to add.
*/
public void addContactToChat(MetaContact contactItem) {
this.chatContacts.add(contactItem);
this.chatConferencePanel.addContactToChat(contactItem);
private void setChatMetaContact(MetaContact metaContact) {
this.sendPanel.addProtocolContacts(contactItem);
}
/**
* Removes a <tt>MetaContact</tt> from the chat.
*
* @param contactItem The <tt>MetaContact</tt> to remove.
*/
public void removeContactFromChat(MetaContact contactItem) {
this.chatContacts.remove(contactItem);
}
this.metaContact = metaContact;
/**
* Returns a list of contacts corresponding to this chat.
*
* @return A Vector containing all MetaContact-s
* for the chat.
*/
public Vector getChatContacts() {
return chatContacts;
}
this.chatConferencePanel.setChatMetaContact(metaContact);
/**
* Sets all contacts for this chat. This is in the
* case when we creates a conference chat.
*
* @param chatContacts A Vector of MetaContact-s.
*/
public void setChatContacts(Vector chatContacts) {
this.chatContacts = chatContacts;
this.sendPanel.addProtocolContacts(metaContact);
}
/**
@ -203,35 +181,14 @@ public void updateContactStatus(PresenceStatus status) {
this.chatConferencePanel.updateContactStatus(status);
}
/**
* Returns the panel that contains the "write" editor
* pane of this chat.
*
* @return The ChatWritePanel.
*/
/*
public ChatWritePanel getWriteMessagePanel() {
return writeMessagePanel;
}
*/
/**
* Returns the panel that contains the conversation.
*
* @return The ChatConversationPanel.
*/
/*
public ChatConversationPanel getConversationPanel() {
return conversationPanel;
}
*/
/**
* Returns the default contact for the chat. The case of conference
* is not yet implemented and for now it returns the first contact.
*
* @return The default contact for the chat.
*/
public MetaContact getDefaultContact() {
return (MetaContact) this.getChatContacts().get(0);
public MetaContact getMetaContact() {
return this.metaContact;
}
/**
@ -245,6 +202,17 @@ public ChatWindow getChatWindow() {
return chatWindow;
}
/**
* Returns the chat window, where this chat panel
* is located.
*
* @return ChatWindow The chat window, where this
* chat panel is located.
*/
public Window getWindow() {
return chatWindow;
}
/**
* Returns the instant messaging operation set for
* this chat panel.
@ -318,7 +286,7 @@ public void componentShown(ComponentEvent e) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
getChatWindow().setTitle(
getDefaultContact().getDisplayName());
getMetaContact().getDisplayName());
chatWindow.setCurrentChatPanel(ChatPanel.this);
@ -390,8 +358,8 @@ public void requestFocusInWriteArea(){
* window. Used to show typing notification messages, links' hrefs, etc.
* @param statusMessage The message text to be displayed.
*/
public void setChatStatusMessage(String statusMessage){
this.sendPanel.setChatStatusMessage(statusMessage);
public void setStatusMessage(String statusMessage){
this.sendPanel.setStatusMessage(statusMessage);
}
/**
@ -466,15 +434,6 @@ public void copy(){
editorPane.copy();
}
/**
* Copies the selected conversation panel content to the clipboard.
*/
public void copyConversation(){
JEditorPane editorPane = this.conversationPanel.getChatEditorPane();
editorPane.copy();
}
/**
* Copies the selected write panel content to the clipboard.
*/
@ -557,7 +516,7 @@ public void openProtocolSelectorBox() {
* panel.
*/
public PresenceStatus getPresenceStatus() {
return getDefaultContact().getDefaultContact().getPresenceStatus();
return getMetaContact().getDefaultContact().getPresenceStatus();
}
/**
@ -581,7 +540,7 @@ public void showDialog() {
if(!contactChats.containsValue(this))
this.chatWindow.addChatTab(this);
else
this.chatWindow.setSelectedContactTab(getDefaultContact());
this.chatWindow.setSelectedContactTab(getMetaContact());
}
else {
if(!contactChats.containsValue(this))

@ -174,7 +174,7 @@ public void addProtocolContacts(MetaContact metaContact) {
* window. Used to show typing notification messages, links' hrefs, etc.
* @param statusMessage The message text to be displayed.
*/
public void setChatStatusMessage(String statusMessage) {
public void setStatusMessage(String statusMessage) {
int stringWidth = StringUtils
.getStringWidth(statusLabel, statusMessage);

@ -228,10 +228,9 @@ private void closeChat() {
public ChatPanel createChat(MetaContact contact,
PresenceStatus status, Contact protocolContact) {
ChatPanel chatPanel = new ChatPanel(this, protocolContact);
ChatPanel chatPanel = new ChatPanel(
this, contact, protocolContact);
chatPanel.addContactToChat(contact, status);
this.contactChats.put(contact.getMetaUID(), chatPanel);
// this.sendPanel.addProtocols(contactItem.getProtocolList());
@ -251,7 +250,7 @@ public void addChat(ChatPanel chatPanel) {
this.getContentPane().add(this.currentChatPanel, BorderLayout.CENTER);
this.windowTitle += chatPanel.getDefaultContact()
this.windowTitle += chatPanel.getMetaContact()
.getDisplayName() + " ";
this.setTitle(this.windowTitle);
@ -267,7 +266,7 @@ public void addChat(ChatPanel chatPanel) {
public void addChatTab(ChatPanel chatPanel) {
chatPanel.setChatVisible(true);
String contactName = chatPanel.getDefaultContact().getDisplayName();
String contactName = chatPanel.getMetaContact().getDisplayName();
PresenceStatus status = chatPanel.getPresenceStatus();
if (chatTabbedPane == null) {
@ -304,7 +303,7 @@ public void closeOperation(MouseEvent e) {
PresenceStatus currentContactStatus = firstChatPanel
.getPresenceStatus();
//Add first two tabs to the tabbed pane.
chatTabbedPane.addTab(firstChatPanel.getDefaultContact()
chatTabbedPane.addTab(firstChatPanel.getMetaContact()
.getDisplayName(), new ImageIcon(Constants
.getStatusIcon(currentContactStatus)), firstChatPanel);
@ -344,7 +343,7 @@ public void setSelectedContactTab(MetaContact contact) {
.get(contact.getMetaUID()));
this.chatTabbedPane.setSelectedComponent(chatPanel);
this.setTitle(chatPanel.getDefaultContact().getDisplayName());
this.setTitle(chatPanel.getMetaContact().getDisplayName());
this.setCurrentChatPanel(chatPanel);
chatPanel.requestFocusInWriteArea();
}
@ -360,7 +359,7 @@ public void setSelectedContactTab(int index) {
this.setCurrentChatPanel(chatPanel);
this.chatTabbedPane.setSelectedIndex(index);
this.setTitle(chatPanel.getDefaultContact().getDisplayName());
this.setTitle(chatPanel.getMetaContact().getDisplayName());
this.setVisible(true);
chatPanel.requestFocusInWriteArea();
}
@ -378,7 +377,7 @@ public void removeContactTab(int index) {
if (title != null) {
if (chatTabbedPane.getTabCount() > 1) {
this.contactChats.remove(closeChat.getDefaultContact()
this.contactChats.remove(closeChat.getMetaContact()
.getMetaUID());
}
@ -419,7 +418,7 @@ public void removeChat(ChatPanel chatPanel) {
*/
public void removeChatTab(ChatPanel chatPanel) {
this.chatTabbedPane.remove(chatPanel);
this.contactChats.remove(chatPanel.getDefaultContact().getMetaUID());
this.contactChats.remove(chatPanel.getMetaContact().getMetaUID());
this.validate();
}

Loading…
Cancel
Save