com.jivesoftware.spark.ui
Class ChatContainer

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JTabbedPane
                  extended bycom.jidesoft.swing.JideTabbedPane
                      extended bycom.jivesoftware.spark.ui.ChatContainer
All Implemented Interfaces:
javax.accessibility.Accessible, javax.swing.event.ChangeListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, MessageListener, java.io.Serializable, javax.swing.SwingConstants

public class ChatContainer
extends com.jidesoft.swing.JideTabbedPane
implements MessageListener, javax.swing.event.ChangeListener

Should be subclassed to track all available ChatRooms.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JTabbedPane
javax.swing.JTabbedPane.AccessibleJTabbedPane, javax.swing.JTabbedPane.ModelListener
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class com.jidesoft.swing.JideTabbedPane
_tabEditingAllowed, BOLDACTIVETAB_PROPERTY, BOX_STYLE_PROPERTY, GRIPPER_PROPERTY, HIDE_IF_ONE_TAB_PROPERTY, SHOW_CLOSE_BUTTON_ON_TAB_PROPERTY, SHOW_CLOSE_BUTTON_PROPERTY, SHOW_ICONS_PROPERTY, SHOW_TAB_BUTTONS_PROPERTY, SHRINK_TAB_PROPERTY, TAB_CLOSABLE_PROPERTY, USE_DEFAULT_SHOW_CLOSE_BUTTON_ON_TAB_PROPERTY, USE_DEFAULT_SHOW_ICONS_PROPERTY
 
Fields inherited from class javax.swing.JTabbedPane
changeEvent, changeListener, model, SCROLL_TAB_LAYOUT, tabPlacement, WRAP_TAB_LAYOUT
 
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 javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
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 room)
           
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 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 getChatRooms()
           
 javax.swing.Action getCloseAction()
          Overrides the clicking of the x on the Tab.
 boolean hasRooms()
          Returns true if there are any Rooms present.
 void leaveChatRoom(ChatRoom room)
          Leaves a ChatRoom.
 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 paintComponent(java.awt.Graphics g)
           
 void removeChatRoom(ChatRoom room)
          Removes a ChatRoom from Spark.
 void removeChatRoomListener(ChatRoomListener listener)
          Removes the specified ChatRoomListener.
 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()
           
 
Methods inherited from class com.jidesoft.swing.JideTabbedPane
fireStateChanged, getDisplayTitleAt, getStringConverter, getTabAtLocation, getTabHeight, getUI, getUIClassID, isBoldActiveTab, isBoxStyleTab, isHideOneTab, isRightClickSelect, isShowCloseButton, isShowCloseButtonOnTab, isShowGripper, isShowIconsOnTab, isShowTabButtons, isShrinkTabs, isTabClosableAt, isTabEditingAllowed, isTabShown, isUseDefaultShowCloseButtonOnTab, isUseDefaultShowIconsOnTab, moveSelectedTabTo, removeTabAt, resetDefaultCloseAction, setBoldActiveTab, setBoxStyleTab, setCloseAction, setHideOneTab, setRightClickSelect, setShowCloseButton, setShowCloseButtonOnTab, setShowGripper, setShowIconsOnTab, setShowTabButtons, setShrinkTabs, setStringConverter, setTabClosableAt, setTabEditingAllowed, setTitleAt, setUI, setUseDefaultShowCloseButtonOnTab, setUseDefaultShowIconsOnTab, updateUI
 
Methods inherited from class javax.swing.JTabbedPane
add, add, add, add, add, addChangeListener, addTab, addTab, addTab, createChangeListener, getAccessibleContext, getBackgroundAt, getBoundsAt, getChangeListeners, getComponentAt, getDisabledIconAt, getDisplayedMnemonicIndexAt, getForegroundAt, getIconAt, getMnemonicAt, getModel, getSelectedComponent, getSelectedIndex, getTabCount, getTabLayoutPolicy, getTabPlacement, getTabRunCount, getTitleAt, getToolTipText, getToolTipTextAt, indexAtLocation, indexOfComponent, indexOfTab, indexOfTab, insertTab, isEnabledAt, paramString, remove, remove, removeAll, removeChangeListener, setBackgroundAt, setComponentAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setSelectedIndex, setTabLayoutPolicy, setTabPlacement, setToolTipTextAt
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

getCloseAction

public javax.swing.Action getCloseAction()
Overrides the clicking of the x on the Tab.

Returns:
the Action Associated with the clicking of the x on the tab.

addChatRoom

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

Parameters:
room - the ChatRoom to add.

removeChatRoom

public void removeChatRoom(ChatRoom room)
Removes a ChatRoom from Spark.

Parameters:
room - the room to remove.

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 room)

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()

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.

stopFlashing

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

Parameters:
room - the ChatRoom to check.

focusChat

public void focusChat()

getChatRooms

public java.util.Collection getChatRooms()

getChatFrame

public ChatFrame getChatFrame()

blinkFrameIfNecessary

public void blinkFrameIfNecessary(javax.swing.JFrame frame)

paintComponent

public void paintComponent(java.awt.Graphics g)