Fix the multi chat windows behavior.

cusax-fix
Yana Stamcheva 18 years ago
parent b9d53623bf
commit 34a4becadb

@ -71,7 +71,7 @@ public ChatWindow(MainFrame mainFrame)
menusPanel = new MenusPanel(this);
//If in mode TABBED_CHAT_WINDOW initialize the tabbed pane
if(Constants.TABBED_CHAT_WINDOW)
if(ConfigurationManager.isMultiChatWindowEnabled())
{
chatTabbedPane = new SIPCommTabbedPane(true, false);
@ -151,7 +151,7 @@ public MainToolBar getMainToolBar()
*/
public void addChat(ChatPanel chatPanel)
{
if (Constants.TABBED_CHAT_WINDOW)
if (ConfigurationManager.isMultiChatWindowEnabled())
addChatTab(chatPanel);
else
addSimpleChat(chatPanel);
@ -348,9 +348,11 @@ public ChatPanel getCurrentChatPanel()
for (int i = 0; i < componentCount; i ++)
{
Component c = getContentPane().getComponent(i);
if(c instanceof ChatPanel)
{
return (ChatPanel)c;
}
}
}
return null;
@ -602,7 +604,7 @@ else if (selectedMenu != null
}
else
{
mainFrame.getChatWindowManager().closeWindow();
mainFrame.getChatWindowManager().closeWindow(this);
}
}

@ -30,8 +30,6 @@ public class ChatWindowManager
{
private Logger logger = Logger.getLogger(ChatWindowManager.class);
private ChatWindow chatWindow;
private Hashtable chats = new Hashtable();
private MainFrame mainFrame;
@ -58,7 +56,7 @@ public void openChat(ChatPanel chatPanel, boolean setSelected)
ChatWindow chatWindow = chatPanel.getChatWindow();
boolean isChatVisible = chatPanel.isShown();
if(!isChatVisible)
chatWindow.addChat(chatPanel);
@ -82,7 +80,7 @@ public void openChat(ChatPanel chatPanel, boolean setSelected)
chatWindow.setTitle(
"*" + chatWindow.getTitle());
}
if(setSelected)
{
chatWindow.setCurrentChatPanel(chatPanel);
@ -96,7 +94,7 @@ else if(!chatWindow.getCurrentChatPanel().equals(chatPanel)
}
}
else
{
{
chatWindow.setVisible(true);
chatWindow.setCurrentChatPanel(chatPanel);
@ -233,12 +231,12 @@ else if (System.currentTimeMillis() - chatWindow
* Closes the chat window. Removes all contained chats and invokes
* setVisible(false) to the window.
*/
public void closeWindow()
public void closeWindow(ChatWindow chatWindow)
{
synchronized (syncChat)
{
ChatPanel chatPanel = chatWindow.getCurrentChatPanel();
if (!chatPanel.isWriteAreaEmpty())
{
SIPCommMsgTextArea msgText = new SIPCommMsgTextArea(Messages
@ -249,7 +247,7 @@ public void closeWindow()
if (answer == JOptionPane.OK_OPTION)
{
this.disposeChatWindow();
this.disposeChatWindow(chatWindow);
}
}
else if (System.currentTimeMillis() - chatWindow
@ -264,12 +262,12 @@ else if (System.currentTimeMillis() - chatWindow
if (answer == JOptionPane.OK_OPTION)
{
this.disposeChatWindow();
this.disposeChatWindow(chatWindow);
}
}
else
{
this.disposeChatWindow();
this.disposeChatWindow(chatWindow);
}
}
}
@ -335,7 +333,7 @@ public MetaContactChatPanel getContactChat( MetaContact metaContact,
{
return (MetaContactChatPanel) getChat(metaContact);
}
else
else
return createChat( metaContact,
protocolContact,
escapedMessageID);
@ -348,9 +346,35 @@ public MetaContactChatPanel getContactChat( MetaContact metaContact,
*/
public ChatPanel getSelectedChat()
{
ChatPanel selectedChat = null;
Enumeration chatPanels = chats.keys();
synchronized (syncChat)
{
return chatWindow.getCurrentChatPanel();
if (ConfigurationManager.isMultiChatWindowEnabled())
{
if (chatPanels.hasMoreElements())
{
ChatPanel firstChatPanel
= (ChatPanel) chatPanels.nextElement();
selectedChat
= firstChatPanel.getChatWindow().getCurrentChatPanel();
}
}
else
{
while (chatPanels.hasMoreElements())
{
ChatPanel chatPanel = (ChatPanel) chatPanels.nextElement();
if (chatPanel.getChatWindow().isFocusOwner())
selectedChat = chatPanel;
}
}
return selectedChat;
}
}
@ -434,10 +458,12 @@ public ConferenceChatPanel getMultiChat(ChatRoom chatRoom,
*/
private void closeChatPanel(ChatPanel chatPanel)
{
this.chatWindow.removeChat(chatPanel);
ChatWindow chatWindow = chatPanel.getChatWindow();
chatWindow.removeChat(chatPanel);
if (chatWindow.getChatCount() == 0)
disposeChatWindow();
disposeChatWindow(chatWindow);
synchronized (chats)
{
@ -527,23 +553,27 @@ private MetaContactChatPanel createChat(MetaContact contact,
{
ChatWindow chatWindow;
if(Constants.TABBED_CHAT_WINDOW)
if(ConfigurationManager.isMultiChatWindowEnabled())
{
if(this.chatWindow == null)
// If we're in a tabbed window we're looking for the chat window
// through one of the already created chats.
if(chats.keys().hasMoreElements())
{
chatWindow
= ((ChatPanel) chats.elements().nextElement())
.getChatWindow();
}
else
{
this.chatWindow = new ChatWindow(mainFrame);
chatWindow = new ChatWindow(mainFrame);
GuiActivator.getUIService()
.registerExportedWindow(this.chatWindow);
.registerExportedWindow(chatWindow);
}
chatWindow = this.chatWindow;
}
else
{
chatWindow = new ChatWindow(mainFrame);
this.chatWindow = chatWindow;
}
MetaContactChatPanel chatPanel
@ -589,24 +619,26 @@ private ConferenceChatPanel createChat( ChatRoomWrapper chatRoomWrapper,
ChatWindow chatWindow;
if(Constants.TABBED_CHAT_WINDOW)
if(ConfigurationManager.isMultiChatWindowEnabled())
{
if(this.chatWindow == null)
// If we're in a tabbed window we're looking for the chat window
// through one of the already created chats.
if(chats.keys().hasMoreElements())
{
this.chatWindow = new ChatWindow(mainFrame);
chatWindow
= ((ChatPanel) chats.keys().nextElement()).getChatWindow();
}
else
{
chatWindow = new ChatWindow(mainFrame);
GuiActivator.getUIService()
.registerExportedWindow(this.chatWindow);
.registerExportedWindow(chatWindow);
}
chatWindow = this.chatWindow;
}
else
{
chatWindow = new ChatWindow(mainFrame);
GuiActivator.getUIService().registerExportedWindow(chatWindow);
this.chatWindow = chatWindow;
}
ConferenceChatPanel chatPanel
@ -678,18 +710,23 @@ private ChatPanel getChat(Object key)
/**
* Disposes the chat window.
*/
private void disposeChatWindow()
private void disposeChatWindow(ChatWindow chatWindow)
{
synchronized (chats)
{
// If we're in a tabbed window we clear the list of active chats, as
// they'll be all gone with the window.
if (ConfigurationManager.isMultiChatWindowEnabled())
chats.clear();
else
chats.remove(
chatWindow.getCurrentChatPanel().getChatIdentifier());
}
if (chatWindow.getChatCount() > 0)
chatWindow.removeAllChats();
chatWindow.dispose();
chatWindow = null;
synchronized (chats)
{
chats.clear();
}
ContactList clist
= mainFrame.getContactListPanel().getContactList();

@ -341,7 +341,7 @@ public void updateContactStatus(Contact contact, PresenceStatus newStatus)
getChatConversationPanel().appendMessageToEnd(message);
if(Constants.TABBED_CHAT_WINDOW)
if(ConfigurationManager.isMultiChatWindowEnabled())
{
if (getChatWindow().getChatTabCount() > 0) {
getChatWindow().setTabIcon(this,

@ -507,7 +507,7 @@ public void chatRoomPropertyChangeFailed(
*/
public void updateChatRoomStatus(String status)
{
if(Constants.TABBED_CHAT_WINDOW)
if(ConfigurationManager.isMultiChatWindowEnabled())
{
if (getChatWindow().getChatTabCount() > 0) {
getChatWindow().setTabIcon(this,

@ -24,7 +24,7 @@ public class ConfigurationManager
private static boolean autoPopupNewMessage = false;
private static String sendMessageCommand;
private static boolean isCallPanelShown = true;
private static boolean isShowOffline = true;
@ -37,6 +37,8 @@ public class ConfigurationManager
private static boolean isMoveContactConfirmationRequested = true;
private static boolean isMultiChatWindowEnabled = true;
private static ConfigurationService configService
= GuiActivator.getConfigurationService();
@ -118,6 +120,19 @@ public static void loadGuiConfigurations()
= new Boolean(isMoveContactConfirmationRequestedString)
.booleanValue();
}
// Load the "isMultiChatWindowEnabled" property.
String isMultiChatWindowEnabledString
= configService.getString(
"net.java.sip.communicator.impl.gui.isMultiChatWindowEnabled");
if(isMultiChatWindowEnabledString != null
&& isMultiChatWindowEnabledString != "")
{
isMultiChatWindowEnabled
= new Boolean(isMultiChatWindowEnabledString)
.booleanValue();
}
}
/**
@ -205,6 +220,19 @@ public static boolean isMoveContactConfirmationRequested()
return isMoveContactConfirmationRequested;
}
/**
* Returns <code>true</code> if the "isMultiChatWindowEnabled" property is
* true, otherwise - returns <code>false</code>. Indicates to the user
* interface whether the chat window could contain multiple chats or just
* one chat.
* @return <code>true</code> if the "isMultiChatWindowEnabled" property is
* true, otherwise - returns <code>false</code>.
*/
public static boolean isMultiChatWindowEnabled()
{
return isMultiChatWindowEnabled;
}
/**
* Return the "sendMessageCommand" property that was saved previously
* through the <tt>ConfigurationService</tt>. Indicates to the user
@ -349,6 +377,23 @@ public static void setMoveContactConfirmationRequested(boolean isRequested)
new Boolean(isMoveContactConfirmationRequested));
}
/**
* Updates the "isMultiChatWindowEnabled" property through the
* <tt>ConfigurationService</tt>.
*
* @param isMultiChatWindowEnabled indicates if the chat window could
* contain multiple chats or only one chat.
*/
public static void setMultiChatWindowEnabled(
boolean isMultiChatWindowEnabled)
{
isMoveContactConfirmationRequested = isMultiChatWindowEnabled;
configService.setProperty(
"net.java.sip.communicator.impl.gui.isMultiChatWindowEnabled",
new Boolean(isMultiChatWindowEnabled));
}
/**
* Saves a chat room through the <tt>ConfigurationService</tt>.
*

@ -260,12 +260,6 @@ public class Constants
* ------------------------ OTHER CONSTANTS ------------------------------
* ======================================================================
*/
/**
* Indicates whether the application is in mode "group messages in one
* window".
*/
public static final boolean TABBED_CHAT_WINDOW = true;
/**
* The default path, where chat window styles could be found.
*/

Loading…
Cancel
Save