<commit_before>/*
 * CODENVY CONFIDENTIAL
 * ________________
 * 
 * [2012] - [2014] Codenvy, S.A.
 * All Rights Reserved.
 * NOTICE: All information contained herein is, and remains
 * the property of Codenvy S.A. and its suppliers,
 * if any. The intellectual and technical concepts contained
 * herein are proprietary to Codenvy S.A.
 * and its suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Codenvy S.A..
 */
package com.codenvy.eclipse.ui.test;

import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic;
import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive;

import java.util.ArrayList;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.junit.After;

/**
 * SWTBot base test class.
 * 
 * @author <NAME>
 */
public class SWTBotBaseTest {
    public static final SWTWorkbenchBot bot = new SWTWorkbenchBot();

    public SWTBotBaseTest() {
        final IEclipsePreferences resourcesPreferences = InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES);
        resourcesPreferences.putBoolean(ResourcesPlugin.PREF_AUTO_BUILDING, false);
        resourcesPreferences.putBoolean(ResourcesPlugin.PREF_AUTO_REFRESH, false);
    }

    @SuppressWarnings("unchecked")
    @After
    public void clearWorkspace() throws Exception {
        openNavigatorView();

        final SWTBotView navigatorView = bot.viewByTitle("Navigator");
        navigatorView.setFocus();

        final SWTBotTree tree = navigatorView.bot().tree();

        ArrayList<String> projectsToDelete = new ArrayList<>();
        for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
            if ("RemoteSystemsTempFiles".equals(project.getName())) {
                continue;
            }
            projectsToDelete.add(project.getName());
        }
        if (!projectsToDelete.isEmpty()) {
            tree.select(projectsToDelete.toArray(new String[projectsToDelete.size()]));

            bot.menu("Edit").menu("Delete").click();

            // the project deletion confirmation dialog
            bot.waitUntilWidgetAppears(shellIsActive("Delete Resources"));
            SWTBotShell shell = bot.shell("Delete Resources");
            bot.checkBox("Delete project contents on disk (cannot be undone)").select();
            bot.button("OK").click();
            try {
                bot.waitUntilWidgetAppears(Conditions.waitForWidget(allOf(widgetOfType(Button.class), withMnemonic("Continue"))));
                bot.button("Continue").click();
            } catch (WidgetNotFoundException e) {
                // Nothing to do, no confirmation page, just go on.
            }
            bot.waitUntil(Conditions.shellCloses(shell));
        }
    }

    public void focusMainWindow() {
        bot.shell("Resource - Eclipse Platform").activate();
    }

    public SWTBotShell openAuthenticationWizardPage() {
        focusMainWindow();

        bot.menu("File")
           .menu("Import...")
           .click();

        final SWTBotShell shell = bot.shell("Import");
        shell.activate();

        shell.bot()
             .tree()
             .expandNode("Codenvy")
             .select("Existing Codenvy Projects");

        shell.bot()
             .button("Next >")
             .click();

        return shell;
    }<commit_msg>Close #72 Last desperate attempt<commit_after>/*
 * CODENVY CONFIDENTIAL
 * ________________
 * 
 * [2012] - [2014] Codenvy, S.A.
 * All Rights Reserved.
 * NOTICE: All information contained herein is, and remains
 * the property of Codenvy S.A. and its suppliers,
 * if any. The intellectual and technical concepts contained
 * herein are proprietary to Codenvy S.A.
 * and its suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Codenvy S.A..
 */
package com.codenvy.eclipse.ui.test;

import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic;
import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive;

import java.util.ArrayList;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.junit.After;

/**
 * SWTBot base test class.
 * 
 * @author <NAME>
 */
public class SWTBotBaseTest {
    public static final SWTWorkbenchBot bot = new SWTWorkbenchBot();

    public SWTBotBaseTest() {
        final IEclipsePreferences resourcesPreferences = InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES);
        resourcesPreferences.putBoolean(ResourcesPlugin.PREF_AUTO_BUILDING, false);
        resourcesPreferences.putBoolean(ResourcesPlugin.PREF_AUTO_REFRESH, false);
    }

    @SuppressWarnings("unchecked")
    @After
    public void clearWorkspace() throws Exception {
        openNavigatorView();

        final SWTBotView navigatorView = bot.viewByTitle("Navigator");
        navigatorView.setFocus();

        final SWTBotTree tree = navigatorView.bot().tree();

        ArrayList<String> projectsToDelete = new ArrayList<>();
        for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
            if ("RemoteSystemsTempFiles".equals(project.getName())) {
                continue;
            }
            projectsToDelete.add(project.getName());
        }
        if (!projectsToDelete.isEmpty()) {
            tree.select(projectsToDelete.toArray(new String[projectsToDelete.size()]));

            bot.menu("Edit").menu("Delete").click();

            // the project deletion confirmation dialog
            bot.waitUntilWidgetAppears(shellIsActive("Delete Resources"));
            SWTBotShell shell = bot.shell("Delete Resources");
            bot.checkBox("Delete project contents on disk (cannot be undone)").select();
            bot.button("OK").click();
            try {
                bot.waitUntilWidgetAppears(Conditions.waitForWidget(allOf(widgetOfType(Button.class), withMnemonic("Continue"))));
                bot.button("Continue").click();
            } catch (WidgetNotFoundException e) {
                // Nothing to do, no confirmation page, just go on.
            }
            bot.waitUntil(Conditions.shellCloses(shell));
        }
    }

    public void focusMainWindow() {
        SWTBotShell mainWindow = bot.shell("Resource - ");
        mainWindow.activate();
    }

    public SWTBotShell openAuthenticationWizardPage() {
        focusMainWindow();

        bot.menu("File")
           .menu("Import...")
           .click();

        final SWTBotShell shell = bot.shell("Import");
        shell.activate();

        shell.bot()
             .tree()
             .expandNode("Codenvy")
             .select("Existing Codenvy Projects");

        shell.bot()
             .button("Next >")
             .click();

        return shell;
    }
{'fraction_non_alphanumeric': 0.10865213523131673, 'fraction_numerical': 0.002001779359430605, 'mean_word_length': 3.1984126984126986, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '423822', 'n_tokens_mistral': 2574, 'n_tokens_neox': 2480, 'n_words': 521}