org.jivesoftware.spark.ui.rooms
Class ChatRoomImpl

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.BackgroundPanel
                      extended by org.jivesoftware.spark.ui.ChatRoom
                          extended by org.jivesoftware.spark.ui.rooms.ChatRoomImpl
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.DocumentListener, org.jivesoftware.smack.ConnectionListener, org.jivesoftware.smack.PacketListener

public class ChatRoomImpl
extends ChatRoom

This is the Person to Person implementation of ChatRoom This room only allows for 1 to 1 conversations.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jivesoftware.spark.ui.ChatRoom
ChatRoom.ChatToolBar
 
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
ChatRoomImpl(java.lang.String participantJID, java.lang.String participantNickname, java.lang.String title)
          Constructs a 1-to-1 ChatRoom.
 
Method Summary
 void addMessageEventListener(MessageEventListener listener)
           
 void closeChatRoom()
          Close the ChatRoom.
 void connectionClosed()
           
 void connectionClosedOnError(java.lang.Exception ex)
           
 void fireOutgoingMessageSending(org.jivesoftware.smack.packet.Message message)
           
 void fireReceivingIncomingMessage(org.jivesoftware.smack.packet.Message message)
           
 javax.swing.Icon getAlternativeIcon()
          Returns the alternative icon.
 org.jivesoftware.smack.packet.Message.Type getChatType()
          Returns the Message.Type specific to this chat room.
 java.lang.String getJID()
          Returns the users full jid (ex.
 long getLastActivity()
          The last time this chat room sent or receieved a message.
 java.util.Collection getMessageEventListeners()
           
 java.lang.String getParticipantJID()
           
 java.lang.String getParticipantNickname()
          Returns the nickname of the user chatting with.
 org.jivesoftware.smack.packet.Presence getPresence()
          Returns the current presence of the client this room was created for.
 java.lang.String getRoomname()
          Get the roomname to use for this ChatRoom.
 java.lang.String getRoomTitle()
          Returns the title of this room to use.
 javax.swing.Icon getTabIcon()
          Get the Icon to be used in the tab holding this ChatRoom.
 java.lang.String getTabTitle()
          Get the title to use in the tab holding this ChatRoom.
 void insertMessage(org.jivesoftware.smack.packet.Message message)
          The main entry point when receiving any messages.
 void insertUpdate(javax.swing.event.DocumentEvent e)
          The current SendField has been updated somehow.
 boolean isActive()
          Returns whether or not this ChatRoom is active.
 boolean isIconHandler()
           
 void leaveChatRoom()
          Disable the chat room.
 void processPacket(org.jivesoftware.smack.packet.Packet packet)
          Process incoming packets.
 void reconnectionSuccessful()
           
 void removeMessageEventListener(MessageEventListener listener)
           
 void sendMessage()
          Creates and sends a message object from the text in the Send Field, using the default nickname specified in your Chat Preferences.
 void sendMessage(org.jivesoftware.smack.packet.Message message)
          Sends a message to the appropriate jid.
 void sendMessage(java.lang.String text)
          Creates a Message object from the given text and delegates to the room for sending.
 void setAlternativeIcon(javax.swing.Icon icon)
          Sets the alternative icon to use for the chat room.
 void setIconHandler(boolean iconHandler)
           
 void setRoomTitle(java.lang.String roomTitle)
           
 void setSendTypingNotification(boolean isSendTypingNotification)
           
 void setTabIcon(javax.swing.Icon icon)
           
 void setTabTitle(java.lang.String tabTitle)
           
 void showTyping(boolean typing)
          Show the typing notification.
 
Methods inherited from class org.jivesoftware.spark.ui.ChatRoom
actionPerformed, addClosingListener, addFileDropListener, addMessageListener, addPacketID, addToTranscript, changedUpdate, checkForText, clearUnreadMessageCount, disableToolbar, enableToolbar, fireFileDropListeners, fireMessageSent, getBottomPanel, getChatInputEditor, getChatPanel, getChatRoom, getChatWindowPanel, getEditorBar, getNickname, getNotificationLabel, getScrollPaneForTranscriptWindow, getSendButton, getSendFieldToolbar, getSplitPane, getToolBar, getTranscripts, getTranscriptWindow, getUnreadMessageCount, getVerticalSlipPane, increaseUnreadMessageCount, packetIDExists, positionCursor, reconnectingIn, reconnectionFailed, removeClosingListener, removeFileDropListener, removeMessageListener, removeUpdate, saveTranscript, scrollToBottom
 
Methods inherited from class org.jivesoftware.spark.component.BackgroundPanel
paintComponent
 
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, getPreferredSize, 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, 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, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChatRoomImpl

public ChatRoomImpl(java.lang.String participantJID,
                    java.lang.String participantNickname,
                    java.lang.String title)
Constructs a 1-to-1 ChatRoom.

Parameters:
participantJID - the participants jid to chat with.
participantNickname - the nickname of the participant.
title - the title of the room.
Method Detail

closeChatRoom

public void closeChatRoom()
Description copied from class: ChatRoom
Close the ChatRoom.

Overrides:
closeChatRoom in class ChatRoom

sendMessage

public void sendMessage()
Description copied from class: ChatRoom
Creates and sends a message object from the text in the Send Field, using the default nickname specified in your Chat Preferences.

Specified by:
sendMessage in class ChatRoom

sendMessage

public void sendMessage(java.lang.String text)
Description copied from class: ChatRoom
Creates a Message object from the given text and delegates to the room for sending.

Specified by:
sendMessage in class ChatRoom
Parameters:
text - the text to send.

sendMessage

public void sendMessage(org.jivesoftware.smack.packet.Message message)
Sends a message to the appropriate jid. The message is automatically added to the transcript.

Specified by:
sendMessage in class ChatRoom
Parameters:
message - the message to send.

getRoomname

public java.lang.String getRoomname()
Description copied from class: ChatRoom
Get the roomname to use for this ChatRoom.

Specified by:
getRoomname in class ChatRoom
Returns:
- the Roomname of this ChatRoom.

getTabIcon

public javax.swing.Icon getTabIcon()
Description copied from class: ChatRoom
Get the Icon to be used in the tab holding this ChatRoom.

Specified by:
getTabIcon in class ChatRoom
Returns:
- Icon to use

setTabIcon

public void setTabIcon(javax.swing.Icon icon)

getTabTitle

public java.lang.String getTabTitle()
Description copied from class: ChatRoom
Get the title to use in the tab holding this ChatRoom.

Specified by:
getTabTitle in class ChatRoom
Returns:
- the title to use.

setTabTitle

public void setTabTitle(java.lang.String tabTitle)

setRoomTitle

public void setRoomTitle(java.lang.String roomTitle)

getRoomTitle

public java.lang.String getRoomTitle()
Description copied from class: ChatRoom
Returns the title of this room to use. The title will be used in the title bar of the ChatRoom.

Specified by:
getRoomTitle in class ChatRoom
Returns:
- the title of this ChatRoom.

getChatType

public org.jivesoftware.smack.packet.Message.Type getChatType()
Description copied from class: ChatRoom
Returns the Message.Type specific to this chat room. GroupChat is Message.Type.GROUP_CHAT Normal Chat is Message.TYPE.NORMAL

Specified by:
getChatType in class ChatRoom
Returns:
the ChatRooms Message.TYPE

leaveChatRoom

public void leaveChatRoom()
Description copied from class: ChatRoom
Disable the chat room. This is called when a chat has been either transfered over or the customer has left the chat room.

Specified by:
leaveChatRoom in class ChatRoom

isActive

public boolean isActive()
Description copied from class: ChatRoom
Returns whether or not this ChatRoom is active. Note: carrying a conversation rather than being disabled, as it would be transcript mode.

Specified by:
isActive in class ChatRoom
Returns:
true if the chat room is active.

getParticipantJID

public java.lang.String getParticipantJID()

getJID

public java.lang.String getJID()
Returns the users full jid (ex. macbeth@jivesoftware.com/spark).

Returns:
the users Full JID.

processPacket

public void processPacket(org.jivesoftware.smack.packet.Packet packet)
Process incoming packets.

Specified by:
processPacket in interface org.jivesoftware.smack.PacketListener
Overrides:
processPacket in class ChatRoom
Parameters:
packet - - the packet to process

getParticipantNickname

public java.lang.String getParticipantNickname()
Returns the nickname of the user chatting with.

Returns:
the nickname of the chatting user.

insertUpdate

public void insertUpdate(javax.swing.event.DocumentEvent e)
The current SendField has been updated somehow.

Specified by:
insertUpdate in interface javax.swing.event.DocumentListener
Overrides:
insertUpdate in class ChatRoom
Parameters:
e - - the DocumentEvent to respond to.

insertMessage

public void insertMessage(org.jivesoftware.smack.packet.Message message)
Description copied from class: ChatRoom
The main entry point when receiving any messages. This will either handle a message from a customer or delegate itself as an agent handler.

Overrides:
insertMessage in class ChatRoom
Parameters:
message - - the message receieved.

addMessageEventListener

public void addMessageEventListener(MessageEventListener listener)

removeMessageEventListener

public void removeMessageEventListener(MessageEventListener listener)

getMessageEventListeners

public java.util.Collection getMessageEventListeners()

fireOutgoingMessageSending

public void fireOutgoingMessageSending(org.jivesoftware.smack.packet.Message message)

fireReceivingIncomingMessage

public void fireReceivingIncomingMessage(org.jivesoftware.smack.packet.Message message)

showTyping

public void showTyping(boolean typing)
Show the typing notification.

Parameters:
typing - true if the typing notification should show, otherwise hide it.

getLastActivity

public long getLastActivity()
The last time this chat room sent or receieved a message.

Specified by:
getLastActivity in class ChatRoom
Returns:
the last time this chat room sent or receieved a message.

getPresence

public org.jivesoftware.smack.packet.Presence getPresence()
Returns the current presence of the client this room was created for.

Returns:
the presence

isIconHandler

public boolean isIconHandler()

setIconHandler

public void setIconHandler(boolean iconHandler)

setSendTypingNotification

public void setSendTypingNotification(boolean isSendTypingNotification)

connectionClosed

public void connectionClosed()
Specified by:
connectionClosed in interface org.jivesoftware.smack.ConnectionListener
Overrides:
connectionClosed in class ChatRoom

connectionClosedOnError

public void connectionClosedOnError(java.lang.Exception ex)
Specified by:
connectionClosedOnError in interface org.jivesoftware.smack.ConnectionListener
Overrides:
connectionClosedOnError in class ChatRoom

reconnectionSuccessful

public void reconnectionSuccessful()
Specified by:
reconnectionSuccessful in interface org.jivesoftware.smack.ConnectionListener
Overrides:
reconnectionSuccessful in class ChatRoom

setAlternativeIcon

public void setAlternativeIcon(javax.swing.Icon icon)
Sets the alternative icon to use for the chat room. If null, then the default icon will be used.

Parameters:
icon - the alternative icon

getAlternativeIcon

public javax.swing.Icon getAlternativeIcon()
Returns the alternative icon. This can be null.

Returns:
the alternative icon.