void () { super.addNotify(); DataContext context = DataManager.getInstance().getDataContext(getParent()); Disposable parentDisposable = Objects.requireNonNullElse(CommonDataKeys.PROJECT.getData(context), ApplicationManager.getApplication()); myConnection = ApplicationManager.getApplication().getMessageBus().connect(parentDisposable); myConnection.subscribe(AnActionListener.TOPIC, new AnActionListener() { @Override public void beforeActionPerformed(@NotNull AnAction action, @NotNull AnActionEvent event) { if (event.getDataContext().getData(PlatformCoreDataKeys.CONTEXT_COMPONENT) == SplitButton.this) { selectedAction = action; copyPresentation(event.getPresentation()); repaint(); } } }); }