|
|
|
|
@ -15,10 +15,8 @@
|
|
|
|
|
import javax.swing.text.*;
|
|
|
|
|
import javax.swing.undo.*;
|
|
|
|
|
|
|
|
|
|
import net.java.sip.communicator.impl.gui.customcontrols.*;
|
|
|
|
|
import net.java.sip.communicator.impl.gui.i18n.*;
|
|
|
|
|
import net.java.sip.communicator.impl.gui.lookandfeel.*;
|
|
|
|
|
import net.java.sip.communicator.impl.gui.main.message.ChatWindow.*;
|
|
|
|
|
import net.java.sip.communicator.impl.gui.main.message.menus.*;
|
|
|
|
|
import net.java.sip.communicator.impl.gui.utils.*;
|
|
|
|
|
import net.java.sip.communicator.service.protocol.*;
|
|
|
|
|
@ -84,6 +82,9 @@ public ChatWritePanel(ChatPanel panel) {
|
|
|
|
|
this.getVerticalScrollBar().setUnitIncrement(30);
|
|
|
|
|
|
|
|
|
|
this.typingTimer.setRepeats(true);
|
|
|
|
|
|
|
|
|
|
//initialize send command to Ctrl+Enter
|
|
|
|
|
this.changeSendCommand(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -93,6 +94,65 @@ public ChatWritePanel(ChatPanel panel) {
|
|
|
|
|
public JEditorPane getEditorPane() {
|
|
|
|
|
return editorPane;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Replaces the Ctrl+Enter send command with simple Enter.
|
|
|
|
|
*/
|
|
|
|
|
public void changeSendCommand(boolean isEnter)
|
|
|
|
|
{
|
|
|
|
|
this.editorPane.getActionMap().put("send", new SendMessageAction());
|
|
|
|
|
this.editorPane.getActionMap().put("newLine", new NewLineAction());
|
|
|
|
|
|
|
|
|
|
InputMap im = this.editorPane.getInputMap();
|
|
|
|
|
|
|
|
|
|
if(isEnter) {
|
|
|
|
|
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "send");
|
|
|
|
|
im.put(KeyStroke.getKeyStroke(
|
|
|
|
|
KeyEvent.VK_ENTER, KeyEvent.CTRL_DOWN_MASK), "newLine");
|
|
|
|
|
im.put(KeyStroke.getKeyStroke(
|
|
|
|
|
KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK), "newLine");
|
|
|
|
|
|
|
|
|
|
chatPanel.getChatSendPanel().getSendButton()
|
|
|
|
|
.setToolTipText(Messages.getString("sendMessage") + " Enter");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
im.put(KeyStroke.getKeyStroke(
|
|
|
|
|
KeyEvent.VK_ENTER, KeyEvent.CTRL_DOWN_MASK), "send");
|
|
|
|
|
im.put(KeyStroke.getKeyStroke(
|
|
|
|
|
KeyEvent.VK_ENTER, 0), "newLine");
|
|
|
|
|
|
|
|
|
|
chatPanel.getChatSendPanel().getSendButton()
|
|
|
|
|
.setToolTipText(Messages.getString("sendMessage") + " Ctrl-Enter");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The <tt>SendMessageAction</tt> is an <tt>AbstractAction</tt> that
|
|
|
|
|
* sends the text that is currently in the write message area.
|
|
|
|
|
*/
|
|
|
|
|
private class SendMessageAction
|
|
|
|
|
extends AbstractAction
|
|
|
|
|
{
|
|
|
|
|
public void actionPerformed(ActionEvent e)
|
|
|
|
|
{
|
|
|
|
|
// chatPanel.stopTypingNotifications();
|
|
|
|
|
chatPanel.sendMessage();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The <tt>NewLineAction</tt> is an <tt>AbstractAction</tt> that
|
|
|
|
|
* types an enter in the write message area.
|
|
|
|
|
*/
|
|
|
|
|
private class NewLineAction
|
|
|
|
|
extends AbstractAction
|
|
|
|
|
{
|
|
|
|
|
public void actionPerformed(ActionEvent e)
|
|
|
|
|
{
|
|
|
|
|
editorPane.setText(editorPane.getText()
|
|
|
|
|
+ System.getProperty("line.separator"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handles the <tt>UndoableEditEvent</tt>, by adding the content edit
|
|
|
|
|
|