@Override @NotNull 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; }
public SelectTargetAction( final Project project, final ExecutionTarget target, boolean selected) { myProject = project; myTarget = target; String name = target.getDisplayName(); Presentation presentation = getTemplatePresentation(); presentation.setText(name, false); presentation.setDescription("Select " + name); presentation.setIcon(selected ? CHECKED_ICON : EMPTY_ICON); presentation.setSelectedIcon(selected ? CHECKED_SELECTED_ICON : EMPTY_ICON); }
private static void updatePresentation( @Nullable ExecutionTarget target, @Nullable RunnerAndConfigurationSettings settings, @Nullable Project project, @NotNull Presentation presentation) { if (project != null && target != null && settings != null) { String name = settings.getName(); if (target != DefaultExecutionTarget.INSTANCE) { name += " | " + target.getDisplayName(); } else { if (!settings.canRunOn(target)) { name += " | Nothing to run on"; } } presentation.setText(name, false); setConfigurationIcon(presentation, settings, project); } else { presentation.setText(""); // IDEA-21657 presentation.setIcon(null); } }