JComponent () { Presentation presentation = new Presentation(); presentation.setText(text); presentation.setDescription(text); presentation.setIcon(icon); presentation.setEnabled(false); tree.getModel().addTreeModelListener(new TreeModelAdapter() { @Override protected void process(@NotNull TreeModelEvent event, @NotNull EventType type) { if (!presentation.isEnabled() && tree.getTestCount() != 0) { presentation.setEnabled(true); } } }); return new ActionButton(new AnAction() { @Override public void actionPerformed(@NotNull AnActionEvent e) { listener.run(); } }, presentation, "ShowDiscoveredTestsToolbar", ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE); }