Package jadex.tools.chat
Class ChatPanel
- java.lang.Object
-
- jadex.base.gui.componentviewer.AbstractServiceViewerPanel<IChatGuiService>
-
- jadex.tools.chat.ChatPanel
-
- All Implemented Interfaces:
IAbstractViewerPanel
,IServiceViewerPanel
,IPropertiesProvider
public class ChatPanel extends AbstractServiceViewerPanel<IChatGuiService>
Panel for displaying the chat.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ChatPanel.FileTableModel
Table model for up/downloads.class
ChatPanel.FileTransferMouseAdapter
Mouse listener that allows to manipulate transfers.class
ChatPanel.UserTableModel
Table model for list of users.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
autorefresh
The autorefresh flag.protected boolean
away
The away state.protected javax.swing.Timer
awaytimer
The away timer.protected javax.swing.JTextPane
chatarea
The text area.java.text.DateFormat
df
The time format.protected java.util.Map<TransferInfo,javax.swing.JComponent>
dialogs
Map for panels of open accept dialogs to close when transfer has been accepted/rejected/timeouted in background.protected javax.swing.JTable
dtable
The download table.protected javax.swing.JFileChooser
filechooser
The file chooser (created on demand, if local).protected JSplitPanel
horsplit
The main split panel between left and right.protected static javax.swing.UIDefaults
icons
The icons.protected javax.swing.Timer
icontimer
The timer for the flashing chat icon.static java.lang.String
lf
The linefeed separator.protected JSplitPanel
listpan
The split panel on left hand side.static java.lang.String
NOTIFICATION_FILE_ABORT
The notification sound for an aborted or failed file transfer.static java.lang.String
NOTIFICATION_FILE_COMPLETE
The notification sound for a successfully completed file.static java.lang.String
NOTIFICATION_MSG_FAILED
The notification sound for a failed message.static java.lang.String
NOTIFICATION_NEW_FILE
The notification sound for an incoming file request.static java.lang.String
NOTIFICATION_NEW_MSG
The notification sound for a new message.static java.lang.String
NOTIFICATION_NEW_USER
The notification sound for a newly online user.protected static java.util.Map<java.lang.String,java.lang.String>
NOTIFICATION_SOUNDS
The default notification sounds.protected java.util.Map<java.lang.String,java.lang.String>
notificationsounds
The custom notification sounds.protected javax.swing.JPanel
panel
The chat panel.protected boolean
playing
Flag to indicate that a sound is playing.protected javax.swing.Timer
refreshtimer
The refresh timer.protected int
reqcnt
The message counter to differentiate sent messages.protected RemoteFileChooser
rfilechooser
The remote file chooser (created on demand, if remote).protected static java.util.List<java.lang.String>
smileys
protected boolean
sound
The sound flag.protected ISubscriptionIntermediateFuture<ChatEvent>
subscription
Registration at the service.protected javax.swing.JTabbedPane
tpane
The tabbed pane.protected boolean
typing
The typing state.protected ChatPanel.UserTableModel
usermodel
protected javax.swing.JTable
usertable
The user table.protected javax.swing.JTable
utable
The upload table.-
Fields inherited from class jadex.base.gui.componentviewer.AbstractServiceViewerPanel
jcc, service, shutdown
-
Fields inherited from interface jadex.base.gui.componentviewer.IAbstractViewerPanel
PROPERTY_VIEWERCLASS
-
-
Constructor Summary
Constructors Constructor Description ChatPanel()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IFuture<java.lang.String>
acceptFile(TransferInfo ti)
Open dialog and check if user wants to receive the file.void
addMessage(IComponentIdentifier cid, java.lang.String text, java.lang.String nick, boolean privatemessage, boolean sendfailure)
Add a message to the text area.static void
append(java.awt.Color c, java.lang.String s, javax.swing.JTextPane p)
Append text.static void
doAppend(java.awt.Color c, java.lang.String s, javax.swing.JTextPane p)
javax.swing.JComponent
getComponent()
Get the plugin view.java.lang.String
getNotificationSound(java.lang.String type)
Get the notification sound.IFuture<Properties>
getProperties()
Write current state into properties.IFuture<java.lang.Void>
init(IControlCenter jcc, IService service)
Called once to initialize the panel.protected void
notifyChatEvent(java.lang.String type, IComponentIdentifier source, java.lang.Object value, boolean quiet)
Show a status message and optionally play a notification sound.protected void
playSound(java.lang.String type, boolean verbose)
Play the notification sound for the selected event.IFuture<java.lang.Void>
postStatus()
Post the local state to available chattersprotected void
setAway(boolean away)
Change the status to away and post a change, if necessary.IFuture<java.lang.Void>
setProperties(Properties props)
Update from given properties.void
setUserState(IComponentIdentifier cid, java.lang.Boolean online, java.lang.Boolean typing, java.lang.Boolean away, java.lang.String nickname, byte[] image)
Add a user or change its state.IFuture<java.lang.Void>
shutdown()
Informs the panel that it should stop all its computationIFuture<java.lang.Void>
tell(java.lang.String text)
Send a message.protected void
updateChatUser(IComponentIdentifier cid, IChatService cs)
protected void
updateRefreshTimer()
Start or stop the refresh timer, if necessary.void
updateTransfer(TransferInfo fi)
Update the fileinfo in the upload/download area.-
Methods inherited from class jadex.base.gui.componentviewer.AbstractServiceViewerPanel
getId, getJCC, getService, getServiceAccess, isLocal, isShutdown
-
-
-
-
Field Detail
-
icons
protected static final javax.swing.UIDefaults icons
The icons.
-
smileys
protected static final java.util.List<java.lang.String> smileys
-
lf
public static final java.lang.String lf
The linefeed separator.
-
df
public final java.text.DateFormat df
The time format.
-
NOTIFICATION_NEW_USER
public static final java.lang.String NOTIFICATION_NEW_USER
The notification sound for a newly online user.- See Also:
- Constant Field Values
-
NOTIFICATION_NEW_MSG
public static final java.lang.String NOTIFICATION_NEW_MSG
The notification sound for a new message.- See Also:
- Constant Field Values
-
NOTIFICATION_MSG_FAILED
public static final java.lang.String NOTIFICATION_MSG_FAILED
The notification sound for a failed message.- See Also:
- Constant Field Values
-
NOTIFICATION_NEW_FILE
public static final java.lang.String NOTIFICATION_NEW_FILE
The notification sound for an incoming file request.- See Also:
- Constant Field Values
-
NOTIFICATION_FILE_COMPLETE
public static final java.lang.String NOTIFICATION_FILE_COMPLETE
The notification sound for a successfully completed file.- See Also:
- Constant Field Values
-
NOTIFICATION_FILE_ABORT
public static final java.lang.String NOTIFICATION_FILE_ABORT
The notification sound for an aborted or failed file transfer.- See Also:
- Constant Field Values
-
NOTIFICATION_SOUNDS
protected static final java.util.Map<java.lang.String,java.lang.String> NOTIFICATION_SOUNDS
The default notification sounds.
-
panel
protected javax.swing.JPanel panel
The chat panel.
-
chatarea
protected javax.swing.JTextPane chatarea
The text area.
-
usertable
protected javax.swing.JTable usertable
The user table.
-
usermodel
protected ChatPanel.UserTableModel usermodel
-
typing
protected boolean typing
The typing state.
-
away
protected boolean away
The away state.
-
dtable
protected javax.swing.JTable dtable
The download table.
-
utable
protected javax.swing.JTable utable
The upload table.
-
tpane
protected javax.swing.JTabbedPane tpane
The tabbed pane.
-
subscription
protected ISubscriptionIntermediateFuture<ChatEvent> subscription
Registration at the service.
-
refreshtimer
protected javax.swing.Timer refreshtimer
The refresh timer.
-
awaytimer
protected javax.swing.Timer awaytimer
The away timer.
-
listpan
protected JSplitPanel listpan
The split panel on left hand side.
-
horsplit
protected JSplitPanel horsplit
The main split panel between left and right.
-
sound
protected boolean sound
The sound flag.
-
autorefresh
protected boolean autorefresh
The autorefresh flag.
-
notificationsounds
protected java.util.Map<java.lang.String,java.lang.String> notificationsounds
The custom notification sounds.
-
filechooser
protected javax.swing.JFileChooser filechooser
The file chooser (created on demand, if local).
-
rfilechooser
protected RemoteFileChooser rfilechooser
The remote file chooser (created on demand, if remote).
-
dialogs
protected java.util.Map<TransferInfo,javax.swing.JComponent> dialogs
Map for panels of open accept dialogs to close when transfer has been accepted/rejected/timeouted in background.
-
reqcnt
protected int reqcnt
The message counter to differentiate sent messages.
-
icontimer
protected javax.swing.Timer icontimer
The timer for the flashing chat icon.
-
playing
protected boolean playing
Flag to indicate that a sound is playing.
-
-
Method Detail
-
init
public IFuture<java.lang.Void> init(IControlCenter jcc, IService service)
Called once to initialize the panel. Called on the swing thread.- Specified by:
init
in interfaceIServiceViewerPanel
- Overrides:
init
in classAbstractServiceViewerPanel<IChatGuiService>
- Parameters:
jcc
- The jcc.service
- The service.
-
updateRefreshTimer
protected void updateRefreshTimer()
Start or stop the refresh timer, if necessary.
-
setAway
protected void setAway(boolean away)
Change the status to away and post a change, if necessary.
-
updateChatUser
protected void updateChatUser(IComponentIdentifier cid, IChatService cs)
-
getComponent
public javax.swing.JComponent getComponent()
Get the plugin view.- Specified by:
getComponent
in interfaceIAbstractViewerPanel
- Specified by:
getComponent
in classAbstractServiceViewerPanel<IChatGuiService>
- Returns:
- The component to be displayed.
-
shutdown
public IFuture<java.lang.Void> shutdown()
Informs the panel that it should stop all its computation- Specified by:
shutdown
in interfaceIAbstractViewerPanel
- Overrides:
shutdown
in classAbstractServiceViewerPanel<IChatGuiService>
-
tell
public IFuture<java.lang.Void> tell(java.lang.String text)
Send a message.- Parameters:
text
- The text.
-
postStatus
public IFuture<java.lang.Void> postStatus()
Post the local state to available chatters
-
addMessage
public void addMessage(IComponentIdentifier cid, java.lang.String text, java.lang.String nick, boolean privatemessage, boolean sendfailure)
Add a message to the text area.
-
setUserState
public void setUserState(IComponentIdentifier cid, java.lang.Boolean online, java.lang.Boolean typing, java.lang.Boolean away, java.lang.String nickname, byte[] image)
Add a user or change its state.
-
acceptFile
public IFuture<java.lang.String> acceptFile(TransferInfo ti)
Open dialog and check if user wants to receive the file.- Returns:
- The path name to store the file, if accepted.
-
notifyChatEvent
protected void notifyChatEvent(java.lang.String type, IComponentIdentifier source, java.lang.Object value, boolean quiet)
Show a status message and optionally play a notification sound.
-
playSound
protected void playSound(java.lang.String type, boolean verbose)
Play the notification sound for the selected event.- Parameters:
type
- The notification event.
-
updateTransfer
public void updateTransfer(TransferInfo fi)
Update the fileinfo in the upload/download area.
-
append
public static void append(java.awt.Color c, java.lang.String s, javax.swing.JTextPane p)
Append text.
-
doAppend
public static void doAppend(java.awt.Color c, java.lang.String s, javax.swing.JTextPane p)
-
getNotificationSound
public java.lang.String getNotificationSound(java.lang.String type)
Get the notification sound.
-
setProperties
public IFuture<java.lang.Void> setProperties(Properties props)
Update from given properties.- Specified by:
setProperties
in interfaceIPropertiesProvider
- Overrides:
setProperties
in classAbstractServiceViewerPanel<IChatGuiService>
-
getProperties
public IFuture<Properties> getProperties()
Write current state into properties.- Specified by:
getProperties
in interfaceIPropertiesProvider
- Overrides:
getProperties
in classAbstractServiceViewerPanel<IChatGuiService>
-
-