<commit_before>/*******************************************************************************
 * Copyright (c) 2012-2016 Codenvy, S.A.
 * 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:
 *   Codenvy, S.A. - initial API and implementation
 *******************************************************************************/
package org.eclipse.che.ide.ext.java.client.action;

import com.google.common.base.Optional;
import com.google.inject.Inject;
import com.google.inject.Singleton;

import org.eclipse.che.ide.api.action.AbstractPerspectiveAction;
import org.eclipse.che.ide.api.action.ActionEvent;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.resources.Project;
import org.eclipse.che.ide.api.resources.Resource;
import org.eclipse.che.ide.ext.java.client.JavaLocalizationConstant;
import org.eclipse.che.ide.ext.java.client.project.classpath.ProjectClasspathPresenter;

import javax.validation.constraints.NotNull;
import java.util.Collections;

import static org.eclipse.che.ide.ext.java.client.resource.SourceFolderMarker.ID;
import static org.eclipse.che.ide.ext.java.client.util.JavaUtil.isJavaProject;
import static org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;

/**
 * Call classpath wizard to see the information about classpath.
 *
 * @author <NAME>
 */
@Singleton
public class ProjectClasspathAction extends AbstractPerspectiveAction {

    private final ProjectClasspathPresenter projectClasspathPresenter;
    private final AppContext                appContext;

    @Inject
    public ProjectClasspathAction(AppContext appContext,
                                  ProjectClasspathPresenter projectClasspathPresenter,
                                  JavaLocalizationConstant localization) {
        super(Collections.singletonList(PROJECT_PERSPECTIVE_ID),
              localization.projectClasspathTitle(),
              localization.projectClasspathDescriptions(),
              null,
              null);
        this.projectClasspathPresenter = projectClasspathPresenter;
        this.appContext = appContext;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        projectClasspathPresenter.show();
    }

    @Override
    public void updateInPerspective(@NotNull ActionEvent event) {
        final Resource resource = appContext.getResource();
        if (resource == null) {
            event.getPresentation().setEnabledAndVisible(false);
            return;
        }

        final Optional<Project> project = resource.getRelatedProject();
        if (!project.isPresent()) {
            event.getPresentation().setEnabledAndVisible(false);
            return;
        }

        event.getPresentation().setEnabledAndVisible(isJavaProject(project.get()) && resource.getParentWithMarker(ID).isPresent());
    }
}<commit_msg>CHE-1475: Allow open classpath configuration anywhere inside java project<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.ide.ext.java.client.action;

import com.google.common.base.Optional;
import com.google.inject.Inject;
import com.google.inject.Singleton;

import org.eclipse.che.ide.api.action.AbstractPerspectiveAction;
import org.eclipse.che.ide.api.action.ActionEvent;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.resources.Project;
import org.eclipse.che.ide.api.resources.Resource;
import org.eclipse.che.ide.ext.java.client.JavaLocalizationConstant;
import org.eclipse.che.ide.ext.java.client.project.classpath.ProjectClasspathPresenter;

import javax.validation.constraints.NotNull;
import java.util.Collections;

import static org.eclipse.che.ide.ext.java.client.resource.SourceFolderMarker.ID;
import static org.eclipse.che.ide.ext.java.client.util.JavaUtil.isJavaProject;
import static org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;

/**
 * Call classpath wizard to see the information about classpath.
 *
 * @author <NAME>
 */
@Singleton
public class ProjectClasspathAction extends AbstractPerspectiveAction {

    private final ProjectClasspathPresenter projectClasspathPresenter;
    private final AppContext                appContext;

    @Inject
    public ProjectClasspathAction(AppContext appContext,
                                  ProjectClasspathPresenter projectClasspathPresenter,
                                  JavaLocalizationConstant localization) {
        super(Collections.singletonList(PROJECT_PERSPECTIVE_ID),
              localization.projectClasspathTitle(),
              localization.projectClasspathDescriptions(),
              null,
              null);
        this.projectClasspathPresenter = projectClasspathPresenter;
        this.appContext = appContext;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        projectClasspathPresenter.show();
    }

    @Override
    public void updateInPerspective(@NotNull ActionEvent event) {
        final Resource resource = appContext.getResource();
        if (resource == null) {
            event.getPresentation().setEnabledAndVisible(false);
            return;
        }

        final Optional<Project> project = resource.getRelatedProject();
        if (!project.isPresent()) {
            event.getPresentation().setEnabledAndVisible(false);
            return;
        }

        event.getPresentation().setEnabledAndVisible(isJavaProject(project.get()));
    }
}
{'fraction_non_alphanumeric': 0.13811074918566776, 'fraction_numerical': 0.004560260586319218, 'mean_word_length': 3.63821752265861, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1701400', 'n_tokens_mistral': 1598, 'n_tokens_neox': 1537, 'n_words': 307}