if (project == null) { // check if we're loading...
presentation.setEnabled(false);
return;
}
final CheckStylePlugin checkStylePlugin
= project.getComponent(CheckStylePlugin.class);
if (checkStylePlugin == null) {
throw new IllegalStateException("Couldn't get checkstyle plugin");
}
final ProjectRootManager projectRootManager
= ProjectRootManager.getInstance(project);
final VirtualFile[] sourceRoots
= projectRootManager.getContentSourceRoots();
// disable if no files are selected
if (sourceRoots == null || sourceRoots.length == 0) {
presentation.setEnabled(false);
} else {
presentation.setEnabled(!checkStylePlugin.isScanInProgress());
}
} catch (Throwable e) {
CheckStylePlugin.processErrorAndLog("Project button update", e);
}
}