Search in sources :

Example 21 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.

the class BaseRunConfigurationAction method getChildren.

private AnAction[] getChildren(DataContext dataContext) {
    final ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
    final RunnerAndConfigurationSettings existing = context.findExisting();
    if (existing == null) {
        final List<ConfigurationFromContext> producers = getConfigurationsFromContext(context);
        if (producers.size() > 1) {
            final AnAction[] children = new AnAction[producers.size()];
            int childIdx = 0;
            for (final ConfigurationFromContext fromContext : producers) {
                final ConfigurationType configurationType = fromContext.getConfigurationType();
                final RunConfiguration configuration = fromContext.getConfiguration();
                final String actionName = childActionName(configurationType, configuration);
                final AnAction anAction = new AnAction(actionName, configurationType.getDisplayName(), configuration.getIcon()) {

                    @Override
                    public void actionPerformed(AnActionEvent e) {
                        perform(fromContext, context);
                    }
                };
                anAction.getTemplatePresentation().setText(actionName, false);
                children[childIdx++] = anAction;
            }
            return children;
        }
    }
    return EMPTY_ARRAY;
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 22 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.

the class CreateAction method choosePolicy.

private static BaseCreatePolicy choosePolicy(final ConfigurationContext context) {
    final RunnerAndConfigurationSettings configuration = context.findExisting();
    if (configuration == null)
        return CREATE_AND_EDIT;
    final RunManager runManager = context.getRunManager();
    if (runManager.getSelectedConfiguration() != configuration)
        return SELECT;
    if (configuration.isTemporary())
        return SAVE;
    return SELECTED_STABLE;
}
Also used : RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RunManager(com.intellij.execution.RunManager)

Example 23 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.

the class CopyConfigurationAction method doActionPerformed.

@Override
@SuppressWarnings("unchecked")
protected void doActionPerformed(DashboardRunConfigurationNode node) {
    RunManagerEx runManager = RunManagerEx.getInstanceEx(node.getProject());
    RunnerAndConfigurationSettings settings = node.getConfigurationSettings();
    RunnerAndConfigurationSettings copiedSettings = ((RunnerAndConfigurationSettingsImpl) settings).clone();
    runManager.setUniqueNameIfNeed(copiedSettings);
    copiedSettings.setFolderName(settings.getFolderName());
    final ConfigurationFactory factory = settings.getFactory();
    if (factory instanceof ConfigurationFactoryEx) {
        ((ConfigurationFactoryEx) factory).onConfigurationCopied(settings.getConfiguration());
    }
    if (RunDialog.editConfiguration(node.getProject(), copiedSettings, ExecutionBundle.message("run.dashboard.edit.configuration.dialog.title"))) {
        runManager.addConfiguration(copiedSettings, runManager.isConfigurationShared(settings), runManager.getBeforeRunTasks(settings.getConfiguration()), false);
    }
}
Also used : RunManagerEx(com.intellij.execution.RunManagerEx) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) ConfigurationFactoryEx(com.intellij.execution.configuration.ConfigurationFactoryEx) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RunnerAndConfigurationSettingsImpl(com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl)

Example 24 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.

the class RunConfigurationNode method update.

@Override
protected void update(PresentationData presentation) {
    RunnerAndConfigurationSettings configurationSettings = getConfigurationSettings();
    boolean isStored = RunManager.getInstance(getProject()).getAllConfigurationsList().contains(configurationSettings.getConfiguration());
    presentation.addText(configurationSettings.getName(), isStored ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES);
    RunDashboardContributor contributor = RunDashboardContributor.getContributor(configurationSettings.getType());
    Icon icon = null;
    if (contributor != null) {
        DashboardRunConfigurationStatus status = contributor.getStatus(this);
        if (DashboardRunConfigurationStatus.STARTED.equals(status)) {
            icon = getExecutorIcon();
        } else if (DashboardRunConfigurationStatus.FAILED.equals(status)) {
            icon = status.getIcon();
        }
    }
    if (icon == null) {
        icon = RunManagerEx.getInstanceEx(getProject()).getConfigurationIcon(configurationSettings);
    }
    presentation.setIcon(isStored ? icon : IconLoader.getDisabledIcon(icon));
    if (contributor != null) {
        contributor.updatePresentation(presentation, this);
    }
}
Also used : RunDashboardContributor(com.intellij.execution.dashboard.RunDashboardContributor) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) DashboardRunConfigurationStatus(com.intellij.execution.dashboard.DashboardRunConfigurationStatus)

Example 25 with RunnerAndConfigurationSettings

use of com.intellij.execution.RunnerAndConfigurationSettings in project intellij-community by JetBrains.

the class CompoundRunConfigurationSettingsEditor method createEditor.

@NotNull
@Override
protected JComponent createEditor() {
    final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myList);
    return decorator.disableUpDownActions().setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            final List<RunConfiguration> all = new ArrayList<>();
            for (ConfigurationType type : myRunManager.getConfigurationFactories()) {
                if (!(type instanceof UnknownConfigurationType)) {
                    for (RunnerAndConfigurationSettings settings : myRunManager.getConfigurationSettingsList(type)) {
                        all.add(settings.getConfiguration());
                    }
                }
            }
            final List<RunConfiguration> configurations = ContainerUtil.filter(all, configuration -> !mySnapshot.getSetToRun().contains(configuration) && canBeAdded(configuration, mySnapshot));
            JBPopupFactory.getInstance().createListPopup(new MultiSelectionListPopupStep<RunConfiguration>(null, configurations) {

                @Nullable
                @Override
                public ListSeparator getSeparatorAbove(RunConfiguration value) {
                    int i = configurations.indexOf(value);
                    if (i < 1)
                        return null;
                    RunConfiguration previous = configurations.get(i - 1);
                    return value.getType() != previous.getType() ? new ListSeparator() : null;
                }

                @Override
                public Icon getIconFor(RunConfiguration value) {
                    return value.getType().getIcon();
                }

                @Override
                public boolean isSpeedSearchEnabled() {
                    return true;
                }

                @NotNull
                @Override
                public String getTextFor(RunConfiguration value) {
                    return value.getName();
                }

                @Override
                public PopupStep<?> onChosen(List<RunConfiguration> selectedValues, boolean finalChoice) {
                    myList.clearSelection();
                    myModel.addAll(selectedValues);
                    return FINAL_CHOICE;
                }
            }).showUnderneathOf(decorator.getActionsPanel());
        }
    }).setEditAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            int index = myList.getSelectedIndex();
            if (index == -1)
                return;
            RunConfiguration configuration = myModel.get(index);
            RunConfigurationSelector selector = RunConfigurationSelector.KEY.getData(DataManager.getInstance().getDataContext(button.getContextComponent()));
            if (selector != null) {
                selector.select(configuration);
            }
        }
    }).setToolbarPosition(ActionToolbarPosition.TOP).createPanel();
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) UnknownConfigurationType(com.intellij.execution.configurations.UnknownConfigurationType) ListSeparator(com.intellij.openapi.ui.popup.ListSeparator) ArrayList(java.util.ArrayList) RunConfigurationSelector(com.intellij.execution.impl.RunConfigurationSelector) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) UnknownConfigurationType(com.intellij.execution.configurations.UnknownConfigurationType) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ArrayList(java.util.ArrayList) JBList(com.intellij.ui.components.JBList) List(java.util.List) MultiSelectionListPopupStep(com.intellij.openapi.ui.popup.MultiSelectionListPopupStep) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)104 Project (com.intellij.openapi.project.Project)24 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)16 RunManagerEx (com.intellij.execution.RunManagerEx)14 Nullable (org.jetbrains.annotations.Nullable)14 RunManager (com.intellij.execution.RunManager)12 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 Module (com.intellij.openapi.module.Module)10 NotNull (org.jetbrains.annotations.NotNull)9 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)7 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)7 ExternalSystemRunConfiguration (com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration)7 ExternalSystemTaskExecutionSettings (com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)6 Executor (com.intellij.execution.Executor)4 RunManagerImpl (com.intellij.execution.impl.RunManagerImpl)4 AbstractExternalSystemTaskConfigurationType (com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType)4 ExternalSystemNode (com.intellij.openapi.externalSystem.view.ExternalSystemNode)4 RunConfigurationNode (com.intellij.openapi.externalSystem.view.RunConfigurationNode)4 PsiElement (com.intellij.psi.PsiElement)4 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)3