Update ChatContainer.

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@6665 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro
2007-01-11 16:32:12 +00:00
committed by derek
parent 5511af500f
commit 2f60eeac38
4 changed files with 27 additions and 35 deletions

View File

@ -40,9 +40,6 @@ import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences; import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager; import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
import javax.swing.Icon;
import javax.swing.SwingUtilities;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
@ -50,6 +47,9 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javax.swing.Icon;
import javax.swing.SwingUtilities;
/** /**
* Handles the Chat Management of each individual <code>Workspace</code>. The ChatManager is responsible * Handles the Chat Management of each individual <code>Workspace</code>. The ChatManager is responsible
* for creation and removal of chat rooms, transcripts, and transfers and room invitations. * for creation and removal of chat rooms, transcripts, and transfers and room invitations.
@ -154,11 +154,10 @@ public class ChatManager implements MessageEventNotificationListener {
* *
* @param roomName the name of the chat room. * @param roomName the name of the chat room.
* @return the MultiUserChat found for that room. * @return the MultiUserChat found for that room.
* @throws ChatNotFoundException thrown if no ChatRoom is found.
*/ */
public GroupChatRoom getGroupChat(String roomName) throws ChatNotFoundException { public GroupChatRoom getGroupChat(String roomName) throws ChatNotFoundException {
Iterator iter = getChatContainer().getAllChatRooms(); for (ChatRoom chatRoom : getChatContainer().getChatRooms()) {
while (iter.hasNext()) {
ChatRoom chatRoom = (ChatRoom)iter.next();
if (chatRoom instanceof GroupChatRoom) { if (chatRoom instanceof GroupChatRoom) {
GroupChatRoom groupChat = (GroupChatRoom)chatRoom; GroupChatRoom groupChat = (GroupChatRoom)chatRoom;
if (groupChat.getRoomname().equals(roomName)) { if (groupChat.getRoomname().equals(roomName)) {

View File

@ -30,6 +30,7 @@ import org.jivesoftware.spark.ui.ChatRoom;
import org.jivesoftware.spark.ui.ChatRoomNotFoundException; import org.jivesoftware.spark.ui.ChatRoomNotFoundException;
import org.jivesoftware.spark.ui.ContactItem; import org.jivesoftware.spark.ui.ContactItem;
import org.jivesoftware.spark.ui.ContactList; import org.jivesoftware.spark.ui.ContactList;
import org.jivesoftware.spark.ui.ChatContainer;
import org.jivesoftware.spark.ui.conferences.Conferences; import org.jivesoftware.spark.ui.conferences.Conferences;
import org.jivesoftware.spark.ui.status.StatusBar; import org.jivesoftware.spark.ui.status.StatusBar;
import org.jivesoftware.spark.util.SwingWorker; import org.jivesoftware.spark.util.SwingWorker;
@ -46,7 +47,6 @@ import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
@ -124,13 +124,11 @@ public class Workspace extends JPanel implements PacketListener {
// Add MainWindow listener // Add MainWindow listener
mainWindow.addMainWindowListener(new MainWindowListener() { mainWindow.addMainWindowListener(new MainWindowListener() {
public void shutdown() { public void shutdown() {
final ChatContainer container = SparkManager.getChatManager().getChatContainer();
// Close all Chats. // Close all Chats.
final Iterator chatRooms = SparkManager.getChatManager().getChatContainer().getAllChatRooms(); for (ChatRoom chatRoom : container.getChatRooms()) {
while (chatRooms.hasNext()) {
final ChatRoom chatRoom = (ChatRoom)chatRooms.next();
// Leave ChatRoom // Leave ChatRoom
SparkManager.getChatManager().getChatContainer().leaveChatRoom(chatRoom); container.leaveChatRoom(chatRoom);
} }
conferences.shutdown(); conferences.shutdown();

View File

@ -302,7 +302,10 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
} }
public void addContainerComponent(ContainerComponent comp) { public void addContainerComponent(ContainerComponent comp) {
createFrameIfNeeded();
addTab(comp.getTabTitle(), comp.getTabIcon(), comp.getGUI(), comp.getToolTipDescription()); addTab(comp.getTabTitle(), comp.getTabIcon(), comp.getGUI(), comp.getToolTipDescription());
chatFrame.setTitle(comp.getFrameTitle());
checkVisibility(comp.getGUI()); checkVisibility(comp.getGUI());
} }
@ -534,15 +537,6 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
throw new ChatRoomNotFoundException(); throw new ChatRoomNotFoundException();
} }
/**
* Returns all the ChatRooms found in the UI.
*
* @return all ChatRooms found in the UI.
*/
public Iterator getAllChatRooms() {
return chatRoomList.iterator();
}
/** /**
* Activates the specified ChatRoom. * Activates the specified ChatRoom.
* *
@ -682,21 +676,20 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
stopFlashing(); stopFlashing();
// Request focus in Chat Area if selected final Object o = getSelectedComponent();
final ChatRoom room; if (o instanceof ChatRoom) {
try { final ChatRoom room = (ChatRoom)o;
room = getActiveChatRoom();
focusChat(); focusChat();
// Set the title of the room. // Set the title of the room.
chatFrame.setTitle(room.getRoomTitle()); chatFrame.setTitle(room.getRoomTitle());
chatFrame.setIconImage(SparkManager.getMainWindow().getIconImage()); chatFrame.setIconImage(SparkManager.getMainWindow().getIconImage());
} }
catch (ChatRoomNotFoundException e1) { else if (o instanceof ContainerComponent) {
// Ignore final ContainerComponent comp = (ContainerComponent)o;
chatFrame.setTitle(comp.getFrameTitle());
chatFrame.setIconImage(comp.getTabIcon().getImage());
} }
} }
@ -1144,8 +1137,7 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
} }
public Collection<ChatRoom> getChatRooms() { public Collection<ChatRoom> getChatRooms() {
final List<ChatRoom> list = new ArrayList<ChatRoom>(chatRoomList); return new ArrayList<ChatRoom>(chatRoomList);
return list;
} }
public ChatFrame getChatFrame() { public ChatFrame getChatFrame() {

View File

@ -10,6 +10,7 @@ package org.jivesoftware.spark.ui;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.ImageIcon;
/** /**
* *
@ -18,7 +19,9 @@ public interface ContainerComponent {
public abstract String getTabTitle(); public abstract String getTabTitle();
public abstract Icon getTabIcon(); public abstract String getFrameTitle();
public abstract ImageIcon getTabIcon();
public abstract JComponent getGUI(); public abstract JComponent getGUI();