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();
}
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;
}
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);
}
}
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);
}
});
}
Aggregations