Example usage for com.intellij.openapi.actionSystem IdeActions ACTION_EDIT_RUN_CONFIGURATIONS

List of usage examples for com.intellij.openapi.actionSystem IdeActions ACTION_EDIT_RUN_CONFIGURATIONS

Introduction

In this page you can find the example usage for com.intellij.openapi.actionSystem IdeActions ACTION_EDIT_RUN_CONFIGURATIONS.

Prototype

String ACTION_EDIT_RUN_CONFIGURATIONS

To view the source code for com.intellij.openapi.actionSystem IdeActions ACTION_EDIT_RUN_CONFIGURATIONS.

Click Source Link

Usage

From source file:com.intellij.execution.actions.RunConfigurationsComboBoxAction.java

License:Apache License

@Override
@NotNull//from  w w  w .j  a va 2 s  . c  o m
protected DefaultActionGroup createPopupActionGroup(final JComponent button) {
    final DefaultActionGroup allActionsGroup = new DefaultActionGroup();
    final Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(button));
    if (project != null) {
        final RunManagerEx runManager = RunManagerEx.getInstanceEx(project);

        allActionsGroup.add(ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_RUN_CONFIGURATIONS));
        allActionsGroup.add(new SaveTemporaryAction());
        allActionsGroup.addSeparator();

        RunnerAndConfigurationSettings selected = RunManager.getInstance(project).getSelectedConfiguration();
        if (selected != null) {
            ExecutionTarget activeTarget = ExecutionTargetManager.getActiveTarget(project);
            for (ExecutionTarget eachTarget : ExecutionTargetManager.getTargetsToChooseFor(project, selected)) {
                allActionsGroup
                        .add(new SelectTargetAction(project, eachTarget, eachTarget.equals(activeTarget)));
            }
            allActionsGroup.addSeparator();
        }

        final ConfigurationType[] types = runManager.getConfigurationFactories();
        for (ConfigurationType type : types) {
            final DefaultActionGroup actionGroup = new DefaultActionGroup();
            Map<String, List<RunnerAndConfigurationSettings>> structure = runManager.getStructure(type);
            for (Map.Entry<String, List<RunnerAndConfigurationSettings>> entry : structure.entrySet()) {
                DefaultActionGroup group = entry.getKey() != null ? new DefaultActionGroup(entry.getKey(), true)
                        : actionGroup;
                group.getTemplatePresentation().setIcon(AllIcons.Nodes.Folder);
                for (RunnerAndConfigurationSettings settings : entry.getValue()) {
                    group.add(new SelectConfigAction(settings, project));
                }
                if (group != actionGroup) {
                    actionGroup.add(group);
                }
            }

            allActionsGroup.add(actionGroup);
            allActionsGroup.addSeparator();
        }
    }
    return allActionsGroup;
}