void (@NotNull AnActionEvent e) { final Map<TemplateImpl, DefaultMutableTreeNode> templates = getSelectedTemplates(); boolean enabled = !templates.isEmpty(); e.getPresentation().setEnabledAndVisible(enabled); if (enabled) { Set<String> oldGroups = getAllGroups(templates); removeAll(); for (TemplateGroup group : getTemplateGroups()) { final String newGroupName = group.getName(); if (!oldGroups.contains(newGroupName)) { add(new DumbAwareAction(newGroupName) { @Override public void actionPerformed(@NotNull AnActionEvent e) { moveTemplates(templates, newGroupName); } }); } } addSeparator(); add(new DumbAwareAction(IdeBundle.messagePointer("action.Anonymous.text.new.group")) { @Override public void actionPerformed(@NotNull AnActionEvent e) { String newName = Messages.showInputDialog(myTree, CodeInsightBundle.message("label.enter.the.new.group.name"), CodeInsightBundle.message("dialog.title.move.to.a.new.group"), null, "", new TemplateGroupInputValidator(null)); if (newName != null) { moveTemplates(templates, newName); } } }); } }