Search in sources :

Example 6 with ScanScope

use of org.infernus.idea.checkstyle.model.ScanScope in project checkstyle-idea by jshiell.

the class CheckStyleConfigPanel method getPluginConfiguration.

public PluginConfiguration getPluginConfiguration() {
    final String checkstyleVersion = (String) csVersionDropdown.getSelectedItem();
    ScanScope scanScope = (ScanScope) scopeDropdown.getSelectedItem();
    if (scanScope == null) {
        scanScope = ScanScope.getDefaultValue();
    }
    // we don't know the scanBeforeCheckin flag at this point
    return PluginConfigurationBuilder.defaultConfiguration(project).withCheckstyleVersion(checkstyleVersion).withScanScope(scanScope).withSuppressErrors(suppressErrorsCheckbox.isSelected()).withCopyLibraries(copyLibsCheckbox.isSelected()).withLocations(new TreeSet<>(locationModel.getLocations())).withThirdPartyClassPath(getThirdPartyClasspath()).withActiveLocation(locationModel.getActiveLocation()).build();
}
Also used : ScanScope(org.infernus.idea.checkstyle.model.ScanScope)

Example 7 with ScanScope

use of org.infernus.idea.checkstyle.model.ScanScope in project checkstyle-idea by jshiell.

the class ProjectConfigurationState method scopeValueOf.

@NotNull
private ScanScope scopeValueOf(@NotNull final Map<String, String> loadedMap) {
    final String propertyValue = loadedMap.get(SCANSCOPE_SETTING);
    ScanScope result = ScanScope.getDefaultValue();
    if (propertyValue != null) {
        try {
            result = ScanScope.valueOf(propertyValue);
        } catch (IllegalArgumentException e) {
        // settings got messed up (manual edit?) - use default
        }
    }
    return result;
}
Also used : ScanScope(org.infernus.idea.checkstyle.model.ScanScope) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with ScanScope

use of org.infernus.idea.checkstyle.model.ScanScope in project checkstyle-idea by jshiell.

the class ScanProject method update.

@Override
public void update(final AnActionEvent event) {
    super.update(event);
    try {
        final Presentation presentation = event.getPresentation();
        Optional<Project> projectFromEvent = project(event);
        if (!projectFromEvent.isPresent()) {
            presentation.setEnabled(false);
            return;
        }
        projectFromEvent.ifPresent(project -> {
            final ScanScope scope = configurationManager(project).getCurrent().getScanScope();
            final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(project);
            VirtualFile[] sourceRoots;
            if (scope == ScanScope.Everything) {
                sourceRoots = projectRootManager.getContentRoots();
            } else {
                sourceRoots = projectRootManager.getContentSourceRoots();
            }
            // disable if no files are selected or scan in progress
            if (containsAtLeastOneFile(sourceRoots)) {
                presentation.setEnabled(!staticScanner(project).isScanInProgress());
            } else {
                presentation.setEnabled(false);
            }
        });
    } catch (Throwable e) {
        LOG.warn("Project button update failed", e);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) ScanScope(org.infernus.idea.checkstyle.model.ScanScope) Presentation(com.intellij.openapi.actionSystem.Presentation) ProjectRootManager(com.intellij.openapi.roots.ProjectRootManager)

Example 9 with ScanScope

use of org.infernus.idea.checkstyle.model.ScanScope in project checkstyle-idea by jshiell.

the class ScanCurrentFile method update.

@Override
public void update(final AnActionEvent event) {
    super.update(event);
    project(event).ifPresent(project -> {
        try {
            final ScanScope scope = configurationManager(project).getCurrent().getScanScope();
            final VirtualFile selectedFile = getSelectedFile(project, scope);
            // disable if no file is selected or scan in progress
            final Presentation presentation = event.getPresentation();
            if (selectedFile != null) {
                presentation.setEnabled(!staticScanner(project).isScanInProgress());
            } else {
                presentation.setEnabled(false);
            }
        } catch (Throwable e) {
            LOG.warn("Current File button update failed", e);
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ScanScope(org.infernus.idea.checkstyle.model.ScanScope) Presentation(com.intellij.openapi.actionSystem.Presentation)

Aggregations

ScanScope (org.infernus.idea.checkstyle.model.ScanScope)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 Presentation (com.intellij.openapi.actionSystem.Presentation)3 ToolWindow (com.intellij.openapi.wm.ToolWindow)3 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 ModuleRootManager (com.intellij.openapi.roots.ModuleRootManager)1 ProjectRootManager (com.intellij.openapi.roots.ProjectRootManager)1 NotNull (org.jetbrains.annotations.NotNull)1