mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
Update ChatContainer.
git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@6665 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
@ -40,9 +40,6 @@ import org.jivesoftware.spark.util.log.Log;
|
||||
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
||||
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@ -50,6 +47,9 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
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
|
||||
* 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.
|
||||
* @return the MultiUserChat found for that room.
|
||||
* @throws ChatNotFoundException thrown if no ChatRoom is found.
|
||||
*/
|
||||
public GroupChatRoom getGroupChat(String roomName) throws ChatNotFoundException {
|
||||
Iterator iter = getChatContainer().getAllChatRooms();
|
||||
while (iter.hasNext()) {
|
||||
ChatRoom chatRoom = (ChatRoom)iter.next();
|
||||
for (ChatRoom chatRoom : getChatContainer().getChatRooms()) {
|
||||
if (chatRoom instanceof GroupChatRoom) {
|
||||
GroupChatRoom groupChat = (GroupChatRoom)chatRoom;
|
||||
if (groupChat.getRoomname().equals(roomName)) {
|
||||
|
||||
@ -30,6 +30,7 @@ import org.jivesoftware.spark.ui.ChatRoom;
|
||||
import org.jivesoftware.spark.ui.ChatRoomNotFoundException;
|
||||
import org.jivesoftware.spark.ui.ContactItem;
|
||||
import org.jivesoftware.spark.ui.ContactList;
|
||||
import org.jivesoftware.spark.ui.ChatContainer;
|
||||
import org.jivesoftware.spark.ui.conferences.Conferences;
|
||||
import org.jivesoftware.spark.ui.status.StatusBar;
|
||||
import org.jivesoftware.spark.util.SwingWorker;
|
||||
@ -46,7 +47,6 @@ import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
@ -124,13 +124,11 @@ public class Workspace extends JPanel implements PacketListener {
|
||||
// Add MainWindow listener
|
||||
mainWindow.addMainWindowListener(new MainWindowListener() {
|
||||
public void shutdown() {
|
||||
final ChatContainer container = SparkManager.getChatManager().getChatContainer();
|
||||
// Close all Chats.
|
||||
final Iterator chatRooms = SparkManager.getChatManager().getChatContainer().getAllChatRooms();
|
||||
while (chatRooms.hasNext()) {
|
||||
final ChatRoom chatRoom = (ChatRoom)chatRooms.next();
|
||||
|
||||
for (ChatRoom chatRoom : container.getChatRooms()) {
|
||||
// Leave ChatRoom
|
||||
SparkManager.getChatManager().getChatContainer().leaveChatRoom(chatRoom);
|
||||
container.leaveChatRoom(chatRoom);
|
||||
}
|
||||
|
||||
conferences.shutdown();
|
||||
|
||||
@ -302,7 +302,10 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
|
||||
}
|
||||
|
||||
public void addContainerComponent(ContainerComponent comp) {
|
||||
createFrameIfNeeded();
|
||||
|
||||
addTab(comp.getTabTitle(), comp.getTabIcon(), comp.getGUI(), comp.getToolTipDescription());
|
||||
chatFrame.setTitle(comp.getFrameTitle());
|
||||
checkVisibility(comp.getGUI());
|
||||
}
|
||||
|
||||
@ -534,15 +537,6 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
|
||||
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.
|
||||
*
|
||||
@ -682,21 +676,20 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
stopFlashing();
|
||||
|
||||
// Request focus in Chat Area if selected
|
||||
final ChatRoom room;
|
||||
try {
|
||||
room = getActiveChatRoom();
|
||||
|
||||
final Object o = getSelectedComponent();
|
||||
if (o instanceof ChatRoom) {
|
||||
final ChatRoom room = (ChatRoom)o;
|
||||
focusChat();
|
||||
|
||||
// Set the title of the room.
|
||||
chatFrame.setTitle(room.getRoomTitle());
|
||||
chatFrame.setIconImage(SparkManager.getMainWindow().getIconImage());
|
||||
}
|
||||
catch (ChatRoomNotFoundException e1) {
|
||||
// Ignore
|
||||
else if (o instanceof ContainerComponent) {
|
||||
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() {
|
||||
final List<ChatRoom> list = new ArrayList<ChatRoom>(chatRoomList);
|
||||
return list;
|
||||
return new ArrayList<ChatRoom>(chatRoomList);
|
||||
}
|
||||
|
||||
public ChatFrame getChatFrame() {
|
||||
|
||||
@ -10,6 +10,7 @@ package org.jivesoftware.spark.ui;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -18,7 +19,9 @@ public interface ContainerComponent {
|
||||
|
||||
public abstract String getTabTitle();
|
||||
|
||||
public abstract Icon getTabIcon();
|
||||
public abstract String getFrameTitle();
|
||||
|
||||
public abstract ImageIcon getTabIcon();
|
||||
|
||||
public abstract JComponent getGUI();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user