List of usage examples for com.intellij.openapi.actionSystem IdeActions ACTION_RENAME
String ACTION_RENAME
To view the source code for com.intellij.openapi.actionSystem IdeActions ACTION_RENAME.
Click Source Link
From source file:com.intellij.codeInsight.template.impl.TemplateListPanel.java
License:Apache License
private void installPopup() { final DumbAwareAction rename = new DumbAwareAction("Rename") { @Override/*from w ww . j av a 2 s . c om*/ public void update(AnActionEvent e) { final int selected = getSingleSelectedIndex(); final TemplateGroup templateGroup = getGroup(selected); boolean enabled = templateGroup != null; e.getPresentation().setEnabled(enabled); e.getPresentation().setVisible(enabled); super.update(e); } @Override public void actionPerformed(AnActionEvent e) { renameGroup(); } }; rename.registerCustomShortcutSet( ActionManager.getInstance().getAction(IdeActions.ACTION_RENAME).getShortcutSet(), myTree); final DefaultActionGroup move = new DefaultActionGroup("Move", true) { @Override public void update(AnActionEvent e) { final Map<TemplateImpl, DefaultMutableTreeNode> templates = getSelectedTemplates(); boolean enabled = !templates.isEmpty(); e.getPresentation().setEnabled(enabled); e.getPresentation().setVisible(enabled); if (enabled) { Set<String> oldGroups = getAllGroups(templates); removeAll(); SchemesManager<TemplateGroup, TemplateGroup> schemesManager = TemplateSettings.getInstance() .getSchemesManager(); for (TemplateGroup group : getTemplateGroups()) { final String newGroupName = group.getName(); if (!oldGroups.contains(newGroupName)) { add(new DumbAwareAction(newGroupName) { @Override public void actionPerformed(AnActionEvent e) { moveTemplates(templates, newGroupName); } }); } } addSeparator(); add(new DumbAwareAction("New group...") { @Override public void actionPerformed(AnActionEvent e) { String newName = Messages.showInputDialog(myTree, "Enter the new group name:", "Move to a New Group", null, "", new TemplateGroupInputValidator(null)); if (newName != null) { moveTemplates(templates, newName); } } }); } } }; myTree.addMouseListener(new PopupHandler() { @Override public void invokePopup(Component comp, int x, int y) { final DefaultActionGroup group = new DefaultActionGroup(); group.add(rename); group.add(move); ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group).getComponent() .show(comp, x, y); } }); }