try {
_actionEvent = event;
_dataContext = event.getDataContext();
final 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;
}
// enable ?
final Content content = toolWindow.getContentManager().getContent(0);
if (content != null) {
final ToolWindowPanel panel = (ToolWindowPanel) content.getComponent();
final BugTree tree = panel.getBugTreePanel().getBugTree();
_enabled = tree.hasNextOccurence();
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);
}