void (@NotNull AnActionEvent e) { Project project = e.getProject(); MyLoadingChangesPanel changesPanel = e.getData(MyLoadingChangesPanel.DATA_KEY); if (project == null || changesPanel == null) { e.getPresentation().setEnabledAndVisible(false); return; } MyChangesBrowser browser = ObjectUtils.tryCast(changesPanel.getChangesBrowser(), MyChangesBrowser.class); boolean isVisible = browser != null && browser.myLocalContent != LocalContent.NONE; boolean isEnabled = isVisible && !browser.getSelectedChanges().isEmpty(); e.getPresentation().setVisible(isVisible); e.getPresentation().setEnabled(isEnabled); }