<commit_before>/*******************************************************************************
 * Copyright (c) 2012-2016 <NAME>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   <NAME>. - initial API and implementation
 *******************************************************************************/
package org.eclipse.che.plugin.svn.ide.resolve;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.inject.Inject;

import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.app.CurrentProject;
import org.eclipse.che.ide.api.notification.NotificationManager;
import org.eclipse.che.ide.extension.machine.client.processes.ConsolesPanelPresenter;
import org.eclipse.che.ide.part.explorer.project.ProjectExplorerPresenter;
import org.eclipse.che.ide.api.dialogs.ConfirmCallback;
import org.eclipse.che.ide.api.dialogs.DialogFactory;
import org.eclipse.che.plugin.svn.ide.SubversionClientService;
import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants;
import org.eclipse.che.plugin.svn.ide.common.StatusColors;
import org.eclipse.che.plugin.svn.ide.common.SubversionActionPresenter;
import org.eclipse.che.plugin.svn.ide.common.SubversionOutputConsoleFactory;
import org.eclipse.che.plugin.svn.shared.CLIOutputResponse;
import org.eclipse.che.plugin.svn.shared.CLIOutputResponseList;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE;
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL;

public class ResolvePresenter extends SubversionActionPresenter implements ResolveView.ActionDelegate {

    private final NotificationManager                      notificationManager;
    private final DialogFactory                            dialogFactory;
    private final SubversionExtensionLocalizationConstants constants;
    private final SubversionClientService                  subversionClientService;
    private final ResolveView                              view;

    private List<String> conflictsPaths;

    @Inject
    protected ResolvePresenter(final ConsolesPanelPresenter consolesPanelPresenter,
                               final SubversionOutputConsoleFactory consoleFactory,
                               final AppContext appContext,
                               final SubversionExtensionLocalizationConstants constants,
                               final NotificationManager notificationManager,
                               final DialogFactory dialogFactory,
                               final SubversionClientService subversionClientService,
                               final ResolveView view,
                               final ProjectExplorerPresenter projectExplorerPart,
                               final StatusColors statusColors) {
        super(appContext, consoleFactory, consolesPanelPresenter, projectExplorerPart, statusColors);

        this.subversionClientService = subversionClientService;
        this.notificationManager = notificationManager;
        this.dialogFactory = dialogFactory;
        this.constants = constants;
        this.view = view;

        this.view.setDelegate(this);
    }

    public boolean containsConflicts() {
        return conflictsPaths != null && !conflictsPaths.isEmpty();
    }

    public void fetchConflictsList(boolean forCurrentSelection) {
        CurrentProject currentProject = getActiveProject();
        if (currentProject == null) {
            return;
        }

        ProjectConfigDto project = currentProject.getRootProject();
        if (project == null) {
            return;
        }

        if (project.getPath() == null) {
            return;
        }

        subversionClientService.showConflicts(project.getPath(),
                                              forCurrentSelection ? getSelectedPaths() : null,
                                              new AsyncCallback<List<String>>() {
                                                  @Override
                                                  public void onSuccess(List<String> conflictsList) {
                                                      conflictsPaths = conflictsList;
                                                  }

                                                  @Override
                                                  public void onFailure(Throwable exception) {
                                                      notificationManager.notify(exception.getMessage(), FAIL, FLOAT_MODE);
                                                  }
                                              });
    }

    public void showConflictsDialog() {
        if (conflictsPaths != null && !conflictsPaths.isEmpty()) {
            for (String file : conflictsPaths) {<commit_msg>CODENVY-563: Unexpected errors after consuming factory (#1361)<commit_after>/*******************************************************************************
 * Copyright (c) 2012-2016 <NAME>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   <NAME>. - initial API and implementation
 *******************************************************************************/
package org.eclipse.che.plugin.svn.ide.resolve;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.inject.Inject;

import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.app.CurrentProject;
import org.eclipse.che.ide.api.notification.NotificationManager;
import org.eclipse.che.ide.extension.machine.client.processes.ConsolesPanelPresenter;
import org.eclipse.che.ide.part.explorer.project.ProjectExplorerPresenter;
import org.eclipse.che.ide.api.dialogs.ConfirmCallback;
import org.eclipse.che.ide.api.dialogs.DialogFactory;
import org.eclipse.che.plugin.svn.ide.SubversionClientService;
import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants;
import org.eclipse.che.plugin.svn.ide.common.StatusColors;
import org.eclipse.che.plugin.svn.ide.common.SubversionActionPresenter;
import org.eclipse.che.plugin.svn.ide.common.SubversionOutputConsoleFactory;
import org.eclipse.che.plugin.svn.shared.CLIOutputResponse;
import org.eclipse.che.plugin.svn.shared.CLIOutputResponseList;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE;
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL;

public class ResolvePresenter extends SubversionActionPresenter implements ResolveView.ActionDelegate {

    private final NotificationManager                      notificationManager;
    private final DialogFactory                            dialogFactory;
    private final SubversionExtensionLocalizationConstants constants;
    private final SubversionClientService                  subversionClientService;
    private final ResolveView                              view;

    private List<String> conflictsPaths;

    @Inject
    protected ResolvePresenter(final ConsolesPanelPresenter consolesPanelPresenter,
                               final SubversionOutputConsoleFactory consoleFactory,
                               final AppContext appContext,
                               final SubversionExtensionLocalizationConstants constants,
                               final NotificationManager notificationManager,
                               final DialogFactory dialogFactory,
                               final SubversionClientService subversionClientService,
                               final ResolveView view,
                               final ProjectExplorerPresenter projectExplorerPart,
                               final StatusColors statusColors) {
        super(appContext, consoleFactory, consolesPanelPresenter, projectExplorerPart, statusColors);

        this.subversionClientService = subversionClientService;
        this.notificationManager = notificationManager;
        this.dialogFactory = dialogFactory;
        this.constants = constants;
        this.view = view;

        this.view.setDelegate(this);
    }

    public boolean containsConflicts() {
        return conflictsPaths != null && !conflictsPaths.isEmpty();
    }

    public void fetchConflictsList(boolean forCurrentSelection) {
        CurrentProject currentProject = getActiveProject();
        if (currentProject == null) {
            return;
        }

        ProjectConfigDto projectConfig = currentProject.getRootProject();
        if (projectConfig == null) {
            return;
        }

        if (projectConfig.getPath() == null) {
            return;
        }

        if (!projectConfig.getProblems().isEmpty()) {
            return;
        }

        subversionClientService.showConflicts(projectConfig.getPath(),
                                              forCurrentSelection ? getSelectedPaths() : null,
                                              new AsyncCallback<List<String>>() {
                                                  @Override
                                                  public void onSuccess(List<String> conflictsList) {
                                                      conflictsPaths = conflictsList;
                                                  }

                                                  @Override
                                                  public void onFailure(Throwable exception) {
                                                      notificationManager.notify(exception.getMessage(), FAIL, FLOAT_MODE);
                                                  }
                                              });
    }

    public void showConflictsDialog() {
        if (conflictsPaths != null && !conflictsPaths.isEmpty()) {
            for (String file : conflictsPaths) {
{'fraction_non_alphanumeric': 0.09971374045801527, 'fraction_numerical': 0.0029580152671755725, 'mean_word_length': 2.1569277108433735, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 44, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5018201', 'n_tokens_mistral': 2324, 'n_tokens_neox': 2242, 'n_words': 465}