<commit_before>package de.uni_hildesheim.sse.qmApp.dialogs;

import java.io.File;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.eclipse.jface.dialogs.ProgressIndicator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

//this shall be the Activator.PLUGIN_ID but then the roles are away
import de.uni_hildesheim.sse.easy_producer.instantiator.Bundle;
import de.uni_hildesheim.sse.qmApp.images.IconManager;
import de.uni_hildesheim.sse.qmApp.model.Location;
import de.uni_hildesheim.sse.qmApp.model.Utils;
import de.uni_hildesheim.sse.qmApp.model.Utils.ConfigurationProperties;
import de.uni_hildesheim.sse.repositoryConnector.IRepositoryConnector;
import de.uni_hildesheim.sse.repositoryConnector.UserContext;
import de.uni_hildesheim.sse.repositoryConnector.roleFetcher.model.ApplicationRole;
import de.uni_hildesheim.sse.repositoryConnector.roleFetcher.model.Role;
import de.uni_hildesheim.sse.repositoryConnector.svnConnector.ConnectorException;
import de.uni_hildesheim.sse.repositoryConnector.svnConnector.RepositoryEventHandler;
import de.uni_hildesheim.sse.repositoryConnector.svnConnector.SVNConnector;
import de.uni_hildesheim.sse.utils.logger.EASyLoggerFactory;
import de.uni_hildesheim.sse.utils.logger.EASyLoggerFactory.EASyLogger;

/**
 * Login Dialog that pops up when the applications starts.
 * 
 * @author Sass
 */
public class LoginDialog {

    private static EASyLogger logger = EASyLoggerFactory.INSTANCE.getLogger(LoginDialog.class, Bundle.ID);
    private static IRepositoryConnector repositoryConnector = new SVNConnector();
    private static final boolean OFFLINE_DEBUG = false; // requires
                                                        // conf.properties
    private static final String EXCEPTION_TITLE = "Connector Exception";

    private Text password;
    private Text username;
    private Display display;
    private ProgressIndicator progress;

    private String localDataToolTip = "If this checkbox is selected you will be working with local data only."
            + "\n You will not be able to commit changes to the pipeline repository.";
    private String localDataUsedMessage = "Last time you used the application you worked with local data and you are "
            + "about to use the remote repository. This will lead to a synchronization of the configuration and "
            + "if you press 'No', local changes will be overridden with more recent settings from the repository. "
            + "Do you want to stay in local mode?";

    /**
     * Displays the login dialog.
     * 
     * @param display
     *            Display
     */
    public LoginDialog(Display display) {
        this.display = display;
    }

    /**
     * Creates the login pop up.
     */
    @SuppressWarnings("unused")
    public void createContents() {
        final Shell shell = new Shell(display);
        shell.setText("QualiMaster Infrastructure Configuration - Login");
        // Set the qualimaster-icon for the login-shell.
        Image icon = IconManager.retrieveImage(IconManager.QUALIMASTER_SMALL);
        shell.setImage(icon);
        shell.addListener(SWT.Close, new Listener() {
            public void handleEvent(Event event) {
                System.exit(0);
            }
        });
        final FillLayout fillLayout = new FillLayout();
        fillLayout.marginHeight = 1;
        shell.setLayout(fillLayout);
        // Create a composite with grid layout.
        final Composite composite = createGridLayout(shell);
        // Setting the background of the composite with the image background for
        // login dialog
        final Label imageLabel = createBackground(composite);
        // Creating the composite which will contain the login related widgets
        final Composite cmpLogin = new Composite(composite, SWT.NONE);
        final RowLayout rowLayout = new RowLayout();
        rowLayout.fill = true;
        rowLayout.type = SWT.VERTICAL;
        cmpLogin.setLayout(rowLayout);
        final GridData gridData = new GridData(GridData.FILL, GridData.FILL, false, false);
        cmpLogin.setLayoutData(gridData);
        // Label for the username
        final CLabel usernameLabel = createLabel(cmpLogin, "Username");
        // Textfield for the username
        username = createTextField(cmpLogin, false);
        // Label for the password
        final CLabel passwordLabel = createLabel(cmpLogin, "Password");
        // Textfield for the password
        password = createTextField(cmpLogin, true);
        final Button selectButton = createCheckBox(cmpLogin, "No login - local data");
        selectButton.setToolTipText(localDataToolTip);<commit_msg>If the username is stored in the preferences the textfield for the username in the login dialog will be filled automaticaly.<commit_after>package de.uni_hildesheim.sse.qmApp.dialogs;

import java.io.File;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.eclipse.jface.dialogs.ProgressIndicator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

//this shall be the Activator.PLUGIN_ID but then the roles are away
import de.uni_hildesheim.sse.easy_producer.instantiator.Bundle;
import de.uni_hildesheim.sse.qmApp.images.IconManager;
import de.uni_hildesheim.sse.qmApp.model.Location;
import de.uni_hildesheim.sse.qmApp.model.Utils;
import de.uni_hildesheim.sse.qmApp.model.Utils.ConfigurationProperties;
import de.uni_hildesheim.sse.repositoryConnector.IRepositoryConnector;
import de.uni_hildesheim.sse.repositoryConnector.UserContext;
import de.uni_hildesheim.sse.repositoryConnector.roleFetcher.model.ApplicationRole;
import de.uni_hildesheim.sse.repositoryConnector.roleFetcher.model.Role;
import de.uni_hildesheim.sse.repositoryConnector.svnConnector.ConnectorException;
import de.uni_hildesheim.sse.repositoryConnector.svnConnector.RepositoryEventHandler;
import de.uni_hildesheim.sse.repositoryConnector.svnConnector.SVNConnector;
import de.uni_hildesheim.sse.utils.logger.EASyLoggerFactory;
import de.uni_hildesheim.sse.utils.logger.EASyLoggerFactory.EASyLogger;

/**
 * Login Dialog that pops up when the applications starts.
 * 
 * @author Sass
 */
public class LoginDialog {

    private static EASyLogger logger = EASyLoggerFactory.INSTANCE.getLogger(LoginDialog.class, Bundle.ID);
    private static IRepositoryConnector repositoryConnector = new SVNConnector();
    private static final boolean OFFLINE_DEBUG = false; // requires
                                                        // conf.properties
    private static final String EXCEPTION_TITLE = "Connector Exception";

    private Text password;
    private Text username;
    private Display display;
    private ProgressIndicator progress;

    private String localDataToolTip = "If this checkbox is selected you will be working with local data only."
            + "\n You will not be able to commit changes to the pipeline repository.";
    private String localDataUsedMessage = "Last time you used the application you worked with local data and you are "
            + "about to use the remote repository. This will lead to a synchronization of the configuration and "
            + "if you press 'No', local changes will be overridden with more recent settings from the repository. "
            + "Do you want to stay in local mode?";

    /**
     * Displays the login dialog.
     * 
     * @param display
     *            Display
     */
    public LoginDialog(Display display) {
        this.display = display;
    }

    /**
     * Creates the login pop up.
     */
    @SuppressWarnings("unused")
    public void createContents() {
        final Shell shell = new Shell(display);
        shell.setText("QualiMaster Infrastructure Configuration - Login");
        // Set the qualimaster-icon for the login-shell.
        Image icon = IconManager.retrieveImage(IconManager.QUALIMASTER_SMALL);
        shell.setImage(icon);
        shell.addListener(SWT.Close, new Listener() {
            public void handleEvent(Event event) {
                System.exit(0);
            }
        });
        final FillLayout fillLayout = new FillLayout();
        fillLayout.marginHeight = 1;
        shell.setLayout(fillLayout);
        // Create a composite with grid layout.
        final Composite composite = createGridLayout(shell);
        // Setting the background of the composite with the image background for
        // login dialog
        final Label imageLabel = createBackground(composite);
        // Creating the composite which will contain the login related widgets
        final Composite cmpLogin = new Composite(composite, SWT.NONE);
        final RowLayout rowLayout = new RowLayout();
        rowLayout.fill = true;
        rowLayout.type = SWT.VERTICAL;
        cmpLogin.setLayout(rowLayout);
        final GridData gridData = new GridData(GridData.FILL, GridData.FILL, false, false);
        cmpLogin.setLayoutData(gridData);
        // Label for the username
        final CLabel usernameLabel = createLabel(cmpLogin, "Username");
        // Textfield for the username
        username = createTextField(cmpLogin, false);
        String user = EclipsePrefUtils.INSTANCE.getPreference(EclipsePrefUtils.USERNAME_PREF_KEY);
        if (null != user) {
            username.setText(user);
        }
        // Label for the password
        final CLabel passwordLabel = createLabel(cmpLogin, "Password");
        // Textfield for the password
        password = createTextField(cmpLogin, true);
        final Button selectButton = createCheckBox(cmpLogin, "No login - local data");
        selectButton.setToolTipText(localDataToolTip);
{'fraction_non_alphanumeric': 0.08490396697181835, 'fraction_numerical': 0.0003590019745108598, 'mean_word_length': 3.3991314646664033, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7592900', 'n_tokens_mistral': 3130, 'n_tokens_neox': 3117, 'n_words': 804}