/** * Prints the transcript of a given chat room. * * @param room the chat room that contains the transcript to print. */ public static void printChatRoomTranscript(ChatRoom room) { final ChatPrinter printer = new ChatPrinter(); final TranscriptWindow currentWindow = room.getTranscriptWindow(); if (currentWindow != null) { printer.print(currentWindow); } }
/** * Override to save transcript in preferred room style. */ public void saveTranscript() { getTranscriptWindow().saveTranscript(getTabTitle() + ".html", getTranscripts(), null); }
private void insertMessage(final BareJid bareJID, final Message message) throws ChatRoomNotFoundException { ChatRoom chatRoom = SparkManager.getChatManager().getChatContainer().getChatRoom(bareJID); chatRoom.insertMessage(message); int chatLength = chatRoom.getTranscriptWindow().getDocument().getLength(); chatRoom.getTranscriptWindow().setCaretPosition(chatLength); chatRoom.getChatInputEditor().requestFocusInWindow(); }
/** * Sends the Answer Form * @param answer <u>must be an answer-form</u> * @param chat */ private void sendAnswerForm(Form answer, MultiUserChat chat) { ChatRoom room = SparkManager.getChatManager().getChatRoom(chat.getRoom().toString()); for (String key : _map.keySet()) { String value = getValueFromComponent(key); answer.setAnswer(key, value); } try { chat.sendRegistrationForm(answer); String reg = Res.getString("message.groupchat.registered.member", chat.getRoom()); room.getTranscriptWindow().insertNotificationMessage(reg,ChatManager.NOTIFICATION_COLOR); } catch (XMPPException | SmackException | InterruptedException e) { room.getTranscriptWindow().insertNotificationMessage(e.getMessage(),ChatManager.ERROR_COLOR); } }
/** * Close the ChatRoom. */ public void closeChatRoom() { fireClosingListeners(); setChatState(ChatState.gone); if (typingTimerTask != null) { TaskEngine.getInstance().cancelScheduledTask(typingTimerTask); typingTimerTask = null; } getTranscriptWindow().removeContextMenuListener(this); getTranscriptWindow().removeMouseListener(transcriptWindowMouseListener); getChatInputEditor().removeKeyListener(chatEditorKeyListener); this.removeAll(); textScroller.getViewport().remove(transcriptWindow); // Remove Connection Listener SparkManager.getConnection().removeConnectionListener(this); getTranscriptWindow().setTransferHandler(null); getChatInputEditor().setTransferHandler(null); transferHandler = null; packetIDList.clear(); messageListeners.clear(); fileDropListeners.clear(); getChatInputEditor().close(); getChatInputEditor().getActionMap().remove("closeTheRoom"); chatAreaButton.getButton().removeActionListener(this); bottomPanel.remove(chatAreaButton); _chatFrame.removeWindowToFrontListener(this); }
/** * Removes the ChatRoom resources. * * @param room the room to remove. */ private void cleanupChatRoom(ChatRoom room) { if (room.isActive()) { room.leaveChatRoom(); room.closeChatRoom(); } final StanzaListener listener = presenceMap.get(room.getRoomname()); if (listener != null) { SparkManager.getConnection().removeAsyncStanzaListener(listener); } fireChatRoomClosed(room); room.removeMessageListener(this); // Remove mappings presenceMap.remove(room.getRoomname()); chatRoomList.remove(room); room.getChatInputEditor().removeKeyListener(this); // Clear all Text :) room.getTranscriptWindow().cleanup(); }
getTranscriptWindow().addContextMenuListener(this); getTranscriptWindow().setTransferHandler(transferHandler); getChatInputEditor().setTransferHandler(transferHandler);
@Override public void finished() { final EntityBareJid roomName = roomJID; try { final ChatRoom room = SparkManager.getChatManager().getChatContainer().getChatRoom( roomName ); final TranscriptWindow transcriptWindow = room.getTranscriptWindow(); for ( final EntityBareJid jid : (Set<EntityBareJid>) getValue() ) { final String notification = Res.getString( "message.waiting.for.user.to.join", jid ); transcriptWindow.insertNotificationMessage( notification, ChatManager.NOTIFICATION_COLOR ); } } catch ( ChatRoomNotFoundException e ) { Log.error( "Unable to identify chat room tab by name: " + roomName ); } } }
chatRoom.getTranscriptWindow().insertNotificationMessage(Res.getString("message.buzz.sent"), ChatManager.NOTIFICATION_COLOR); buzzButton.setEnabled(false);
chatRoom.getTranscriptWindow().insertNotificationMessage("The user is offline. Will auto-send \"" + file.getName() + "\" when user comes back online.", ChatManager.ERROR_COLOR); return null; TranscriptWindow transcriptWindow = chatRoom.getTranscriptWindow();
EventQueue.invokeLater( () -> room.getTranscriptWindow().insertNotificationMessage(infoText, ChatManager.NOTIFICATION_COLOR) );
chatRoom.getTranscriptWindow().insertNotificationMessage( nickname + " has rejected the invitation.", ChatManager.NOTIFICATION_COLOR);
private void handleTransferRequest(FileTransferRequest request, ContactList contactList) { // Check if a listener handled this request if (fireTransferListeners(request)) { return; } Jid requestor = request.getRequestor(); EntityBareJid bareJID = requestor.asEntityBareJidOrThrow(); String fileName = request.getFileName(); ContactItem contactItem = contactList.getContactItemByJID(bareJID); ChatRoom chatRoom; if (contactItem != null) { chatRoom = SparkManager.getChatManager().createChatRoom(bareJID, contactItem.getDisplayName(), contactItem.getDisplayName()); } else { chatRoom = SparkManager.getChatManager().createChatRoom(bareJID, bareJID, bareJID); } TranscriptWindow transcriptWindow = chatRoom.getTranscriptWindow(); transcriptWindow.insertCustomText(Res.getString("message.file.transfer.chat.window"), true, false, Color.BLACK); final ReceiveFileTransfer receivingMessageUI = new ReceiveFileTransfer(); receivingMessageUI.acceptFileTransfer(request); chatRoom.addClosingListener( () -> receivingMessageUI.cancelTransfer() ); transcriptWindow.addComponent(receivingMessageUI); chatRoom.increaseUnreadMessageCount(); chatRoom.scrollToBottom(); String fileTransMsg = contactItem.getDisplayName() + " " + Res.getString("message.file.transfer.short.message") + " " + fileName; SparkManager.getChatManager().getChatContainer().fireNotifyOnMessage(chatRoom, true, fileTransMsg, Res.getString("message.file.transfer.notification")); }
chatRoom.getTranscriptWindow().addComponent(invitationUI);
room.getTranscriptWindow().insertNotificationMessage( Res.getString("message.buzz.message", nickname), ChatManager.NOTIFICATION_COLOR);
room.getTranscriptWindow().insertMessage(nickname, message, ChatManager.FROM_COLOR); room.addToTranscript(message, true);