ArrayList<AnAction> (final boolean fromPopup) { ArrayList<AnAction> result = new ArrayList<>(); result.add(new DumbAwareAction(SvnBundle.messagePointer("action.DumbAware.SvnConfigureProxiesComponent.text.add"), SvnBundle.messagePointer("action.DumbAware.SvnConfigureProxiesComponent.description.add"), IconUtil.getAddIcon()) { { registerCustomShortcutSet(CommonShortcuts.INSERT, myTree); } @Override public void actionPerformed(@NotNull AnActionEvent event) { addGroup(null); } }); result.add(new MyDeleteAction(forAll(o -> { if (o instanceof MyNode node) { if (node.getConfigurable() instanceof GroupConfigurable) { final ProxyGroup group = ((GroupConfigurable)node.getConfigurable()).getEditableObject(); return !group.isDefault(); } } return false; })) { @Override public void actionPerformed(@NotNull final AnActionEvent e) { final TreePath path = myTree.getSelectionPath(); final MyNode node = (MyNode)path.getLastPathComponent(); final MyNode parentNode = (MyNode) node.getParent(); int idx = parentNode.getIndex(node); super.actionPerformed(e); idx = (idx == parentNode.getChildCount()) ? idx - 1 : idx; if (parentNode.getChildCount() > 0) { final TreePath newSelectedPath = new TreePath(parentNode.getPath()).pathByAddingChild(parentNode.getChildAt(idx)); myTree.setSelectionPath(newSelectedPath); } } }); result.add(new DumbAwareAction(SvnBundle.messagePointer("action.DumbAware.SvnConfigureProxiesComponent.text.copy"), SvnBundle.messagePointer("action.DumbAware.SvnConfigureProxiesComponent.description.copy"), PlatformIcons.COPY_ICON) { { registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK)), myTree); } @Override public void actionPerformed(@NotNull AnActionEvent event) { // apply - for update of editable object try { getSelectedConfigurable().apply(); } catch (ConfigurationException e) { // suppress & wait for OK } final ProxyGroup selectedGroup = (ProxyGroup)getSelectedObject(); if (selectedGroup != null) { addGroup(selectedGroup); } } @Override public @NotNull ActionUpdateThread getActionUpdateThread() { return ActionUpdateThread.EDT; } @Override public void update(@NotNull AnActionEvent event) { event.getPresentation().setEnabled(getSelectedObject() != null); } }); return result; }