Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.gui.main.chat
Class ChatConversationPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JScrollPane
                  extended by net.java.sip.communicator.impl.gui.customcontrols.SCScrollPane
                      extended by net.java.sip.communicator.impl.gui.main.chat.ChatConversationPanel
All Implemented Interfaces:
ClipboardOwner, MouseListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, HyperlinkListener, ScrollPaneConstants, Skinnable

public class ChatConversationPanel
extends SCScrollPane
implements HyperlinkListener, MouseListener, ClipboardOwner, Skinnable

The ChatConversationPanel is the panel, where all sent and received messages appear. All data is stored in an HTML document. An external CSS file is applied to the document to provide the look&feel. All smileys and link strings are processed and finally replaced by corresponding images and HTML links.

Author:
Yana Stamcheva, Lubomir Marinov, Adam Netocny
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JScrollPane
JScrollPane.AccessibleJScrollPane, JScrollPane.ScrollBar
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String HTML_CONTENT_TYPE
          The html text content type.
static String TEXT_CONTENT_TYPE
          The plain text content type.
 
Fields inherited from class javax.swing.JScrollPane
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewport
 
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.ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ChatConversationPanel(ChatConversationContainer chatContainer)
          Creates an instance of ChatConversationPanel.
 
Method Summary
 void addComponent(ChatConversationComponent component)
          Adds a custom component at the end of the conversation.
 void appendMessageToEnd(String chatString, String contentType)
          Appends the given string at the end of the contained in this panel document.
 void clear()
          Creates new document and all the messages that will be processed in the future will be appended in it.
 void copyConversation()
          Copies the selected conversation panel content to the clipboard.
 ChatConversationContainer getChatContainer()
          Returns the chat container.
 JTextPane getChatTextPane()
          Returns the text pane of this conversation panel.
 HTMLDocument getContent()
          Returns the document contained in this panel.
static String getDateString(long date)
          Returns the date string to show for the given date.
 long getLastIncomingMsgTimestamp()
          Returns the time of the last received message.
 Date getPageFirstMsgTimestamp()
          Returns the date of the first message in the current page.
 Date getPageLastMsgTimestamp()
          Returns the date of the last message in the current page.
 ChatRightButtonMenu getRightButtonMenu()
          Returns the right button popup menu.
 void hyperlinkUpdate(HyperlinkEvent e)
          Opens a link in the default browser when clicked and shows link url in a popup on mouseover.
 void loadSkin()
          Reloads images.
 void lostOwnership(Clipboard clipboard, Transferable contents)
           
 void mouseClicked(MouseEvent e)
          When a right button click is performed in the editor pane, a popup menu is opened.
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 String processChatRoomHighlight(String message, String contentType, String keyWord)
          Highlights the string in multi user chat.
 String processMeCommand(ChatMessage chatMessage)
           
 String processMessage(ChatMessage chatMessage)
          Processes the message given by the parameters.
 String processMessage(ChatMessage chatMessage, String keyword)
          Processes the message given by the parameters.
 void setBounds(int x, int y, int width, int height)
          Overrides Component#setBounds(int, int, int, int) in order to determine whether an automatic scroll of #chatTextPane to its bottom will be necessary at a later time in order to keep its vertical scroll bar to its bottom after the realization of the resize if it is at its bottom before the resize.
 void setContent(HTMLDocument document)
          Sets the given document to the editor pane in this panel.
 void setDefaultContent()
          Sets the default document contained in this panel, created on init or when clear is invoked.
 
Methods inherited from class net.java.sip.communicator.impl.gui.customcontrols.SCScrollPane
setViewportView
 
Methods inherited from class javax.swing.JScrollPane
createHorizontalScrollBar, createVerticalScrollBar, createViewport, getAccessibleContext, getColumnHeader, getCorner, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getUI, getUIClassID, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorder, getViewportBorderBounds, isValidateRoot, isWheelScrollingEnabled, paramString, setColumnHeader, setColumnHeaderView, setComponentOrientation, setCorner, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setLayout, setRowHeader, setRowHeaderView, setUI, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportBorder, setViewportView, setWheelScrollingEnabled, 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, getBaseline, getBaselineResizeBehavior, 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, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, 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, 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, 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
 

Field Detail

HTML_CONTENT_TYPE

public static final String HTML_CONTENT_TYPE
The html text content type.

See Also:
Constant Field Values

TEXT_CONTENT_TYPE

public static final String TEXT_CONTENT_TYPE
The plain text content type.

See Also:
Constant Field Values
Constructor Detail

ChatConversationPanel

public ChatConversationPanel(ChatConversationContainer chatContainer)
Creates an instance of ChatConversationPanel.

Parameters:
chatContainer - The parent ChatConversationContainer.
Method Detail

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Overrides Component#setBounds(int, int, int, int) in order to determine whether an automatic scroll of #chatTextPane to its bottom will be necessary at a later time in order to keep its vertical scroll bar to its bottom after the realization of the resize if it is at its bottom before the resize.

Overrides:
setBounds in class Component

processMessage

public String processMessage(ChatMessage chatMessage,
                             String keyword)
Processes the message given by the parameters.

Parameters:
chatMessage - the message
keyword - a substring of chatMessage to be highlighted upon display of chatMessage in the UI
Returns:
the processed message

processMessage

public String processMessage(ChatMessage chatMessage)
Processes the message given by the parameters.

Parameters:
chatMessage - the message.
Returns:
the formatted message

appendMessageToEnd

public void appendMessageToEnd(String chatString,
                               String contentType)
Appends the given string at the end of the contained in this panel document.

Parameters:
chatString - the string to append

hyperlinkUpdate

public void hyperlinkUpdate(HyperlinkEvent e)
Opens a link in the default browser when clicked and shows link url in a popup on mouseover.

Specified by:
hyperlinkUpdate in interface HyperlinkListener
Parameters:
e - The HyperlinkEvent.

getChatTextPane

public JTextPane getChatTextPane()
Returns the text pane of this conversation panel.

Returns:
The text pane of this conversation panel.

getLastIncomingMsgTimestamp

public long getLastIncomingMsgTimestamp()
Returns the time of the last received message.

Returns:
The time of the last received message.

mouseClicked

public void mouseClicked(MouseEvent e)
When a right button click is performed in the editor pane, a popup menu is opened.

Specified by:
mouseClicked in interface MouseListener
Parameters:
e - The MouseEvent.

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener

lostOwnership

public void lostOwnership(Clipboard clipboard,
                          Transferable contents)
Specified by:
lostOwnership in interface ClipboardOwner

getChatContainer

public ChatConversationContainer getChatContainer()
Returns the chat container.

Returns:
the chat container

copyConversation

public void copyConversation()
Copies the selected conversation panel content to the clipboard.


clear

public void clear()
Creates new document and all the messages that will be processed in the future will be appended in it.


setContent

public void setContent(HTMLDocument document)
Sets the given document to the editor pane in this panel.

Parameters:
document - the document to set

setDefaultContent

public void setDefaultContent()
Sets the default document contained in this panel, created on init or when clear is invoked.


getContent

public HTMLDocument getContent()
Returns the document contained in this panel.

Returns:
the document contained in this panel

getRightButtonMenu

public ChatRightButtonMenu getRightButtonMenu()
Returns the right button popup menu.

Returns:
the right button popup menu

getPageFirstMsgTimestamp

public Date getPageFirstMsgTimestamp()
Returns the date of the first message in the current page.

Returns:
the date of the first message in the current page

getPageLastMsgTimestamp

public Date getPageLastMsgTimestamp()
Returns the date of the last message in the current page.

Returns:
the date of the last message in the current page

addComponent

public void addComponent(ChatConversationComponent component)
Adds a custom component at the end of the conversation.

Parameters:
component - the component to add at the end of the conversation.

getDateString

public static String getDateString(long date)
Returns the date string to show for the given date.

Parameters:
date - the date to format
Returns:
the date string to show for the given date

loadSkin

public void loadSkin()
Reloads images.

Specified by:
loadSkin in interface Skinnable
Overrides:
loadSkin in class SCScrollPane

processChatRoomHighlight

public String processChatRoomHighlight(String message,
                                       String contentType,
                                       String keyWord)
Highlights the string in multi user chat.

Parameters:
message - the message to process
contentType - the content type of the message
keyWord - the keyword to highlight
Returns:
the message string with the keyword highlighted

processMeCommand

public String processMeCommand(ChatMessage chatMessage)

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.