AnActionButton () { AnActionButton button = new AnActionButton(CodeInsightBundle.messagePointer("action.AnActionButton.text.duplicate"), PlatformIcons.COPY_ICON) { @Override public void actionPerformed(@NotNull AnActionEvent e) { if (myCheckboxTree != null) { myCheckboxTree.duplicateSelectedTemplate(); } } @Override public void updateButton(@NotNull AnActionEvent e) { e.getPresentation().setEnabled(myCheckboxTree != null && myCheckboxTree.canDuplicateSelectedTemplate()); } @Override public @NotNull ActionUpdateThread getActionUpdateThread() { return ActionUpdateThread.EDT; } }; button.registerCustomShortcutSet(CommonShortcuts.getDuplicate(), myCheckboxTree, myCheckboxTree); return button; }