From a35dc3fada33659dcbc5570f55fdf838e900bfd3 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 28 Feb 2019 18:52:30 +0300 Subject: [PATCH] actions: move 'NewProjectOrModuleGroup' to the platform and reuse it in concrete IDEs This is needed to allow plugins contribute their own variants of 'New Project' action (e.g. in Java plugin, IDEA-195719) which should be shown under the main one. --- .../intellij/ide/actions/NewActionGroup.java | 21 +++++++++++++------ .../src/idea/LangActions.xml | 2 ++ python/ide/src/META-INF/pycharm-core.xml | 5 ++++- resources/src/META-INF/JavaIdePlugin.xml | 5 +++++ resources/src/idea/JavaActions.xml | 9 +++----- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/actions/NewActionGroup.java b/platform/lang-impl/src/com/intellij/ide/actions/NewActionGroup.java index eb8c22b8ce79..c369373489d6 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/NewActionGroup.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/NewActionGroup.java @@ -16,10 +16,13 @@ package com.intellij.ide.actions; import com.intellij.openapi.actionSystem.*; -import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + /** * @author Dmitry Avdeev */ @@ -31,11 +34,17 @@ public class NewActionGroup extends ActionGroup { AnAction[] actions = ((ActionGroup)ActionManager.getInstance().getAction(IdeActions.GROUP_WEIGHING_NEW)).getChildren(e); if (e == null || ActionPlaces.isMainMenuOrActionSearch(e.getPlace())) { AnAction newGroup = ActionManager.getInstance().getAction("NewProjectOrModuleGroup"); - AnAction[] newProjectActions = newGroup == null ? EMPTY_ARRAY : ((ActionGroup)newGroup).getChildren(e); - return ArrayUtil.mergeArrays(newProjectActions, actions); - } - else { - return actions; + if (newGroup != null) { + AnAction[] newProjectActions = ((ActionGroup)newGroup).getChildren(e); + if (newProjectActions.length > 0) { + List mergedActions = new ArrayList<>(newProjectActions.length + 1 + actions.length); + Collections.addAll(mergedActions, newProjectActions); + mergedActions.add(Separator.getInstance()); + Collections.addAll(mergedActions, actions); + return mergedActions.toArray(AnAction.EMPTY_ARRAY); + } + } } + return actions; } } diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml index 9c1c6007391c..7b5f2b84ce56 100644 --- a/platform/platform-resources/src/idea/LangActions.xml +++ b/platform/platform-resources/src/idea/LangActions.xml @@ -74,6 +74,8 @@ --> + + diff --git a/python/ide/src/META-INF/pycharm-core.xml b/python/ide/src/META-INF/pycharm-core.xml index 19cdc39d3fd4..4ab402f435df 100644 --- a/python/ide/src/META-INF/pycharm-core.xml +++ b/python/ide/src/META-INF/pycharm-core.xml @@ -94,8 +94,11 @@ + + + - + diff --git a/resources/src/META-INF/JavaIdePlugin.xml b/resources/src/META-INF/JavaIdePlugin.xml index 70adbe3c44ce..e1c140960631 100644 --- a/resources/src/META-INF/JavaIdePlugin.xml +++ b/resources/src/META-INF/JavaIdePlugin.xml @@ -847,6 +847,11 @@ + + + + + diff --git a/resources/src/idea/JavaActions.xml b/resources/src/idea/JavaActions.xml index 7beaeb3c4752..53d0a2d6c72c 100644 --- a/resources/src/idea/JavaActions.xml +++ b/resources/src/idea/JavaActions.xml @@ -14,12 +14,8 @@ - - - - - + - + +