public void update(final AnActionEvent event) {
try {
_actionEvent = event;
_dataContext = event.getDataContext();
final com.intellij.openapi.project.Project 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);
final VirtualFile[] selectedSourceFiles = IdeaUtilImpl.getVirtualFiles(_dataContext);
if (!_running) {
_enabled = selectedSourceFiles != null &&
selectedSourceFiles.length > 0 &&
selectedSourceFiles[0].isValid() &&
IdeaUtilImpl.isValidFileType(selectedSourceFiles[0].getFileType()) &&
IdeaUtilImpl.getCurrentClass(_dataContext) != null;
}
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);
}