public class ChatConversationPanel extends SIPCommScrollPane implements javax.swing.event.HyperlinkListener, java.awt.event.MouseListener, java.awt.datatransfer.ClipboardOwner, Skinnable
javax.swing.JScrollPane.AccessibleJScrollPane, javax.swing.JScrollPane.ScrollBar
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
(package private) javax.swing.text.html.HTMLDocument |
document
The document used by the text component.
|
(package private) static java.util.regex.Pattern |
TEXT_TO_REPLACE_PATTERN
A regular expression for searching all pieces of plain text within a blob
of HTML text.
|
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewport
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
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
Constructor and Description |
---|
ChatConversationPanel(ChatConversationContainer chatContainer)
Creates an instance of ChatConversationPanel.
|
Modifier and Type | Method and Description |
---|---|
void |
addChatLinkClickedListener(ChatLinkClickedListener listener)
Registers a new link click listener.
|
void |
addComponent(ChatConversationComponent component)
Adds a custom component at the end of the conversation.
|
void |
appendConsecutiveMessage(ChatMessage chatMessage,
java.lang.String keyword)
Appends a consecutive message to the document.
|
void |
appendMessageToEnd(java.lang.String original,
java.lang.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.
|
void |
correctMessage(ChatMessage chatMessage)
Replaces the contents of the message with ID of the corrected message
specified in chatMessage, with this message.
|
void |
dispose()
Releases the resources allocated by this instance throughout its lifetime
and prepares it for garbage collection.
|
static ConfigurationForm |
getChatConfigForm()
Returns the first available advanced configuration form.
|
ChatConversationContainer |
getChatContainer()
Returns the chat container.
|
javax.swing.JTextPane |
getChatTextPane()
Returns the text pane of this conversation panel.
|
javax.swing.text.html.HTMLDocument |
getContent()
Returns the document contained in this panel.
|
java.util.Date |
getLastIncomingMsgTimestamp()
Returns the time of the last received message.
|
java.lang.String |
getMessageContents(java.lang.String messageUID)
Retrieves the contents of the sent message with the given ID.
|
java.util.Date |
getPageFirstMsgTimestamp()
Returns the date of the first message in the current page.
|
java.util.Date |
getPageLastMsgTimestamp()
Returns the date of the last message in the current page.
|
ChatRightButtonMenu |
getRightButtonMenu()
Returns the right button popup menu.
|
void |
hyperlinkUpdate(javax.swing.event.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(java.awt.datatransfer.Clipboard clipboard,
java.awt.datatransfer.Transferable contents) |
void |
mouseClicked(java.awt.event.MouseEvent e)
When a right button click is performed in the editor pane, a popup menu
is opened.
|
void |
mouseEntered(java.awt.event.MouseEvent e) |
void |
mouseExited(java.awt.event.MouseEvent e) |
void |
mousePressed(java.awt.event.MouseEvent e) |
void |
mouseReleased(java.awt.event.MouseEvent e) |
java.lang.String |
processMeCommand(ChatMessage chatMessage)
Processes /me command in group chats.
|
java.lang.String |
processMessage(ChatMessage chatMessage,
ProtocolProviderService protocolProvider,
java.lang.String contactAddress)
Processes the message given by the parameters.
|
java.lang.String |
processMessage(ChatMessage chatMessage,
java.lang.String keyword,
ProtocolProviderService protocolProvider,
java.lang.String contactAddress)
Processes the message given by the parameters.
|
(package private) void |
processReplacement(java.lang.String messageID,
java.lang.String chatString)
Formats the given message.
|
void |
removeChatLinkClickedListener(ChatLinkClickedListener listener)
Remove a registered link click listener.
|
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(javax.swing.text.html.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.
|
setViewportView
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, setWheelScrollingEnabled, updateUI
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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
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, transferFocusDownCycle, validate, validateTree
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, 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, transferFocusBackward, transferFocusUpCycle
static final java.util.regex.Pattern TEXT_TO_REPLACE_PATTERN
In essence this regexp pattern works as follows: 1. Find all the text that isn't the start of a tag. (so all chars != '<') -> This is your actual result: textual content that is not part of a tag. 2. Then, if you find a '<', find as much chars as you can until you find '>' (if it is possible at all to find a closing '>') In depth explanation of 2.: The text between tags consists mainly of 2 parts: A) a piece of text B) some value "between quotes" So everything up to the "quote" is part of a piece of text (A). Then if we encounter a "quote" we consider the rest of the text part of the value (B) until the value section is closed with a closing "quote". (We tend to be rather greedy, so we even swallow '>' along the way looking for the closing "quote".) This subpattern is allowed any number of times, until eventually the closing '>' is encountered. (Or not if the pattern is incomplete.) 3. And consider that 2. is optional, since it could also be that we only find plain text, which would all be captured by 1.
The first group matches any piece of text outside of the < and > brackets that define the start and end of HTML tags.
javax.swing.text.html.HTMLDocument document
public ChatConversationPanel(ChatConversationContainer chatContainer)
chatContainer
- The parent ChatConversationContainer.public void setBounds(int x, int y, int width, int height)
setBounds
in class java.awt.Component
public java.lang.String getMessageContents(java.lang.String messageUID)
messageUID
- The ID of the message to retrieve.public java.lang.String processMessage(ChatMessage chatMessage, java.lang.String keyword, ProtocolProviderService protocolProvider, java.lang.String contactAddress)
chatMessage
- the messagekeyword
- a substring of chatMessage to be highlighted upon
display of chatMessage in the UIpublic java.lang.String processMessage(ChatMessage chatMessage, ProtocolProviderService protocolProvider, java.lang.String contactAddress)
chatMessage
- the message.public void appendConsecutiveMessage(ChatMessage chatMessage, java.lang.String keyword)
chatMessage
- the message to appendkeyword
- the keywords to highlightpublic void correctMessage(ChatMessage chatMessage)
chatMessage
- A ChatMessage that contains all the required
information to correct the old message.public void appendMessageToEnd(java.lang.String original, java.lang.String contentType)
original
- the message string to appendcontentType
- the message's content typevoid processReplacement(java.lang.String messageID, java.lang.String chatString)
messageID
- the messageID element.chatString
- the message.public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e)
hyperlinkUpdate
in interface javax.swing.event.HyperlinkListener
e
- The HyperlinkEvent.public javax.swing.JTextPane getChatTextPane()
public java.util.Date getLastIncomingMsgTimestamp()
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
e
- The MouseEvent.public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void lostOwnership(java.awt.datatransfer.Clipboard clipboard, java.awt.datatransfer.Transferable contents)
lostOwnership
in interface java.awt.datatransfer.ClipboardOwner
public ChatConversationContainer getChatContainer()
public void copyConversation()
public void clear()
public void setContent(javax.swing.text.html.HTMLDocument document)
document
- the document to setpublic void setDefaultContent()
public javax.swing.text.html.HTMLDocument getContent()
public ChatRightButtonMenu getRightButtonMenu()
public java.util.Date getPageFirstMsgTimestamp()
public java.util.Date getPageLastMsgTimestamp()
public void addComponent(ChatConversationComponent component)
component
- the component to add at the end of the conversation.public void addChatLinkClickedListener(ChatLinkClickedListener listener)
listener
- the object that should be notified when an internal
link was clicked.public void removeChatLinkClickedListener(ChatLinkClickedListener listener)
listener
- a registered click listener to removepublic void loadSkin()
loadSkin
in interface Skinnable
loadSkin
in class SIPCommScrollPane
public java.lang.String processMeCommand(ChatMessage chatMessage)
chatMessage
- the chat messagepublic void dispose()
dispose
in class SIPCommScrollPane
public static ConfigurationForm getChatConfigForm()
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.