void (@NotNull AnActionEvent e) { final Component component = e.getData(PlatformCoreDataKeys.CONTEXT_COMPONENT); if (component instanceof JTextComponent textComponent) { e.getPresentation().setEnabled(textComponent.getText().length() > 0 && ((JTextComponent)component).isEditable()); } else { e.getPresentation().setEnabled(false); } }