<commit_before>/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package net.java.sip.communicator.impl.gui.main.message;

import java.awt.BorderLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Hashtable;

import javax.swing.AbstractAction;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;

import net.java.sip.communicator.impl.gui.GuiActivator;
import net.java.sip.communicator.impl.gui.customcontrols.SIPCommMsgTextArea;
import net.java.sip.communicator.impl.gui.customcontrols.SIPCommTabbedPane;
import net.java.sip.communicator.impl.gui.customcontrols.events.CloseListener;
import net.java.sip.communicator.impl.gui.i18n.Messages;
import net.java.sip.communicator.impl.gui.main.MainFrame;
import net.java.sip.communicator.impl.gui.utils.Constants;
import net.java.sip.communicator.impl.gui.utils.ImageLoader;
import net.java.sip.communicator.service.configuration.ConfigurationService;
import net.java.sip.communicator.service.configuration.PropertyVetoException;
import net.java.sip.communicator.service.contactlist.MetaContact;
import net.java.sip.communicator.service.protocol.Contact;
import net.java.sip.communicator.service.protocol.PresenceStatus;
import net.java.sip.communicator.util.Logger;

/**
 * The chat window is the place, where users can write and send messages, view
 * received messages. The ChatWindow supports two modes of use: "Group all
 * messages in one window" and "Open messages in new window". In the first case
 * a <tt>JTabbedPane</tt> is added in the window, where each tab contains a
 * <tt>ChatPanel</tt>. In the second case the <tt>ChatPanel</tt> is added
 * directly to the window. The <tt>ChatPanel</tt> contains all chat elements
 * like a "write message area", "send" button, etc. It corresponds to a
 * <tt>MetaContact</tt> or to a conference.
 * <p>
 * Note that the conference case is not yet implemented.
 * 
 * @author <NAME>
 */
public class ChatWindow extends JFrame {

    private Logger logger = Logger.getLogger(ChatWindow.class.getName());
    
    private ChatPanel currentChatPanel;

    private MenusPanel menusPanel;

    private MainFrame mainFrame;

    private String windowTitle = "";

    private SIPCommTabbedPane chatTabbedPane = null;

    private Hashtable contactChats = new Hashtable();

    private boolean enableTypingNotification = true;
    
    /**
     * Creates an instance of <tt>ChatWindow</tt>.
     * 
     * @param mainFrame The parent MainFrame.
     */
    public ChatWindow(MainFrame mainFrame) {

        this.mainFrame = mainFrame;

        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        
        this.setSize(550, 450);

        this.setIconImage(ImageLoader.getImage(ImageLoader.SIP_LOGO));

        menusPanel = new MenusPanel(this);

        this.setSizeAndLocation();
        
        this.init();
        
        getRootPane().getActionMap()
                .put("close", new CloseAction());
        getRootPane().getActionMap()
                .put("changeTabForword", new ForwordTabAction());
        getRootPane().getActionMap()
                .put("changeTabBackword", new BackwordTabAction());
        getRootPane().getActionMap()
                .put("sendMessage", new SendMessageAction());
        getRootPane().getActionMap()
                .put("openSmilies", new OpenSmileyAction());
        getRootPane().getActionMap()
                .put("changeProtocol", new ChangeProtocolAction());
        
        getRootPane().getActionMap().put("copy", new CopyAction());
        getRootPane().getActionMap().put("paste", new PasteAction());
        
        InputMap imap = this.getRootPane().getInputMap(
                JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
                KeyEvent.ALT_DOWN_MASK), "changeTabForword");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,
                KeyEvent.ALT_DOWN_MASK), "changeTabBackword");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT,
                KeyEvent.CTRL_DOWN_MASK), "copy");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT,
                KeyEvent.SHIFT_DOWN_MASK), "paste");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
                KeyEvent.CTRL_DOWN_MASK), "sendMessage");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_S,
                KeyEvent.ALT_DOWN_MASK), "openSmilies");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_P,
                KeyEvent.ALT_DOWN_MASK), "changeProtocol");
        
        this.addWindowListener(new ChatWindowAdapter());       
    }

    /**
     * Initializes this window, by adding the menus.
     */
    public void init() {
        this.getContentPane().add(menusPanel, BorderLayout.NORTH);
    }
<commit_msg>apple+c, apple+v key combinations for mac<commit_after>/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package net.java.sip.communicator.impl.gui.main.message;

import java.awt.BorderLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Hashtable;

import javax.swing.AbstractAction;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;

import net.java.sip.communicator.impl.gui.GuiActivator;
import net.java.sip.communicator.impl.gui.customcontrols.SIPCommMsgTextArea;
import net.java.sip.communicator.impl.gui.customcontrols.SIPCommTabbedPane;
import net.java.sip.communicator.impl.gui.customcontrols.events.CloseListener;
import net.java.sip.communicator.impl.gui.i18n.Messages;
import net.java.sip.communicator.impl.gui.main.MainFrame;
import net.java.sip.communicator.impl.gui.utils.Constants;
import net.java.sip.communicator.impl.gui.utils.ImageLoader;
import net.java.sip.communicator.service.configuration.ConfigurationService;
import net.java.sip.communicator.service.configuration.PropertyVetoException;
import net.java.sip.communicator.service.contactlist.MetaContact;
import net.java.sip.communicator.service.protocol.Contact;
import net.java.sip.communicator.service.protocol.PresenceStatus;
import net.java.sip.communicator.util.Logger;

/**
 * The chat window is the place, where users can write and send messages, view
 * received messages. The ChatWindow supports two modes of use: "Group all
 * messages in one window" and "Open messages in new window". In the first case
 * a <tt>JTabbedPane</tt> is added in the window, where each tab contains a
 * <tt>ChatPanel</tt>. In the second case the <tt>ChatPanel</tt> is added
 * directly to the window. The <tt>ChatPanel</tt> contains all chat elements
 * like a "write message area", "send" button, etc. It corresponds to a
 * <tt>MetaContact</tt> or to a conference.
 * <p>
 * Note that the conference case is not yet implemented.
 * 
 * @author <NAME>
 */
public class ChatWindow extends JFrame {

    private Logger logger = Logger.getLogger(ChatWindow.class.getName());
    
    private ChatPanel currentChatPanel;

    private MenusPanel menusPanel;

    private MainFrame mainFrame;

    private String windowTitle = "";

    private SIPCommTabbedPane chatTabbedPane = null;

    private Hashtable contactChats = new Hashtable();

    private boolean enableTypingNotification = true;
    
    /**
     * Creates an instance of <tt>ChatWindow</tt>.
     * 
     * @param mainFrame The parent MainFrame.
     */
    public ChatWindow(MainFrame mainFrame) {

        this.mainFrame = mainFrame;

        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        
        this.setSize(550, 450);

        this.setIconImage(ImageLoader.getImage(ImageLoader.SIP_LOGO));

        menusPanel = new MenusPanel(this);

        this.setSizeAndLocation();
        
        this.init();
        
        getRootPane().getActionMap()
                .put("close", new CloseAction());
        getRootPane().getActionMap()
                .put("changeTabForword", new ForwordTabAction());
        getRootPane().getActionMap()
                .put("changeTabBackword", new BackwordTabAction());
        getRootPane().getActionMap()
                .put("sendMessage", new SendMessageAction());
        getRootPane().getActionMap()
                .put("openSmilies", new OpenSmileyAction());
        getRootPane().getActionMap()
                .put("changeProtocol", new ChangeProtocolAction());
        
        getRootPane().getActionMap().put("copy", new CopyAction());
        getRootPane().getActionMap().put("paste", new PasteAction());
        
        InputMap imap = this.getRootPane().getInputMap(
                JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
                KeyEvent.ALT_DOWN_MASK), "changeTabForword");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,
                KeyEvent.ALT_DOWN_MASK), "changeTabBackword");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT,
                KeyEvent.CTRL_DOWN_MASK), "copy");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT,
                KeyEvent.SHIFT_DOWN_MASK), "paste");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C,
                KeyEvent.META_MASK), "copy");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V,
                KeyEvent.META_MASK), "paste");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
                KeyEvent.CTRL_DOWN_MASK), "sendMessage");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_S,
                KeyEvent.ALT_DOWN_MASK), "openSmilies");
        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_P,
                KeyEvent.ALT_DOWN_MASK), "changeProtocol");
        
        this.addWindowListener(new ChatWindowAdapter());       
    }

    /**
     * Initializes this window, by adding the menus.
     */
    public void init() {
        this.getContentPane().add(menusPanel, BorderLayout.NORTH);
    }

{'fraction_non_alphanumeric': 0.11012153260970406, 'fraction_numerical': 0.0016699137211244085, 'mean_word_length': 3.332797427652733, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5044779', 'n_tokens_mistral': 3346, 'n_tokens_neox': 3232, 'n_words': 635}