public void update(final AnActionEvent event) {
try {
_actionEvent = event;
_dataContext = event.getDataContext();
_project = DataKeys.PROJECT.getData(_dataContext);
final Presentation presentation = event.getPresentation();
// check a project is loaded
if (isProjectNotLoaded(_project, presentation)) {
return;
}
isPluginAccessible(_project);
// check if tool window is registered
final ToolWindow toolWindow = isToolWindowRegistered(_project);
if (toolWindow == null) {
presentation.setEnabled(false);
presentation.setVisible(false);
return;
}
registerEventListener(_project);
// enable ?
final List<VirtualFile> modifiedFiles = IdeaUtilImpl.getAllModifiedFiles(_dataContext);
if (!_running && !modifiedFiles.isEmpty()) {
for (final VirtualFile virtualFile : modifiedFiles) {
if (IdeaUtilImpl.isValidFileType(virtualFile.getFileType())) {
_enabled = true;
break;
} else {
_enabled = false;
}
}
} else {
_enabled = false;
}
presentation.setEnabled(toolWindow.isAvailable() && isEnabled());
presentation.setVisible(true);
} catch (final Throwable e) {
final FindBugsPluginException processed = FindBugsPluginImpl.processError("Action update failed", e);
LOGGER.error("Action update failed", processed);
}