Base configuration of the send message command

cusax-fix
Yana Stamcheva 20 years ago
parent 8a41517257
commit 8ca13dc9ec

@ -62,6 +62,7 @@ duration=Duration
edit=Edit
emptyHistory=Empty history
enableNotifications=Enable notifications
enableTypingNotifications=Enable typing notifications
error=Error
exit=Exit
extendedCriteria=Extended criteria
@ -160,6 +161,7 @@ selectProvidersWizard=The list below contains all registered accounts. Select th
selectProvidersWizardTitle=Select account(s)
send=Send
sendFile=Send file
useEnterToSend=Use Enter to send
sendMessage=Send a message
sendVia=Send via
settings=Settings
@ -171,7 +173,6 @@ statusChangeNetworkFailure=The status could not be changed due to a network \n f
summary=Summary
today=Today
tools=Tools
typingNotifications=Typing notifications
uin=UIN:
unknown=Unknown user
msgDeliveryFailedUnknownError=Unknown error has occured while delivering your message.

@ -17,6 +17,7 @@
import net.java.sip.communicator.impl.gui.customcontrols.events.*;
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.message.ChatWritePanel.*;
import net.java.sip.communicator.impl.gui.main.message.menus.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.contactlist.*;
@ -90,9 +91,7 @@ public ChatWindow(MainFrame mainFrame)
this.addKeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_C,
KeyEvent.META_MASK), new CopyAction());
this.addKeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_V,
KeyEvent.META_MASK), new PasteAction());
this.addKeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
KeyEvent.CTRL_DOWN_MASK), new SendMessageAction());
KeyEvent.META_MASK), new PasteAction());
this.addKeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_M,
KeyEvent.CTRL_DOWN_MASK), new OpenSmileyAction());
this.addKeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_P,
@ -103,6 +102,15 @@ public ChatWindow(MainFrame mainFrame)
this.addWindowListener(new ChatWindowAdapter());
}
/**
* Changes the Ctrl+Enter message command with Enter or vice versa.
*/
public void changeSendCommand(boolean isEnter)
{
this.getCurrentChatPanel().getChatWritePanel()
.changeSendCommand(isEnter);
}
/**
* Initializes this window, by adding the menus.
*/

@ -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

@ -20,7 +20,11 @@ public class SettingsMenu extends JMenu
private JCheckBoxMenuItem typingNotificationsItem
= new JCheckBoxMenuItem(
Messages.getString("typingNotifications"), true);
Messages.getString("enableTypingNotifications"), true);
private JCheckBoxMenuItem sendingMessageCommandItem
= new JCheckBoxMenuItem(
Messages.getString("useEnterToSend"), false);
private ChatWindow chatWindow;
@ -35,6 +39,9 @@ public SettingsMenu(ChatWindow chatWindow){
this.chatWindow = chatWindow;
typingNotificationsItem.setName("typingNotifications");
sendingMessageCommandItem.setName("sendingMessageCommand");
this.setMnemonic(Messages.getString("mnemonic.chatSettings").charAt(0));
this.typingNotificationsItem.setMnemonic(
Messages.getString("mnemonic.typingNotifications").charAt(0));
@ -47,8 +54,10 @@ public SettingsMenu(ChatWindow chatWindow){
*/
private void init(){
this.add(typingNotificationsItem);
this.add(sendingMessageCommandItem);
this.typingNotificationsItem.addActionListener(this);
this.sendingMessageCommandItem.addActionListener(this);
}
/**
@ -57,11 +66,18 @@ private void init(){
public void actionPerformed(ActionEvent e) {
JCheckBoxMenuItem item = (JCheckBoxMenuItem)e.getSource();
if (item.isSelected()) {
chatWindow.enableTypingNotification(true);
if(item.getName().equals("typingNotifications")) {
if (item.isSelected()) {
chatWindow.enableTypingNotification(true);
}
else {
chatWindow.enableTypingNotification(false);
}
}
else if(item.getName().equals("sendingMessageCommand")) {
chatWindow.changeSendCommand(item.isSelected());
}
else {
chatWindow.enableTypingNotification(false);
}
}
}

Loading…
Cancel
Save