public void mouseClicked(MouseEvent e) { if(e.getClickCount()!=2){ getChatInputEditor().requestFocus(); } }
@Override public void actionPerformed( ActionEvent e ) { getChatInputEditor().appendText( match.substring( needle.length() ) ); popup.setVisible( false ); } } );
public void focusLost(FocusEvent focusEvent) { if(focusEvent.getComponent().equals(getChatInputEditor())) { setChatState( ChatState.inactive ); } }
public void mouseReleased(MouseEvent e) { mousePressed = false; if (transcriptWindow.getSelectedText() == null) { getChatInputEditor().requestFocus(); } }
/** * Requests valid focus to the SendField. */ public void positionCursor() { getChatInputEditor().setCaretPosition(getChatInputEditor().getCaretPosition()); chatAreaButton.getChatInputArea().requestFocusInWindow(); }
public void actionPerformed(ActionEvent e) { sendMessage(); // Clear send field and disable send button getChatInputEditor().clear(); chatAreaButton.getButton().setEnabled(false); }
public void mouseClicked(MouseEvent e) { // Show popup final JPopupMenu popup = new JPopupMenu(); EmoticonUI emoticonUI = new EmoticonUI(); emoticonUI .setEmoticonPickListener( emoticon -> { try { popup.setVisible(false); final ChatInputEditor editor = room.getChatInputEditor(); String currentText = editor.getText(); if (currentText.length() == 0 || currentText.endsWith(" ")) { room.getChatInputEditor().insertText(emoticon + " "); } else { room.getChatInputEditor() .insertText(" " + emoticon + " "); } room.getChatInputEditor().requestFocus(); } catch (BadLocationException e1) { Log.error(e1); } } ); popup.add(emoticonUI); popup.show(emoticonPicker, e.getX(), e.getY()); } });
public void doRun() { try { //chatFrame.requestFocus(); ChatRoom chatRoom = getActiveChatRoom(); chatRoom.getChatInputEditor().requestFocusInWindow(); updateActiveTab(); } catch (ChatRoomNotFoundException e1) { // Ignore. There may legitamtly not be a chat room. } } };
/** * Checks to see if enter was pressed and validates room. * * @param e the KeyEvent */ private void checkForEnter(KeyEvent e) { final KeyStroke keyStroke = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers()); if (!keyStroke.equals(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK)) && e.getKeyChar() == KeyEvent.VK_ENTER) { e.consume(); sendMessage(); getChatInputEditor().setText(""); getChatInputEditor().setCaretPosition(0); SparkManager.getWorkspace().getTranscriptPlugin().persistChatRoom(this); } else if (keyStroke.equals(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK))) { final Document document = getChatInputEditor().getDocument(); try { document.insertString(getChatInputEditor().getCaretPosition(), "\n", null); getChatInputEditor().requestFocusInWindow(); chatAreaButton.getButton().setEnabled(true); } catch (BadLocationException badLoc) { Log.error("Error when checking for enter:", badLoc); } } }
public void focusGained(FocusEvent focusEvent) { validate(); invalidate(); repaint(); if(focusEvent.getComponent().equals(getChatInputEditor())) { setChatState( ChatState.active ); } }
if (o instanceof String) { chatRoom.getChatInputEditor().insertText((String)o); return true;
public void closing() { chatRoom.removeFileDropListener(this); chatRoom.getChatInputEditor().removeKeyListener(this); chatRoom.removeClosingListener(this); sendFileButton.removeActionListener(this); sendScreenShotButton.removeActionListener(this); } }
final String text = getChatInputEditor().getText(); if ( text == null || text.isEmpty() ) getChatInputEditor().appendText( matches.iterator().next().substring( needle.length() ) ); getChatInputEditor().getCaret().getMagicCaretPosition().x, SparkManager.getChatManager().getChatContainer().getHeight() - 20 );
/** * 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); }
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(); }
transcriptWindow.setBackground(Color.white); getChatInputEditor().setSelectedTextColor((Color)UIManager.get("ChatInput.SelectedTextColor")); getChatInputEditor().setSelectionColor((Color)UIManager.get("ChatInput.SelectionColor")); getChatInputEditor().getDocument().addDocumentListener(this); getChatInputEditor().addKeyListener(chatEditorKeyListener); getChatInputEditor().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ctrl F4"), "closeTheRoom"); getChatInputEditor().getActionMap().put("closeTheRoom", new AbstractAction("closeTheRoom") { private static final long serialVersionUID = 1L; getChatInputEditor().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ctrl SPACE"), "handleCompletion"); getChatInputEditor().getActionMap().put("handleCompletion", new AbstractAction("handleCompletion") { private static final long serialVersionUID = 1L; getChatInputEditor().setTransferHandler(transferHandler);
/** * 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(); }
public ChatRoomTransferDecorator(final ChatRoom chatRoom) { this.chatRoom = chatRoom; chatRoom.addFileDropListener(this); chatRoom.getChatInputEditor().addKeyListener(this); chatRoom.addClosingListener(this); sendFileButton = UIComponentRegistry.getButtonFactory().createSendFileButton(); sendFileButton.setToolTipText(Res.getString("message.send.file.to.user")); chatRoom.addChatRoomButton(sendFileButton); sendFileButton.addActionListener(this); sendScreenShotButton = UIComponentRegistry.getButtonFactory().createScreenshotButton(); sendScreenShotButton.setToolTipText(Res.getString("message.send.picture")); chatRoom.addChatRoomButton(sendScreenShotButton); sendScreenShotButton.addActionListener(this); }
room.getChatInputEditor().addKeyListener(this);