org.jivesoftware.spark.ui
Class ChatContainer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.jivesoftware.spark.component.tabbedPane.SparkTabbedPane
                      extended by org.jivesoftware.spark.ui.ChatContainer
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener, MessageListener

public class ChatContainer
extends SparkTabbedPane
implements MessageListener, javax.swing.event.ChangeListener

Contains all ChatRoom objects within Spark.

Author:
Derek DeMoro
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ChatContainer()
          Creates the ChatRooms to hold all ChatRooms.
 
Method Summary
 void activateChatRoom(ChatRoom room)
          Activates the specified ChatRoom.
 void activateComponent(java.awt.Component component)
          Activates the component in tabbed pane.
 void addChatRoom(ChatRoom room)
          Adds a new ChatRoom to Spark.
 void addChatRoomListener(ChatRoomListener listener)
          Adds a ChatRoom listener to ChatRooms.
 void blinkFrameIfNecessary(javax.swing.JFrame frame)
           
 void closeActiveRoom()
           
 void closeAllChatRooms()
          Close all chat rooms.
 void closeTab(java.awt.Component component)
          Closes a tab of a room.
protected  void fireChatRoomActivated(ChatRoom room)
          Notifies users that a ChatRoom has been activated.
protected  void fireChatRoomClosed(ChatRoom room)
          Notifies users that a ChatRoom has been closed.
protected  void fireChatRoomLeft(ChatRoom room)
          Notifies users that a ChatRoom has been left.
protected  void fireChatRoomOpened(ChatRoom room)
          Notifies users that a ChatRoom has been opened.
 void fireNotifyOnMessage(ChatRoom chatRoom)
           
protected  void fireUserHasJoined(ChatRoom room, java.lang.String userid)
          Notifies users that a user has joined a ChatRoom.
protected  void fireUserHasLeft(ChatRoom room, java.lang.String userid)
          Notifies users that a user has left a ChatRoom.
 void flashWindow(ChatRoom room)
           
 void focusChat()
           
 ChatRoom getActiveChatRoom()
          Returns the Active ChatRoom.
 java.util.Iterator getAllChatRooms()
          Returns all the ChatRooms found in the UI.
 ChatFrame getChatFrame()
           
 ChatRoom getChatRoom(int location)
          Returns a ChatRoom in the specified tab location.
 ChatRoom getChatRoom(java.lang.String roomName)
          Returns a ChatRoom by name.
 java.util.Collection<ChatRoom> getChatRooms()
           
 java.util.Collection<ChatRoom> getStaleChatRooms()
          Returns a Collection of stale chat rooms.
 boolean hasRooms()
          Returns true if there are any Rooms present.
 void leaveChatRoom(ChatRoom room)
          Leaves a ChatRoom.
 void makeTabRed(ChatRoom room)
           
 void messageReceived(ChatRoom room, org.jivesoftware.smack.packet.Message message)
          Used for Tray Notifications.
 void messageSent(ChatRoom room, org.jivesoftware.smack.packet.Message message)
          Invoked by the ChatRoom when a new message has been sent.
 void removeChatRoomListener(ChatRoomListener listener)
          Removes the specified ChatRoomListener.
 void setChatRoomTitle(ChatRoom room, java.lang.String title)
           
 void startFlashing(ChatRoom room)
          Starts flashing of MainWindow.
 void stateChanged(javax.swing.event.ChangeEvent e)
          Notification that the tab pane has been modified.
 void stopFlashing(ChatRoom room)
          Checks to see if the MainWindow should stop flashing.
 java.lang.String toString()
           
 void useTabDefault(ChatRoom room)
           
 
Methods inherited from class org.jivesoftware.spark.component.tabbedPane.SparkTabbedPane
addSparkTabbedPaneListener, addTab, addTab, allTabsClosed, close, fireTabAdded, fireTabRemoved, fireTabSelected, getCloseActiveButtonIcon, getCloseInactiveButtonIcon, getComponentAt, getComponentInTab, getIndex, getMainPanel, getPreferredSize, getSelectedComponent, getSelectedIndex, getTabAt, getTabCount, indexOfComponent, indexOfTab, isActiveButtonBold, isCloseButtonEnabled, isPopupAllowed, mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased, removeComponent, removeSparkTabbedPaneListener, removeTabAt, setActiveButtonBold, setCloseActiveButtonIcon, setCloseButtonEnabled, setCloseInactiveButtonIcon, setParentWindow, setPopupAllowed, setSelectedIndex, setSelectedTab
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChatContainer

public ChatContainer()
Creates the ChatRooms to hold all ChatRooms.

Method Detail

addChatRoom

public void addChatRoom(ChatRoom room)
Adds a new ChatRoom to Spark.

Parameters:
room - the ChatRoom to add.

closeAllChatRooms

public void closeAllChatRooms()
Close all chat rooms.


leaveChatRoom

public void leaveChatRoom(ChatRoom room)
Leaves a ChatRoom. Leaving a chat room does everything but close the room itself.

Parameters:
room - the room to leave.

getChatRoom

public ChatRoom getChatRoom(java.lang.String roomName)
                     throws ChatRoomNotFoundException
Returns a ChatRoom by name.

Parameters:
roomName - the name of the ChatRoom.
Returns:
the ChatRoom
Throws:
ChatRoomNotFoundException

getChatRoom

public ChatRoom getChatRoom(int location)
                     throws ChatRoomNotFoundException
Returns a ChatRoom in the specified tab location.

Parameters:
location - the tab location.
Returns:
the ChatRoom found.
Throws:
ChatRoomNotFoundException

getActiveChatRoom

public ChatRoom getActiveChatRoom()
                           throws ChatRoomNotFoundException
Returns the Active ChatRoom.

Returns:
the ChatRoom active in the tabbed pane.
Throws:
ChatRoomNotFoundException - is thrown if no chat room is found.

getAllChatRooms

public java.util.Iterator getAllChatRooms()
Returns all the ChatRooms found in the UI.

Returns:
all ChatRooms found in the UI.

activateChatRoom

public void activateChatRoom(ChatRoom room)
Activates the specified ChatRoom.

Parameters:
room - the ChatRoom to activate.

activateComponent

public void activateComponent(java.awt.Component component)
Activates the component in tabbed pane.

Parameters:
component - the component contained within the tab to activate.

messageReceived

public void messageReceived(ChatRoom room,
                            org.jivesoftware.smack.packet.Message message)
Used for Tray Notifications.

Specified by:
messageReceived in interface MessageListener
Parameters:
room - the ChatRoom where the message was received.
message - the message received.
See Also:
ChatRoom

fireNotifyOnMessage

public void fireNotifyOnMessage(ChatRoom chatRoom)

messageSent

public void messageSent(ChatRoom room,
                        org.jivesoftware.smack.packet.Message message)
Description copied from interface: MessageListener
Invoked by the ChatRoom when a new message has been sent.

Specified by:
messageSent in interface MessageListener
Parameters:
room - the ChatRoom that sent the message.
message - the message sent.
See Also:
ChatRoom

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
Notification that the tab pane has been modified. Generally by changing of the tabs.

Specified by:
stateChanged in interface javax.swing.event.ChangeListener
Parameters:
e - the ChangeEvent.

closeTab

public void closeTab(java.awt.Component component)
Closes a tab of a room.

Parameters:
component - the component inside of the tab to close.

closeActiveRoom

public void closeActiveRoom()

toString

public java.lang.String toString()
Overrides:
toString in class java.awt.Component

hasRooms

public boolean hasRooms()
Returns true if there are any Rooms present.

Returns:
true if Rooms are present, otherwise false.

addChatRoomListener

public void addChatRoomListener(ChatRoomListener listener)
Adds a ChatRoom listener to ChatRooms. The listener will be called when either a ChatRoom has been added, removed, or activated.

Parameters:
listener - the ChatRoomListener to register

removeChatRoomListener

public void removeChatRoomListener(ChatRoomListener listener)
Removes the specified ChatRoomListener.

Parameters:
listener - the ChatRoomListener to remove

fireChatRoomOpened

protected void fireChatRoomOpened(ChatRoom room)
Notifies users that a ChatRoom has been opened.

Parameters:
room - - the ChatRoom that has been opened.

fireChatRoomLeft

protected void fireChatRoomLeft(ChatRoom room)
Notifies users that a ChatRoom has been left.

Parameters:
room - - the ChatRoom that has been left

fireChatRoomClosed

protected void fireChatRoomClosed(ChatRoom room)
Notifies users that a ChatRoom has been closed.

Parameters:
room - - the ChatRoom that has been closed.

fireChatRoomActivated

protected void fireChatRoomActivated(ChatRoom room)
Notifies users that a ChatRoom has been activated.

Parameters:
room - - the ChatRoom that has been activated.

fireUserHasJoined

protected void fireUserHasJoined(ChatRoom room,
                                 java.lang.String userid)
Notifies users that a user has joined a ChatRoom.

Parameters:
room - - the ChatRoom that a user has joined.
userid - - the userid of the person.

fireUserHasLeft

protected void fireUserHasLeft(ChatRoom room,
                               java.lang.String userid)
Notifies users that a user has left a ChatRoom.

Parameters:
room - - the ChatRoom that a user has left.
userid - - the userid of the person.

startFlashing

public void startFlashing(ChatRoom room)
Starts flashing of MainWindow.

Parameters:
room - the ChatRoom to check if a message has been inserted but the room is not the selected room.

flashWindow

public void flashWindow(ChatRoom room)

makeTabRed

public void makeTabRed(ChatRoom room)

useTabDefault

public void useTabDefault(ChatRoom room)

stopFlashing

public void stopFlashing(ChatRoom room)
Checks to see if the MainWindow should stop flashing.

Parameters:
room - the ChatRoom to check.

setChatRoomTitle

public void setChatRoomTitle(ChatRoom room,
                             java.lang.String title)

focusChat

public void focusChat()

getChatRooms

public java.util.Collection<ChatRoom> getChatRooms()

getChatFrame

public ChatFrame getChatFrame()

blinkFrameIfNecessary

public void blinkFrameIfNecessary(javax.swing.JFrame frame)

getStaleChatRooms

public java.util.Collection<ChatRoom> getStaleChatRooms()
Returns a Collection of stale chat rooms.

Returns:
a collection of stale chat rooms.