public abstract class ChatRoom extends BackgroundPanel implements java.awt.event.ActionListener, org.jivesoftware.smack.StanzaListener, javax.swing.event.DocumentListener, org.jivesoftware.smack.ConnectionListener, java.awt.event.FocusListener, ContextMenuListener, ChatFrameToFrontListener
Modifier and Type | Class and Description |
---|---|
class |
ChatRoom.ChatToolBar
Used for the top toolbar.
|
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Modifier | Constructor and Description |
---|---|
protected |
ChatRoom()
Initializes the base layout and base background color.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e) |
void |
addChatRoomButton(ChatRoomButton button) |
void |
addChatRoomButton(ChatRoomButton button,
boolean forceRepaint) |
void |
addChatRoomComponent(javax.swing.JComponent component) |
void |
addClosingListener(ChatRoomClosingListener listener)
Adds a
ChatRoomClosingListener to this ChatRoom. |
void |
addControllerButton(RolloverButton button) |
void |
addEditorComponent(javax.swing.JComponent component) |
void |
addFileDropListener(FileDropListener listener)
Adds a new
FileDropListener to allow for Drag and Drop notifications
of objects onto the ChatWindow. |
void |
addMessageListener(MessageListener listener)
Add a
MessageListener to the current ChatRoom. |
void |
addPacketID(java.lang.String packetID)
Adds a packetID to the packedIDList.
|
protected void |
addToolbar() |
void |
addToTranscript(org.jivesoftware.smack.packet.Message message,
boolean updateDate)
Add a
ChatResponse to the current discussion chat area. |
void |
addToTranscript(java.lang.String to,
java.lang.String from,
java.lang.String body,
java.util.Date date)
Adds a new message to the transcript history.
|
void |
changedUpdate(javax.swing.event.DocumentEvent docEvent)
Checks to see if the Send button should be enabled.
|
protected void |
checkForText(javax.swing.event.DocumentEvent e)
Checks to see if the Send button should be enabled.
|
void |
clearUnreadMessageCount()
Resets the number of unread messages.
|
void |
closeChatRoom()
Close the ChatRoom.
|
void |
connectionClosed() |
void |
connectionClosedOnError(java.lang.Exception e) |
protected void |
createChatStateTimerTask() |
void |
disableToolbar()
Disables the ChatRoom toolbar.
|
void |
enableToolbar()
Enable the ChatRoom toolbar.
|
void |
fireFileDropListeners(java.util.Collection<java.io.File> files)
Notify all users that a collection of files has been dropped onto the ChatRoom.
|
protected void |
fireMessageSent(org.jivesoftware.smack.packet.Message message)
Notifies all
MessageListener that a message has been sent. |
void |
focusGained(java.awt.event.FocusEvent focusEvent) |
void |
focusLost(java.awt.event.FocusEvent focusEvent) |
javax.swing.JPanel |
getBottomPanel()
Returns the bottom panel used in the ChatRoom.
|
protected java.awt.Insets |
getChatAreaInsets() |
ChatInputEditor |
getChatInputEditor()
Returns the SendField component.
|
javax.swing.JPanel |
getChatPanel()
Returns the ChatPanel that contains the ChatWindow and SendField.
|
protected java.awt.Insets |
getChatPanelInsets() |
ChatRoom |
getChatRoom()
Returns this instance of the chatroom.
|
abstract org.jivesoftware.smack.packet.Message.Type |
getChatType()
Returns the
Message.Type specific to this
chat room. |
javax.swing.JPanel |
getChatWindowPanel()
Returns the Container which holds the ChatWindow.
|
javax.swing.JPanel |
getEditorBar()
Returns the panel which contains the toolbar items, such as spell checker.
|
protected javax.swing.JPanel |
getEditorBarLeft() |
protected javax.swing.JPanel |
getEditorBarRight() |
protected javax.swing.JPanel |
getEditorWrapperBar() |
protected java.awt.Insets |
getEditorWrapperInsets() |
abstract long |
getLastActivity()
Implementation of this method should return the last time this chat room
sent or recieved a message.
|
java.lang.String |
getNickname()
Returns the nickname of the current agent as specified in Chat
Preferences.
|
javax.swing.JLabel |
getNotificationLabel()
Returns the notification label.
|
javax.swing.JPanel |
getRoomControllerBar()
Returns the panel next to the editor bar
for use with system buttons, like room controlling or toggle stay-on-top |
abstract java.lang.String |
getRoomname()
Get the roomname to use for this ChatRoom.
|
abstract java.lang.String |
getRoomTitle()
Returns the title of this room to use.
|
javax.swing.JScrollPane |
getScrollPaneForTranscriptWindow()
Returns the ScrollPane that contains the TranscriptWindow.
|
javax.swing.JButton |
getSendButton()
Return the "Send" button.
|
javax.swing.JSplitPane |
getSplitPane()
Return the splitpane used in this chat room.
|
abstract javax.swing.Icon |
getTabIcon()
Get the
Icon to be used in the tab holding
this ChatRoom. |
abstract java.lang.String |
getTabTitle()
Get the title to use in the tab holding this ChatRoom.
|
protected javax.swing.JScrollPane |
getTextScroller() |
ChatRoom.ChatToolBar |
getToolBar()
Returns the toolbar used on top of the chat room.
|
java.util.List<org.jivesoftware.smack.packet.Message> |
getTranscripts()
Returns a map of the current Chat Transcript which is a list of all
ChatResponses and their order.
|
TranscriptWindow |
getTranscriptWindow()
Returns the chatWindow components.
|
int |
getUnreadMessageCount()
Returns the number of unread messages in this ChatRoom.
|
javax.swing.JSplitPane |
getVerticalSlipPane()
Returns the VerticalSplitPane used in this ChatRoom.
|
boolean |
handleDefaultAction(java.awt.event.MouseEvent e)
Called when the user double clicks on an item that has a popup menu.
|
void |
hideToolbar() |
void |
increaseUnreadMessageCount()
Increases the number of unread messages by 1.
|
void |
insertMessage(org.jivesoftware.smack.packet.Message message)
The main entry point when receiving any messages.
|
void |
insertUpdate(javax.swing.event.DocumentEvent e) |
abstract boolean |
isActive()
Returns whether or not this ChatRoom is active.
|
abstract void |
leaveChatRoom()
Disable the chat room.
|
boolean |
packetIDExists(java.lang.String packetID)
Checks if the packetID has already been used.
|
void |
poppingDown(javax.swing.JPopupMenu popup)
Called just before the context menu closed.
|
void |
poppingUp(java.lang.Object component,
javax.swing.JPopupMenu popup)
Called just before the context menu is popping up.
|
void |
positionCursor()
Requests valid focus to the SendField.
|
void |
processPacket(org.jivesoftware.smack.packet.Stanza stanza)
Process incoming packets.
|
void |
reconnectingIn(int seconds) |
void |
reconnectionFailed(java.lang.Exception e) |
void |
reconnectionSuccessful() |
void |
registeredToFrame(ChatFrame chatframe)
the observer should register on this chatframe component
|
void |
removeClosingListener(ChatRoomClosingListener listener)
Removes a
ChatRoomClosingListener from this ChatRoom. |
void |
removeEditorComponent(javax.swing.JComponent component) |
void |
removeFileDropListener(FileDropListener listener)
Remove the
FileDropListener from ChatRoom. |
void |
removeMessageListener(MessageListener listener)
Remove the specified
MessageListener from the current ChatRoom. |
void |
removeUpdate(javax.swing.event.DocumentEvent event)
Checks to see if the Send Button should be enabled depending on the
current update in SendField.
|
void |
saveTranscript()
Override to save transcript in preferred room style.
|
void |
scrollToBottom()
Scrolls the chat window to the bottom.
|
protected abstract void |
sendChatState(org.jivesoftware.smackx.chatstates.ChatState state)
Sends a chat state to all peers.
|
protected abstract void |
sendMessage()
Creates and sends a message object from the text in
the Send Field, using the default nickname specified in your
Chat Preferences.
|
abstract void |
sendMessage(org.jivesoftware.smack.packet.Message message)
Sends the current message.
|
protected abstract void |
sendMessage(java.lang.String text)
Creates a Message object from the given text and delegates to the room
for sending.
|
void |
setChatState(org.jivesoftware.smackx.chatstates.ChatState state)
Sets the chat state, causing an update to be sent to all peers if the new state warrants an update.
|
void |
showToolbar() |
void |
updateStatus(boolean active)
Update.
|
paintComponent
getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, 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
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, 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, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected ChatRoom()
protected void createChatStateTimerTask()
protected abstract void sendChatState(org.jivesoftware.smackx.chatstates.ChatState state) throws org.jivesoftware.smack.SmackException.NotConnectedException
state
- the chat state.org.jivesoftware.smack.SmackException.NotConnectedException
public final void setChatState(org.jivesoftware.smackx.chatstates.ChatState state)
state
- the chat state (never null).public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
protected abstract void sendMessage()
protected abstract void sendMessage(java.lang.String text)
text
- the text to send.public abstract void sendMessage(org.jivesoftware.smack.packet.Message message)
message
- - the message to send.public java.lang.String getNickname()
public void insertMessage(org.jivesoftware.smack.packet.Message message)
message
- - the message receieved.public void addToTranscript(org.jivesoftware.smack.packet.Message message, boolean updateDate)
ChatResponse to the current discussion chat area.
message
- the message to add to the transcript listupdateDate
- true if you wish the date label to be updated with the
date and time the message was received.public void addToTranscript(java.lang.String to, java.lang.String from, java.lang.String body, java.util.Date date)
to
- who the message is to.from
- who the message was from.body
- the body of the message.date
- when the message was received.public void scrollToBottom()
protected void checkForText(javax.swing.event.DocumentEvent e)
e
- - the documentevent to react to.public void positionCursor()
public abstract void leaveChatRoom()
public void processPacket(org.jivesoftware.smack.packet.Stanza stanza)
processPacket
in interface org.jivesoftware.smack.StanzaListener
stanza
- - the packet to processpublic ChatInputEditor getChatInputEditor()
public TranscriptWindow getTranscriptWindow()
public void addMessageListener(MessageListener listener)
MessageListener
to the current ChatRoom.listener
- - the MessageListener to add to the current ChatRoom.public void removeMessageListener(MessageListener listener)
MessageListener
from the current ChatRoom.listener
- - the MessageListener to remove from the current ChatRoom.protected void fireMessageSent(org.jivesoftware.smack.packet.Message message)
MessageListener
that a message has been sent.message
- the message sent.public java.util.List<org.jivesoftware.smack.packet.Message> getTranscripts()
public void disableToolbar()
public void enableToolbar()
public void removeUpdate(javax.swing.event.DocumentEvent event)
removeUpdate
in interface javax.swing.event.DocumentListener
event
- the DocumentEvent from the sendField.public void changedUpdate(javax.swing.event.DocumentEvent docEvent)
changedUpdate
in interface javax.swing.event.DocumentListener
docEvent
- the document event.public javax.swing.JSplitPane getSplitPane()
public javax.swing.JPanel getChatPanel()
public void closeChatRoom()
public abstract javax.swing.Icon getTabIcon()
Icon
to be used in the tab holding
this ChatRoom.Icon
to usepublic abstract java.lang.String getRoomname()
public abstract java.lang.String getTabTitle()
public abstract java.lang.String getRoomTitle()
public abstract org.jivesoftware.smack.packet.Message.Type getChatType()
Message.Type
specific to this
chat room.
GroupChat is Message.Type.groupchat
Normal Chat is Message.TYPE.NORMALpublic abstract boolean isActive()
public javax.swing.JLabel getNotificationLabel()
public void addPacketID(java.lang.String packetID)
packetID
- the packetID to add.public boolean packetIDExists(java.lang.String packetID)
packetID
- the packetID to check for.public ChatRoom getChatRoom()
public ChatRoom.ChatToolBar getToolBar()
protected void addToolbar()
public void insertUpdate(javax.swing.event.DocumentEvent e)
insertUpdate
in interface javax.swing.event.DocumentListener
public void saveTranscript()
public int getUnreadMessageCount()
public void increaseUnreadMessageCount()
public void clearUnreadMessageCount()
public javax.swing.JPanel getBottomPanel()
public javax.swing.JPanel getChatWindowPanel()
public void addFileDropListener(FileDropListener listener)
FileDropListener
to allow for Drag and Drop notifications
of objects onto the ChatWindow.listener
- the listener.public void removeFileDropListener(FileDropListener listener)
FileDropListener
from ChatRoom.listener
- the listener.public void fireFileDropListeners(java.util.Collection<java.io.File> files)
files
- the files dropped.public javax.swing.JPanel getEditorBar()
public javax.swing.JPanel getRoomControllerBar()
public void addClosingListener(ChatRoomClosingListener listener)
ChatRoomClosingListener
to this ChatRoom. A ChatRoomClosingListener
is notified whenever this room is closing.listener
- the ChatRoomClosingListener.public void removeClosingListener(ChatRoomClosingListener listener)
ChatRoomClosingListener
from this ChatRoom.listener
- the ChatRoomClosingListener.public javax.swing.JScrollPane getScrollPaneForTranscriptWindow()
TranscriptWindow
ScrollPane.public javax.swing.JButton getSendButton()
public javax.swing.JSplitPane getVerticalSlipPane()
public void focusGained(java.awt.event.FocusEvent focusEvent)
focusGained
in interface java.awt.event.FocusListener
public void poppingUp(java.lang.Object component, javax.swing.JPopupMenu popup)
ContextMenuListener
poppingUp
in interface ContextMenuListener
component
- the object the event was fired for.popup
- the PopupMenu to be displayed.public void poppingDown(javax.swing.JPopupMenu popup)
ContextMenuListener
poppingDown
in interface ContextMenuListener
popup
- the popup menu in the process of closing.public boolean handleDefaultAction(java.awt.event.MouseEvent e)
ContextMenuListener
handleDefaultAction
in interface ContextMenuListener
e
- the current mouse eventpublic void focusLost(java.awt.event.FocusEvent focusEvent)
focusLost
in interface java.awt.event.FocusListener
public abstract long getLastActivity()
public void connectionClosed()
connectionClosed
in interface org.jivesoftware.smack.ConnectionListener
public void connectionClosedOnError(java.lang.Exception e)
connectionClosedOnError
in interface org.jivesoftware.smack.ConnectionListener
public void reconnectingIn(int seconds)
reconnectingIn
in interface org.jivesoftware.smack.ConnectionListener
public void reconnectionSuccessful()
reconnectionSuccessful
in interface org.jivesoftware.smack.ConnectionListener
public void reconnectionFailed(java.lang.Exception e)
reconnectionFailed
in interface org.jivesoftware.smack.ConnectionListener
public void updateStatus(boolean active)
ChatFrameToFrontListener
updateStatus
in interface ChatFrameToFrontListener
public void registeredToFrame(ChatFrame chatframe)
ChatFrameToFrontListener
registeredToFrame
in interface ChatFrameToFrontListener
protected javax.swing.JPanel getEditorWrapperBar()
protected javax.swing.JPanel getEditorBarRight()
protected javax.swing.JPanel getEditorBarLeft()
protected javax.swing.JScrollPane getTextScroller()
protected java.awt.Insets getChatPanelInsets()
protected java.awt.Insets getChatAreaInsets()
protected java.awt.Insets getEditorWrapperInsets()
public void addChatRoomComponent(javax.swing.JComponent component)
public void addChatRoomButton(ChatRoomButton button)
public void addChatRoomButton(ChatRoomButton button, boolean forceRepaint)
public void showToolbar()
public void hideToolbar()
public void addEditorComponent(javax.swing.JComponent component)
public void removeEditorComponent(javax.swing.JComponent component)
public void addControllerButton(RolloverButton button)