chatroom.java.svn-base
来自「开源项目openfire的完整源程序」· SVN-BASE 代码 · 共 1,006 行 · 第 1/3 页
SVN-BASE
1,006 行
* transcript mode.
*
* @return true if the chat room is active.
*/
public abstract boolean isActive();
/**
* Returns the notification label. The notification label notifies the
* user of chat room activity, such as the date of the last message
* and typing notifications.
*
* @return the notification label.
*/
public JLabel getNotificationLabel() {
return notificationLabel;
}
/**
* Adds a packetID to the packedIDList. The packetIDLlist
* keeps track of all messages coming into the chatroom.
*
* @param packetID the packetID to add.
*/
public void addPacketID(String packetID) {
packetIDList.add(packetID);
}
/**
* Checks if the packetID has already been used.
*
* @param packetID the packetID to check for.
* @return true if the packetID already exists.
*/
public boolean packetIDExists(String packetID) {
return packetIDList.contains(packetID);
}
/**
* Returns this instance of the chatroom.
*
* @return the current ChatRoom instance.
*/
public ChatRoom getChatRoom() {
return this;
}
/**
* Returns the toolbar used on top of the chat room.
*
* @return the toolbar used on top of this chat room.
*/
public ChatToolBar getToolBar() {
return toolbar;
}
public void insertUpdate(DocumentEvent e) {
// Meant to be overriden
checkForText(e);
}
/**
* Override to save transcript in preferred room style.
*/
public void saveTranscript() {
getTranscriptWindow().saveTranscript(getTabTitle() + ".html", getTranscripts(), null);
}
/**
* Returns the button panel. The Button Panel contains all tool items
* above the send field.
*
* @return the chat's button panel.
*/
public JPanel getSendFieldToolbar() {
return editorBar;
}
/**
* Used for the top toolbar.
*/
public class ChatToolBar extends JPanel {
private JPanel buttonPanel;
/**
* Default Constructor.
*/
public ChatToolBar() {
buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 0));
// Set Layout
setLayout(new GridBagLayout());
buttonPanel.setOpaque(false);
add(buttonPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
setOpaque(false);
}
/**
* Adds a new ChatRoomButton the CommandBar.
*
* @param button the button.
*/
public void addChatRoomButton(ChatRoomButton button) {
buttonPanel.add(button);
// Make all JButtons the same size
Component[] comps = buttonPanel.getComponents();
final int no = comps != null ? comps.length : 0;
final List<Component> buttons = new ArrayList<Component>();
for (int i = 0; i < no; i++) {
Component component = comps[i];
if (component instanceof JButton) {
buttons.add(component);
}
}
GraphicUtils.makeSameSize((JComponent[])buttons.toArray(new JComponent[buttons.size()]));
}
/**
* Removes the ChatRoomButton from the CommandBar.
*
* @param button the button.
*/
public void removeChatRoomButton(ChatRoomButton button) {
buttonPanel.remove(button);
}
}
/**
* Returns the number of unread messages in this ChatRoom.
*
* @return the number of unread messages.
*/
public int getUnreadMessageCount() {
return unreadMessageCount;
}
/**
* Increases the number of unread messages by 1.
*/
public void increaseUnreadMessageCount() {
unreadMessageCount++;
}
/**
* Resets the number of unread messages.
*/
public void clearUnreadMessageCount() {
unreadMessageCount = 0;
}
/**
* Returns the bottom panel used in the ChatRoom.
*
* @return the bottomPane;
*/
public JPanel getBottomPanel() {
return bottomPanel;
}
/**
* Returns the Container which holds the ChatWindow.
*
* @return the Container.
*/
public JPanel getChatWindowPanel() {
return chatWindowPanel;
}
/**
* Adds a new <code>FileDropListener</code> to allow for Drag and Drop notifications
* of objects onto the ChatWindow.
*
* @param listener the listener.
*/
public void addFileDropListener(FileDropListener listener) {
fileDropListeners.add(listener);
}
/**
* Remove the <code>FileDropListener</code> from ChatRoom.
*
* @param listener the listener.
*/
public void removeFileDropListener(FileDropListener listener) {
fileDropListeners.remove(listener);
}
/**
* Notify all users that a collection of files has been dropped onto the ChatRoom.
*
* @param files the files dropped.
*/
public void fireFileDropListeners(Collection files) {
for (FileDropListener fileDropListener : fileDropListeners) {
fileDropListener.filesDropped(files, this);
}
}
/**
* Returns the panel which contains the toolbar items, such as spell checker.
*
* @return the panel which contains the lower toolbar items.
*/
public JPanel getEditorBar() {
return editorBar;
}
/**
* Adds a <code>ChatRoomClosingListener</code> to this ChatRoom. A ChatRoomClosingListener
* is notified whenever this room is closing.
*
* @param listener the ChatRoomClosingListener.
*/
public void addClosingListener(ChatRoomClosingListener listener) {
closingListeners.add(listener);
}
/**
* Removes a <code>ChatRoomClosingListener</code> from this ChatRoom.
*
* @param listener the ChatRoomClosingListener.
*/
public void removeClosingListener(ChatRoomClosingListener listener) {
closingListeners.remove(listener);
}
/**
* Notifies all <code>ChatRoomClosingListener</code> that this ChatRoom is closing.
*/
private void fireClosingListeners() {
for (ChatRoomClosingListener chatRoomClosingListener : closingListeners) {
chatRoomClosingListener.closing();
removeClosingListener(chatRoomClosingListener);
}
}
/**
* Returns the ScrollPane that contains the TranscriptWindow.
*
* @return the <code>TranscriptWindow</code> ScrollPane.
*/
public JScrollPane getScrollPaneForTranscriptWindow() {
return textScroller;
}
/**
* Return the "Send" button.
*
* @return the send button.
*/
public JButton getSendButton() {
return chatAreaButton.getButton();
}
/**
* Returns the VerticalSplitPane used in this ChatRoom.
*
* @return the VerticalSplitPane.
*/
public JSplitPane getVerticalSlipPane() {
return verticalSplit;
}
public void focusGained(FocusEvent focusEvent) {
validate();
invalidate();
repaint();
verticalSplit.setDividerLocation(-1);
}
public void poppingUp(Object component, JPopupMenu popup) {
Action saveAction = new AbstractAction() {
public void actionPerformed(ActionEvent actionEvent) {
saveTranscript();
}
};
saveAction.putValue(Action.NAME, "Save");
saveAction.putValue(Action.SMALL_ICON, SparkRes.getImageIcon(SparkRes.SAVE_AS_16x16));
popup.add(saveAction);
}
public void poppingDown(JPopupMenu popup) {
}
public boolean handleDefaultAction(MouseEvent e) {
return false;
}
public void focusLost(FocusEvent focusEvent) {
}
/**
* Implementation of this method should return the last time this chat room
* sent or recieved a message.
*
* @return the last time (in system milliseconds) that the room last recieved a message.
*/
public abstract long getLastActivity();
public void connectionClosed() {
}
public void connectionClosedOnError(Exception e) {
}
public void reconnectingIn(int seconds) {
}
public void reconnectionSuccessful() {
}
public void reconnectionFailed(Exception e) {
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?