void (@NotNull AnActionEvent event, boolean flag) { if (flag) { // invokeLater is called to update state of button before long tree building operation ApplicationManager.getApplication().invokeLater(() -> changeView(myTypeName)); } }