<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.login;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.protocol.*;
/**
 * The <tt>LoginWindow</tt> is the window where the user should type his
 * user identifier and password to login.
 *
 * @author <NAME>
 */
public class AuthenticationWindow
    extends SIPCommDialog
    implements ActionListener
{

    private JTextArea realmTextArea = new JTextArea();

    private JLabel uinLabel = new JLabel(
        Messages.getI18NString("uin").getText());

    private JLabel passwdLabel = new JLabel(
        Messages.getI18NString("passwd").getText());

    private JLabel uinValueLabel;

    private JPasswordField passwdField = new JPasswordField(15);

    private I18NString okString = Messages.getI18NString("ok");
    
    private I18NString cancelString = Messages.getI18NString("cancel");
    
    private JButton loginButton = new JButton(okString.getText());

    private JButton cancelButton = new JButton(cancelString.getText());

    private JPanel labelsPanel = new JPanel(new GridLayout(0, 1, 8, 8));

    private JPanel textFieldsPanel = new JPanel(new GridLayout(0, 1, 8, 8));

    private JPanel mainPanel = new JPanel(new BorderLayout(10, 10));

    private JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

    private JCheckBox rememberPassCheckBox
        = new JCheckBox(Messages.getI18NString("rememberPassword").getText());

    private LoginWindowBackground backgroundPanel;

    private UserCredentials userCredentials;

    private String realm;

    /**
     * Creates an instance of the <tt>LoginWindow</tt>.
     * @param mainFrame the parent <tt>MainFrame</tt> window.
     * @param protocolProvider the protocol provider.
     * @param realm the realm
     * @param userCredentials the user credentials
     */
    public AuthenticationWindow(MainFrame mainFrame,
                ProtocolProviderService protocolProvider,
                String realm,
                UserCredentials userCredentials) {

        super(mainFrame);

        this.userCredentials = userCredentials;

        this.realm = realm;

        this.setModal(true);

        backgroundPanel = new LoginWindowBackground(
                Constants.getProtocolBigIcon(
                        protocolProvider.getProtocolName()));

        this.backgroundPanel.setPreferredSize(new Dimension(420, 230));
        
        this.backgroundPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

        this.backgroundPanel.setBorder(
                BorderFactory.createEmptyBorder(20, 5, 5, 5));
        
        this.getContentPane().setLayout(new BorderLayout());

        this.init();

        this.getContentPane().add(backgroundPanel, BorderLayout.CENTER);
        
        this.setResizable(false);

        this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

        this.setTitle(
            Messages.getI18NString("authenticationWindowTitle").getText());

        this.enableKeyActions();
    }

    /**
     * Constructs the <tt>LoginWindow</tt>.
     */
    private void init() {

        this.uinValueLabel = new JLabel(userCredentials.getUserName());
        if(userCredentials.getPassword() != null) {
            this.passwdField.setText(userCredentials.getPassword().toString());
        }

        this.realmTextArea.setOpaque(false);
        this.realmTextArea.setLineWrap(true);
        this.realmTextArea.setWrapStyleWord(true);
        this.realmTextArea.setFont(Constants.FONT.deriveFont(Font.BOLD, 12f));
        this.realmTextArea.setEditable(false);
        this.realmTextArea.setText(
            Messages.getI18NString("securityAuthorityRealm", this.realm)
                .getText());

        this.uinLabel.setFont(Constants.FONT.deriveFont(Font.BOLD));
        this.passwdLabel.setFont(Constants.FONT.deriveFont(Font.BOLD));

        this.labelsPanel.add(uinLabel);
        this.labelsPanel.add(passwdLabel);
        this.labelsPanel.add(new JLabel());

        this.rememberPassCheckBox.setOpaque(false);
        
        this.textFieldsPanel.add(uinValueLabel);
        this.textFieldsPanel.add(passwdField);
        this.textFieldsPanel.add(rememberPassCheckBox);

        this.buttonsPanel.add(loginButton);
        this.buttonsPanel.add(cancelButton);

        this.mainPanel.add(realmTextArea, BorderLayout.NORTH);
        this.mainPanel.add(labelsPanel, BorderLayout.WEST);
        this.mainPanel.add(textFieldsPanel, BorderLayout.CENTER);
        this.mainPanel.add(buttonsPanel, BorderLayout.SOUTH);

        this.backgroundPanel.add(mainPanel, BorderLayout.CENTER);

        this.loginButton.setName("ok");
        this.cancelButton.setName("cancel");

        this.loginButton.addActionListener(this);
        this.cancelButton.addActionListener(this);

        this.getRootPane().setDefaultButton(loginButton);

        this.setTransparent(true);
    }

    /**
     * Sets transparent background to all components in the login window,
     * because of the nonwhite background.
     * @param transparent <code>true</code> to set a transparent background,
     * <code>false</code> otherwise.
     */
    private void setTransparent(boolean transparent) {
        this.mainPanel.setOpaque(!transparent);<commit_msg>mnemonics in the Authentication window<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.login;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.protocol.*;
/**
 * The <tt>LoginWindow</tt> is the window where the user should type his
 * user identifier and password to login.
 *
 * @author <NAME>
 */
public class AuthenticationWindow
    extends SIPCommDialog
    implements ActionListener
{

    private JTextArea realmTextArea = new JTextArea();

    private JLabel uinLabel = new JLabel(
        Messages.getI18NString("uin").getText());

    private JLabel passwdLabel = new JLabel(
        Messages.getI18NString("passwd").getText());

    private JLabel uinValueLabel;

    private JPasswordField passwdField = new JPasswordField(15);

    private I18NString okString = Messages.getI18NString("ok");
    
    private I18NString cancelString = Messages.getI18NString("cancel");
    
    private JButton loginButton = new JButton(okString.getText());

    private JButton cancelButton = new JButton(cancelString.getText());

    private JPanel labelsPanel = new JPanel(new GridLayout(0, 1, 8, 8));

    private JPanel textFieldsPanel = new JPanel(new GridLayout(0, 1, 8, 8));

    private JPanel mainPanel = new JPanel(new BorderLayout(10, 10));

    private JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

    private JCheckBox rememberPassCheckBox
        = new JCheckBox(Messages.getI18NString("rememberPassword").getText());

    private LoginWindowBackground backgroundPanel;

    private UserCredentials userCredentials;

    private String realm;

    /**
     * Creates an instance of the <tt>LoginWindow</tt>.
     * @param mainFrame the parent <tt>MainFrame</tt> window.
     * @param protocolProvider the protocol provider.
     * @param realm the realm
     * @param userCredentials the user credentials
     */
    public AuthenticationWindow(MainFrame mainFrame,
                ProtocolProviderService protocolProvider,
                String realm,
                UserCredentials userCredentials) {

        super(mainFrame);

        this.userCredentials = userCredentials;

        this.realm = realm;

        this.setModal(true);

        backgroundPanel = new LoginWindowBackground(
                Constants.getProtocolBigIcon(
                        protocolProvider.getProtocolName()));

        this.backgroundPanel.setPreferredSize(new Dimension(420, 230));
        
        this.backgroundPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

        this.backgroundPanel.setBorder(
                BorderFactory.createEmptyBorder(20, 5, 5, 5));
        
        this.getContentPane().setLayout(new BorderLayout());

        this.init();

        this.getContentPane().add(backgroundPanel, BorderLayout.CENTER);
        
        this.setResizable(false);

        this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

        this.setTitle(
            Messages.getI18NString("authenticationWindowTitle").getText());

        this.enableKeyActions();
    }

    /**
     * Constructs the <tt>LoginWindow</tt>.
     */
    private void init() {

        this.uinValueLabel = new JLabel(userCredentials.getUserName());
        if(userCredentials.getPassword() != null) {
            this.passwdField.setText(userCredentials.getPassword().toString());
        }

        this.realmTextArea.setOpaque(false);
        this.realmTextArea.setLineWrap(true);
        this.realmTextArea.setWrapStyleWord(true);
        this.realmTextArea.setFont(Constants.FONT.deriveFont(Font.BOLD, 12f));
        this.realmTextArea.setEditable(false);
        this.realmTextArea.setText(
            Messages.getI18NString("securityAuthorityRealm", this.realm)
                .getText());

        this.uinLabel.setFont(Constants.FONT.deriveFont(Font.BOLD));
        this.passwdLabel.setFont(Constants.FONT.deriveFont(Font.BOLD));

        this.labelsPanel.add(uinLabel);
        this.labelsPanel.add(passwdLabel);
        this.labelsPanel.add(new JLabel());

        this.rememberPassCheckBox.setOpaque(false);
        
        this.textFieldsPanel.add(uinValueLabel);
        this.textFieldsPanel.add(passwdField);
        this.textFieldsPanel.add(rememberPassCheckBox);

        this.buttonsPanel.add(loginButton);
        this.buttonsPanel.add(cancelButton);

        this.mainPanel.add(realmTextArea, BorderLayout.NORTH);
        this.mainPanel.add(labelsPanel, BorderLayout.WEST);
        this.mainPanel.add(textFieldsPanel, BorderLayout.CENTER);
        this.mainPanel.add(buttonsPanel, BorderLayout.SOUTH);

        this.backgroundPanel.add(mainPanel, BorderLayout.CENTER);

        this.loginButton.setName("ok");
        this.cancelButton.setName("cancel");
        
        this.loginButton.setMnemonic(okString.getMnemonic());
        this.cancelButton.setMnemonic(cancelString.getMnemonic());

        this.loginButton.addActionListener(this);
        this.cancelButton.addActionListener(this);

        this.getRootPane().setDefaultButton(loginButton);

        this.setTransparent(true);
    }

    /**
     * Sets transparent background to all components in the login window,
     * because of the nonwhite background.
     * @param transparent <code>true</code> to set a transparent background,
     * <code>false</code> otherwise.
     */
    private void setTransparent(boolean transparent) {
        this.mainPanel.setOpaque(!transparent);
{'fraction_non_alphanumeric': 0.10548266573985576, 'fraction_numerical': 0.008167521070466591, 'mean_word_length': 3.1313711414213925, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '3753350', 'n_tokens_mistral': 3380, 'n_tokens_neox': 3179, 'n_words': 603}