final Project project = DataKeys.PROJECT.getData(event.getDataContext());
if (project == null) { // check if we're loading...
return;
}
final CheckStylePlugin checkStylePlugin
= project.getComponent(CheckStylePlugin.class);
if (checkStylePlugin == null) {
throw new IllegalStateException("Couldn't get checkstyle plugin");
}
final Presentation presentation = event.getPresentation();
// disable if no files are modified
final List<VirtualFile> modifiedFiles = ChangeListManager.getInstance(project).getAffectedFiles();
if (modifiedFiles.size() == 0) {
presentation.setEnabled(false);
} else {
presentation.setEnabled(!checkStylePlugin.isScanInProgress());
}
} catch (Throwable e) {
final CheckStylePluginException processed
= CheckStylePlugin.processError(null, e);