<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.plugin.facebookaccregwizz;

import java.awt.*;

import javax.swing.*;
import javax.swing.event.*;

import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.swing.*;

/**
 * The <tt>FirstWizardPage</tt> is the page, where user could enter the username
 * and the password of the account.
 *
 * @author <NAME>
 * @author <NAME>
 */
public class FirstWizardPage
    extends TransparentPanel
    implements WizardPage,
               DocumentListener
{
    public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier";

    public static final String USER_NAME_EXAMPLE = "Ex: username";
    
    private JPanel userPassPanel
        = new TransparentPanel(new BorderLayout(10, 10));

    private JLabel usernameLabel
        = new JLabel(Resources.getString("plugin.facebookaccregwizz.USERNAME"));

    private JLabel passLabel
        = new JLabel(Resources.getString("service.gui.PASSWORD"));

    private JLabel existingAccountLabel
        = new JLabel(Resources.getString("service.gui.EXISTING_ACCOUNT_ERROR"));

    private JPanel emptyPanel = new TransparentPanel();

    private JLabel usernameExampleLabel = new JLabel(USER_NAME_EXAMPLE);

    private JTextField usernameField = new TrimTextField();

    private JPasswordField passField = new JPasswordField();

    private JCheckBox rememberPassBox
        = new JCheckBox(Resources.getString("service.gui.REMEMBER_PASSWORD"));

    private JPanel mainPanel = new TransparentPanel();

    private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;

    private FacebookAccountRegistrationWizard wizard;
    
    private boolean isCommitted = false;

    /**
     * Creates an instance of <tt>FirstWizardPage</tt>.
     * @param wizard the parent wizard
     */
    public FirstWizardPage(FacebookAccountRegistrationWizard wizard)
    {
        super(new BorderLayout());

        this.wizard = wizard;

        mainPanel.setLayout(new BorderLayout());

        this.init();

        this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    }

    /**
     * Initializes all panels, buttons, etc.
     */
    private void init()
    {
        this.usernameField.getDocument().addDocumentListener(this);
        this.rememberPassBox.setSelected(true);
        this.rememberPassBox.setOpaque(false);

        this.existingAccountLabel.setForeground(Color.RED);

        this.usernameExampleLabel.setForeground(Color.GRAY);
        this.usernameExampleLabel.setFont(
                usernameExampleLabel.getFont().deriveFont(8));
        this.emptyPanel.setMaximumSize(new Dimension(40, 35));
        this.usernameExampleLabel.setBorder(
                BorderFactory.createEmptyBorder(0, 0, 8,0));

        JPanel labelsPanel = new TransparentPanel();
        labelsPanel.setLayout(new BoxLayout(labelsPanel, BoxLayout.Y_AXIS));
        labelsPanel.add(usernameLabel);
        labelsPanel.add(emptyPanel);
        labelsPanel.add(passLabel);

        JPanel valuesPanel = new TransparentPanel();
        valuesPanel.setLayout(new BoxLayout(valuesPanel, BoxLayout.Y_AXIS));
        valuesPanel.add(usernameField);
        valuesPanel.add(usernameExampleLabel);
        valuesPanel.add(passField);

        JPanel descriptionPanel = new TransparentPanel(new BorderLayout());
        descriptionPanel.setBorder(
            BorderFactory.createEmptyBorder(10, 10, 10, 10));

        JEditorPane descriptionValue = new JEditorPane();
        descriptionValue.setAlignmentX(JEditorPane.CENTER_ALIGNMENT);
        descriptionValue.setOpaque(false);
        descriptionValue.setContentType("text/html");
        descriptionValue.setEditable(false);
        descriptionValue.setText(
            Resources.getString(
                "plugin.facebookaccregwizz.DESCRIPTION"));
        descriptionValue.addHyperlinkListener(new HyperlinkListener()
            {
                public void hyperlinkUpdate(HyperlinkEvent e)
                {
                    if (e.getEventType()
                            .equals(HyperlinkEvent.EventType.ACTIVATED))
                    {
                        FacebookAccRegWizzActivator
                            .getBrowserLauncher().openURL(e.getURL().toString());
                    }
                }
            });
        descriptionPanel.add(descriptionValue, BorderLayout.CENTER);

        userPassPanel.add(labelsPanel, BorderLayout.WEST);
        userPassPanel.add(valuesPanel, BorderLayout.CENTER);
        userPassPanel.add(rememberPassBox, BorderLayout.SOUTH);

        userPassPanel.setBorder(
            BorderFactory.createTitledBorder(
                Resources.getString(
                    "plugin.facebookaccregwizz.USERNAME_AND_PASSWORD")));

        mainPanel.add(userPassPanel, BorderLayout.CENTER);<commit_msg>Re: issue JITSI-924 "Bulgarian fb wizard is very wide on Windows", fixes the fb account wizard to use the font used elsewhere in the UI.<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.plugin.facebookaccregwizz;

import java.awt.*;

import javax.swing.*;
import javax.swing.event.*;

import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.swing.*;

/**
 * The <tt>FirstWizardPage</tt> is the page, where user could enter the username
 * and the password of the account.
 *
 * @author <NAME>
 * @author <NAME>
 */
public class FirstWizardPage
    extends TransparentPanel
    implements WizardPage,
               DocumentListener
{
    public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier";

    public static final String USER_NAME_EXAMPLE = "Ex: username";
    
    private JPanel userPassPanel
        = new TransparentPanel(new BorderLayout(10, 10));

    private JLabel usernameLabel
        = new JLabel(Resources.getString("plugin.facebookaccregwizz.USERNAME"));

    private JLabel passLabel
        = new JLabel(Resources.getString("service.gui.PASSWORD"));

    private JLabel existingAccountLabel
        = new JLabel(Resources.getString("service.gui.EXISTING_ACCOUNT_ERROR"));

    private JPanel emptyPanel = new TransparentPanel();

    private JLabel usernameExampleLabel = new JLabel(USER_NAME_EXAMPLE);

    private JTextField usernameField = new TrimTextField();

    private JPasswordField passField = new JPasswordField();

    private JCheckBox rememberPassBox
        = new JCheckBox(Resources.getString("service.gui.REMEMBER_PASSWORD"));

    private JPanel mainPanel = new TransparentPanel();

    private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;

    private FacebookAccountRegistrationWizard wizard;
    
    private boolean isCommitted = false;

    /**
     * Creates an instance of <tt>FirstWizardPage</tt>.
     * @param wizard the parent wizard
     */
    public FirstWizardPage(FacebookAccountRegistrationWizard wizard)
    {
        super(new BorderLayout());

        this.wizard = wizard;

        mainPanel.setLayout(new BorderLayout());

        this.init();

        this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    }

    /**
     * Initializes all panels, buttons, etc.
     */
    private void init()
    {
        this.usernameField.getDocument().addDocumentListener(this);
        this.rememberPassBox.setSelected(true);
        this.rememberPassBox.setOpaque(false);

        this.existingAccountLabel.setForeground(Color.RED);

        this.usernameExampleLabel.setForeground(Color.GRAY);
        this.usernameExampleLabel.setFont(
                usernameExampleLabel.getFont().deriveFont(8));
        this.emptyPanel.setMaximumSize(new Dimension(40, 35));
        this.usernameExampleLabel.setBorder(
                BorderFactory.createEmptyBorder(0, 0, 8,0));

        JPanel labelsPanel = new TransparentPanel();
        labelsPanel.setLayout(new BoxLayout(labelsPanel, BoxLayout.Y_AXIS));
        labelsPanel.add(usernameLabel);
        labelsPanel.add(emptyPanel);
        labelsPanel.add(passLabel);

        JPanel valuesPanel = new TransparentPanel();
        valuesPanel.setLayout(new BoxLayout(valuesPanel, BoxLayout.Y_AXIS));
        valuesPanel.add(usernameField);
        valuesPanel.add(usernameExampleLabel);
        valuesPanel.add(passField);

        JPanel descriptionPanel = new TransparentPanel(new BorderLayout());
        descriptionPanel.setBorder(
            BorderFactory.createEmptyBorder(10, 10, 10, 10));

        JEditorPane descriptionValue = new JEditorPane();
        descriptionValue.setAlignmentX(JEditorPane.CENTER_ALIGNMENT);
        descriptionValue.setOpaque(false);
        descriptionValue.setContentType("text/html");
        descriptionValue.setEditable(false);
        descriptionValue.setText(
            Resources.getString(
                "plugin.facebookaccregwizz.DESCRIPTION"));
        /* Display the description with the font we use elsewhere in the UI. */
        descriptionValue.putClientProperty(
                JEditorPane.HONOR_DISPLAY_PROPERTIES,
                true);
        descriptionValue.addHyperlinkListener(new HyperlinkListener()
            {
                public void hyperlinkUpdate(HyperlinkEvent e)
                {
                    if (e.getEventType()
                            .equals(HyperlinkEvent.EventType.ACTIVATED))
                    {
                        FacebookAccRegWizzActivator
                            .getBrowserLauncher().openURL(e.getURL().toString());
                    }
                }
            });
        descriptionPanel.add(descriptionValue, BorderLayout.CENTER);

        userPassPanel.add(labelsPanel, BorderLayout.WEST);
        userPassPanel.add(valuesPanel, BorderLayout.CENTER);
        userPassPanel.add(rememberPassBox, BorderLayout.SOUTH);

        userPassPanel.setBorder(
            BorderFactory.createTitledBorder(
                Resources.getString(
                    "plugin.facebookaccregwizz.USERNAME_AND_PASSWORD")));

        mainPanel.add(userPassPanel, BorderLayout.CENTER);
{'fraction_non_alphanumeric': 0.09133601686793176, 'fraction_numerical': 0.005846271803718613, 'mean_word_length': 2.880624767571588, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7662873', 'n_tokens_mistral': 2906, 'n_tokens_neox': 2706, 'n_words': 542}