Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.gui.main.chat
Class ChatWindowManager

java.lang.Object
  extended by net.java.sip.communicator.impl.gui.main.chat.ChatWindowManager

public class ChatWindowManager
extends Object

Manages chat windows and panels.

Author:
Yana Stamcheva, Valentin Martinet, Lubomir Marinov

Constructor Summary
ChatWindowManager()
           
 
Method Summary
 void addChatListener(ChatListener listener)
          Registers a NewChatListener to be informed when new Chats are created.
(package private)  void closeAllChats(ChatContainer chatContainer, boolean warningEnabled)
          Closes all chats in the specified ChatContainer and makes them available for garbage collection.
 void closeChat(ChatPanel chatPanel)
          Closes the given chat panel.
 Collection<ChatPanel> getAllChats()
          Returns all currently instantiated ChatPanels.
 List<ChatPanel> getChatPanels()
          Returns all open ChatPanels.
 ChatPanel getContactChat(MetaContact metaContact, boolean create)
          Gets the ChatPanel corresponding to the specified MetaContact and optionally creates it if it does not exist.
 ChatPanel getContactChat(MetaContact metaContact, Contact protocolContact)
          Returns the chat panel corresponding to the given meta contact
 ChatPanel getContactChat(MetaContact metaContact, Contact protocolContact, String escapedMessageID)
          Returns the chat panel corresponding to the given meta contact
 ChatPanel getMultiChat(AdHocChatRoom adHocChatRoom, boolean create)
          Gets the ChatPanel corresponding to the specified AdHocChatRoom and optionally creates it if it does not exist.
 ChatPanel getMultiChat(AdHocChatRoom adHocChatRoom, boolean create, String escapedMessageID)
          Gets the ChatPanel corresponding to the specified AdHocChatRoom and optionally creates it if it does not exist.
 ChatPanel getMultiChat(AdHocChatRoomWrapper chatRoomWrapper, boolean create)
          Gets the ChatPanel corresponding to the specified AdHocChatRoomWrapper and optionally creates it if it does not exist yet.
 ChatPanel getMultiChat(ChatRoom chatRoom, boolean create)
          Gets the ChatPanel corresponding to the specified ChatRoom and optionally creates it if it does not exist.
 ChatPanel getMultiChat(ChatRoom chatRoom, boolean create, String escapedMessageID)
          Gets the ChatPanel corresponding to the specified ChatRoom and optionally creates it if it does not exist.
 ChatPanel getMultiChat(ChatRoomWrapper chatRoomWrapper, boolean create)
          Gets the ChatPanel corresponding to the specified ChatRoomWrapper and optionally creates it if it does not exist yet.
 ChatPanel getSelectedChat()
          Returns the currently selected ChatPanel.
 boolean isChatOpenedFor(MetaContact metaContact)
          Returns true if there is an opened ChatPanel for the given MetaContact.
 void openChat(ChatPanel chatPanel, boolean setSelected)
          Opens the specified ChatPanel and optinally brings it to the front.
 void removeChatListener(ChatListener listener)
          Removes the registration of a NewChatListener.
 void removeNonReadChatState(ChatPanel chatPanel)
          Removes the non read state of the currently selected chat session.
 void startChat(MetaContact metaContact)
          Starts a chat with the given MetaContact.
 void startChat(MetaContact metaContact, Contact protocolContact, boolean isSmsMessage)
          Starts a chat with the given MetaContact.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChatWindowManager

public ChatWindowManager()
Method Detail

openChat

public void openChat(ChatPanel chatPanel,
                     boolean setSelected)
Opens the specified ChatPanel and optinally brings it to the front.

Parameters:
chatPanel - the ChatPanel to be opened
setSelected - true if chatPanel (and respectively its ChatWindow) should be brought to the front; otherwise, false

isChatOpenedFor

public boolean isChatOpenedFor(MetaContact metaContact)
Returns true if there is an opened ChatPanel for the given MetaContact.

Parameters:
metaContact - the MetaContact, for which the chat is about
Returns:
true if there is an opened ChatPanel for the given MetaContact

closeChat

public void closeChat(ChatPanel chatPanel)
Closes the given chat panel.

Parameters:
chatPanel - the chat panel to close

closeAllChats

void closeAllChats(ChatContainer chatContainer,
                   boolean warningEnabled)
Closes all chats in the specified ChatContainer and makes them available for garbage collection.

Parameters:
chatContainer - the ChatContainer containing the chats to close
warningEnabled - indicates if the user should be warned that we're closing all the chats. This would be done only if there are currently active file transfers or waiting messages

getContactChat

public ChatPanel getContactChat(MetaContact metaContact,
                                boolean create)
Gets the ChatPanel corresponding to the specified MetaContact and optionally creates it if it does not exist.

Parameters:
metaContact - the MetaContact to get the corresponding ChatPanel of
create - true to create a ChatPanel corresponding to the specified MetaContact if such ChatPanel does not exist yet
Returns:
the ChatPanel corresponding to the specified MetaContact; null if there is no such ChatPanel and create is false

getContactChat

public ChatPanel getContactChat(MetaContact metaContact,
                                Contact protocolContact)
Returns the chat panel corresponding to the given meta contact

Parameters:
metaContact - the meta contact.
protocolContact - the protocol specific contact
Returns:
the chat panel corresponding to the given meta contact

getContactChat

public ChatPanel getContactChat(MetaContact metaContact,
                                Contact protocolContact,
                                String escapedMessageID)
Returns the chat panel corresponding to the given meta contact

Parameters:
metaContact - the meta contact.
protocolContact - the protocol specific contact
escapedMessageID - the message ID of the message that should be excluded from the history when the last one is loaded in the chat
Returns:
the chat panel corresponding to the given meta contact

getSelectedChat

public ChatPanel getSelectedChat()
Returns the currently selected ChatPanel.

Returns:
the currently selected ChatPanel

getMultiChat

public ChatPanel getMultiChat(ChatRoomWrapper chatRoomWrapper,
                              boolean create)
Gets the ChatPanel corresponding to the specified ChatRoomWrapper and optionally creates it if it does not exist yet.

Parameters:
chatRoomWrapper - the ChatRoomWrapper to get the corresponding ChatPanel of
create - true to create a new ChatPanel for the specified ChatRoomWrapper if no such ChatPanel exists already; otherwise, false
Returns:
the ChatPanel corresponding to the specified ChatRoomWrapper or null if no such ChatPanel exists and create is false

getMultiChat

public ChatPanel getMultiChat(AdHocChatRoomWrapper chatRoomWrapper,
                              boolean create)
Gets the ChatPanel corresponding to the specified AdHocChatRoomWrapper and optionally creates it if it does not exist yet.

Parameters:
chatRoomWrapper - the AdHocChatRoomWrapper to get the corresponding ChatPanel of
create - true to create a new ChatPanel for the specified AdHocChatRoomWrapper if no such ChatPanel exists already; otherwise, false
Returns:
the ChatPanel corresponding to the specified AdHocChatRoomWrapper or null if no such ChatPanel exists and create is false

getMultiChat

public ChatPanel getMultiChat(AdHocChatRoom adHocChatRoom,
                              boolean create)
Gets the ChatPanel corresponding to the specified AdHocChatRoom and optionally creates it if it does not exist.

Parameters:
adHocChatRoom - the AdHocChatRoom to get the corresponding ChatPanel of
create - true to create a ChatPanel corresponding to the specified AdHocChatRoom if such ChatPanel does not exist yet
Returns:
the ChatPanel corresponding to the specified AdHocChatRoom; null if there is no such ChatPanel and create is false

getMultiChat

public ChatPanel getMultiChat(ChatRoom chatRoom,
                              boolean create)
Gets the ChatPanel corresponding to the specified ChatRoom and optionally creates it if it does not exist.

Parameters:
chatRoom - the ChatRoom to get the corresponding ChatPanel of
create - true to create a ChatPanel corresponding to the specified ChatRoom if such ChatPanel does not exist yet
Returns:
the ChatPanel corresponding to the specified ChatRoom; null if there is no such ChatPanel and create is false

getMultiChat

public ChatPanel getMultiChat(ChatRoom chatRoom,
                              boolean create,
                              String escapedMessageID)
Gets the ChatPanel corresponding to the specified ChatRoom and optionally creates it if it does not exist.

Parameters:
chatRoom - the ChatRoom to get the corresponding ChatPanel of
create - true to create a ChatPanel corresponding to the specified ChatRoom if such ChatPanel does not exist yet
escapedMessageID - the message ID of the message that should be excluded from the history when the last one is loaded in the chat
Returns:
the ChatPanel corresponding to the specified ChatRoom; null if there is no such ChatPanel and create is false

getMultiChat

public ChatPanel getMultiChat(AdHocChatRoom adHocChatRoom,
                              boolean create,
                              String escapedMessageID)
Gets the ChatPanel corresponding to the specified AdHocChatRoom and optionally creates it if it does not exist.

Parameters:
adHocChatRoom - the AdHocChatRoom to get the corresponding ChatPanel of
create - true to create a ChatPanel corresponding to the specified AdHocChatRoom if such ChatPanel does not exist yet
escapedMessageID - the message ID of the message that should be excluded from the history when the last one is loaded in the chat
Returns:
the ChatPanel corresponding to the specified AdHocChatRoom; null if there is no such ChatPanel and create is false

getChatPanels

public List<ChatPanel> getChatPanels()
Returns all open ChatPanels.

Returns:
A list of ChatPanels

startChat

public void startChat(MetaContact metaContact)
Starts a chat with the given MetaContact.

Parameters:
metaContact - the destination MetaContact

startChat

public void startChat(MetaContact metaContact,
                      Contact protocolContact,
                      boolean isSmsMessage)
Starts a chat with the given MetaContact.

Parameters:
metaContact - the destination MetaContact
protocolContact - the protocol contact of the destination
isSmsMessage - indicates if the chat should be opened for an SMS message

removeNonReadChatState

public void removeNonReadChatState(ChatPanel chatPanel)
Removes the non read state of the currently selected chat session. This will result in removal of all icons representing the non read state (like envelopes in contact list).

Parameters:
chatPanel - the ChatPanel for which we would like to remove non read chat state

getAllChats

public Collection<ChatPanel> getAllChats()
Returns all currently instantiated ChatPanels.

Returns:
all instantiated ChatPanels

addChatListener

public void addChatListener(ChatListener listener)
Registers a NewChatListener to be informed when new Chats are created.

Parameters:
listener - listener to be registered

removeChatListener

public void removeChatListener(ChatListener listener)
Removes the registration of a NewChatListener.

Parameters:
listener - listener to be unregistered

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.