mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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.
This commit is contained in:
@@ -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<AnAction> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@
|
||||
-->
|
||||
</action>
|
||||
|
||||
<group id="NewProjectOrModuleGroup">
|
||||
</group>
|
||||
|
||||
<group id="PrintExportGroup">
|
||||
<separator/>
|
||||
|
||||
@@ -94,8 +94,11 @@
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
<action id="NewDirectoryProject" class="com.jetbrains.python.newProject.PyCharmNewProjectAction">
|
||||
<add-to-group group-id="NewProjectOrModuleGroup"/>
|
||||
</action>
|
||||
<group id="PlatformOpenProjectGroup">
|
||||
<action id="NewDirectoryProject" class="com.jetbrains.python.newProject.PyCharmNewProjectAction"/>
|
||||
<reference ref="NewProjectOrModuleGroup"/>
|
||||
<action id="NewElement" class="com.intellij.ide.actions.NewElementAction" />
|
||||
<reference ref="NewScratchFile" />
|
||||
<add-to-group group-id="FileOpenGroup" anchor="first"/>
|
||||
|
||||
@@ -847,6 +847,11 @@
|
||||
<actions>
|
||||
<action id="NewElement" class="com.intellij.ide.actions.NewElementAction"/>
|
||||
|
||||
<group id="OpenProjectGroup">
|
||||
<group id="NewElementInMenuGroup" class="com.intellij.ide.actions.NewActionGroup" text="New" popup="true"/>
|
||||
<add-to-group group-id="FileOpenGroup" anchor="first"/>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<group id="MarkSourceRootGroup" class="com.intellij.ide.projectView.actions.MarkSourceRootActionGroup"/>
|
||||
<action id="MarkExcludeRoot" class="com.intellij.ide.projectView.actions.MarkExcludeRootAction"/>
|
||||
|
||||
@@ -14,12 +14,8 @@
|
||||
</group>
|
||||
|
||||
<!-- File -->
|
||||
<group id="OpenProjectGroup">
|
||||
<group id="NewElementInMenuGroup" class="com.intellij.ide.actions.NewActionGroup" text="New" popup="true"/>
|
||||
<add-to-group group-id="FileOpenGroup" anchor="first"/>
|
||||
</group>
|
||||
|
||||
<group id="NewProjectOrModuleGroup">
|
||||
<group id="JavaNewProjectOrModuleGroup">
|
||||
<action id="NewProject" class="com.intellij.ide.actions.NewProjectAction" text="Project..."/>
|
||||
<action id="ImportProject" class="com.intellij.ide.actions.ImportProjectAction" text="Project from Existing Sources..."/>
|
||||
<group id="NewProjectFromVCS" class="com.intellij.openapi.vcs.checkout.NewProjectFromVCSGroup" text="Project from Version Control"
|
||||
@@ -27,7 +23,8 @@
|
||||
<separator/>
|
||||
<action id="NewModule" class="com.intellij.openapi.roots.ui.configuration.actions.NewModuleAction" text="Module..."/>
|
||||
<action id="ImportModule" class="com.intellij.ide.actions.ImportModuleAction" text="Module from Existing Sources..."/>
|
||||
<separator/>
|
||||
|
||||
<add-to-group group-id="NewProjectOrModuleGroup"/>
|
||||
</group>
|
||||
|
||||
<action id="SaveAsNewFormat" class="com.intellij.ide.actions.SaveAsDirectoryBasedFormatAction" text="Save as Directory-Based Format...">
|
||||
|
||||
Reference in New Issue
Block a user