void (@NotNull AnActionEvent e) { final ExclusionHandler<T> exclusionProcessor = e.getData(ExclusionHandler.EXCLUSION_HANDLER); if (exclusionProcessor == null) { e.getPresentation().setEnabledAndVisible(false); return; } final Component component = e.getData(PlatformCoreDataKeys.CONTEXT_COMPONENT); final Presentation presentation = e.getPresentation(); if (!(component instanceof JTree tree) || !exclusionProcessor.isActionEnabled(myIsExclude)) { presentation.setEnabledAndVisible(false); return; } List<TreePath> selection = TreePathRoots.collect(tree.getSelectionPaths()); if (selection.isEmpty()) { presentation.setEnabledAndVisible(false); return; } final boolean[] isEnabled = {false}; for (TreePath path : selection) { final T node = (T)path.getLastPathComponent(); TreeUtil.traverse(node, n -> { if (!exclusionProcessor.isNodeExclusionAvailable((T)n)) return true; boolean isNodeExcluded = exclusionProcessor.isNodeExcluded((T)n); if (myIsExclude != isNodeExcluded) { isEnabled[0] = true; return false; } return true; }); } presentation.setEnabledAndVisible(isEnabled[0]); if (isEnabled[0]) { presentation.setText(getActionText(selection.size() > 1)); } }