Search in sources :

Example 76 with RunnerAndConfigurationSettings

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

the class AbstractExternalSystemRuntimeConfigurationProducer method createConfigurationByElement.

@Nullable
@Override
protected RunnerAndConfigurationSettings createConfigurationByElement(Location location, ConfigurationContext context) {
    if (!(location instanceof ExternalSystemTaskLocation)) {
        return null;
    }
    ExternalSystemTaskLocation taskLocation = (ExternalSystemTaskLocation) location;
    mySourceElement = taskLocation.getPsiElement();
    RunManagerEx runManager = RunManagerEx.getInstanceEx(taskLocation.getProject());
    RunnerAndConfigurationSettings settings = runManager.createConfiguration("", getConfigurationFactory());
    ExternalSystemRunConfiguration configuration = (ExternalSystemRunConfiguration) settings.getConfiguration();
    ExternalSystemTaskExecutionSettings taskExecutionSettings = configuration.getSettings();
    ExternalTaskExecutionInfo task = taskLocation.getTaskInfo();
    taskExecutionSettings.setExternalProjectPath(task.getSettings().getExternalProjectPath());
    taskExecutionSettings.setTaskNames(task.getSettings().getTaskNames());
    configuration.setName(AbstractExternalSystemTaskConfigurationType.generateName(location.getProject(), taskExecutionSettings));
    return settings;
}
Also used : RunManagerEx(com.intellij.execution.RunManagerEx) ExternalTaskExecutionInfo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ExternalSystemTaskExecutionSettings(com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings) Nullable(org.jetbrains.annotations.Nullable)

Example 77 with RunnerAndConfigurationSettings

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

the class AssignRunConfigurationShortcutAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = getProject(e);
    assert project != null;
    final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
    if (selectedNodes == null || selectedNodes.size() != 1 || !(selectedNodes.get(0) instanceof RunConfigurationNode))
        return;
    RunnerAndConfigurationSettings settings = ((RunConfigurationNode) selectedNodes.get(0)).getSettings();
    assert settings != null;
    ExternalSystemRunConfiguration runConfiguration = (ExternalSystemRunConfiguration) settings.getConfiguration();
    String actionIdPrefix = getActionPrefix(project, runConfiguration.getSettings().getExternalProjectPath());
    String actionId = actionIdPrefix + settings.getName();
    AnAction action = ActionManager.getInstance().getAction(actionId);
    if (action == null) {
        ExternalSystemKeymapExtension.getOrRegisterAction(project, settings);
    }
    new EditKeymapsDialog(project, actionId).show();
}
Also used : Project(com.intellij.openapi.project.Project) EditKeymapsDialog(com.intellij.openapi.keymap.impl.ui.EditKeymapsDialog) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ExternalSystemRunConfiguration(com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration) ExternalSystemNode(com.intellij.openapi.externalSystem.view.ExternalSystemNode) RunConfigurationNode(com.intellij.openapi.externalSystem.view.RunConfigurationNode) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 78 with RunnerAndConfigurationSettings

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

the class RunExternalSystemTaskAction method perform.

@Override
protected void perform(@NotNull Project project, @NotNull ProjectSystemId projectSystemId, @NotNull TaskData taskData, @NotNull AnActionEvent e) {
    final ExternalTaskExecutionInfo taskExecutionInfo = ExternalSystemActionUtil.buildTaskInfo(taskData);
    ExternalSystemUtil.runTask(taskExecutionInfo.getSettings(), taskExecutionInfo.getExecutorId(), project, projectSystemId);
    final DataContext dataContext = e.getDataContext();
    final ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
    RunnerAndConfigurationSettings configuration = context.findExisting();
    RunManagerEx runManager = (RunManagerEx) context.getRunManager();
    if (configuration == null) {
        configuration = context.getConfiguration();
        if (configuration == null) {
            return;
        }
        runManager.setTemporaryConfiguration(configuration);
    }
    runManager.setSelectedConfiguration(configuration);
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) DataContext(com.intellij.openapi.actionSystem.DataContext) RunManagerEx(com.intellij.execution.RunManagerEx) ExternalTaskExecutionInfo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Example 79 with RunnerAndConfigurationSettings

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

the class ModuleRunConfigurationManager method readExternal.

public void readExternal(@NotNull final Element element) {
    LOG.debug("readExternal(" + myModule + ")");
    myUnloadedElements = null;
    final Set<String> existing = new HashSet<>();
    for (final Element child : element.getChildren()) {
        final RunnerAndConfigurationSettings configuration = myManager.loadConfiguration(child, true);
        if (configuration == null && Comparing.strEqual(element.getName(), RunManagerImpl.CONFIGURATION)) {
            if (myUnloadedElements == null)
                myUnloadedElements = new ArrayList<>(2);
            myUnloadedElements.add(element);
        }
        if (configuration != null) {
            existing.add(configuration.getUniqueID());
        }
    }
    for (final RunConfiguration configuration : myManager.getAllConfigurationsList()) {
        if (!usesMyModule(configuration)) {
            RunnerAndConfigurationSettings settings = myManager.getSettings(configuration);
            if (settings != null) {
                existing.add(settings.getUniqueID());
            }
        }
    }
    myManager.removeNotExistingSharedConfigurations(existing);
    // IDEA-60004: configs may never be sorted before write, so call it manually after shared configs read
    myManager.setOrdered(false);
    myManager.getSortedConfigurations();
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) Element(org.jdom.Element) ArrayList(java.util.ArrayList) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) HashSet(com.intellij.util.containers.HashSet)

Example 80 with RunnerAndConfigurationSettings

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

the class ProjectRunConfigurationManager method loadState.

@Override
public void loadState(Element state) {
    if (myUnloadedElements != null) {
        myUnloadedElements.clear();
    }
    Set<String> existing = new THashSet<>();
    for (Iterator<Element> iterator = state.getChildren().iterator(); iterator.hasNext(); ) {
        Element child = iterator.next();
        RunnerAndConfigurationSettings configuration = myManager.loadConfiguration(child, true);
        if (configuration != null) {
            existing.add(configuration.getUniqueID());
        } else if (child.getName().equals(RunManagerImpl.CONFIGURATION)) {
            if (myUnloadedElements == null) {
                myUnloadedElements = new SmartList<>();
            }
            iterator.remove();
            myUnloadedElements.add(child);
        }
    }
    myManager.removeNotExistingSharedConfigurations(existing);
    if (myManager.getSelectedConfiguration() == null) {
        final List<RunConfiguration> allConfigurations = myManager.getAllConfigurationsList();
        for (final RunConfiguration configuration : allConfigurations) {
            final RunnerAndConfigurationSettings settings = myManager.getSettings(allConfigurations.get(0));
            if (!(configuration instanceof UnknownRunConfiguration)) {
                myManager.setSelectedConfiguration(settings);
                break;
            }
        }
    }
    // IDEA-60004: configs may never be sorted before write, so call it manually after shared configs read
    myManager.setOrdered(false);
    myManager.getSortedConfigurations();
}
Also used : UnknownRunConfiguration(com.intellij.execution.configurations.UnknownRunConfiguration) UnknownRunConfiguration(com.intellij.execution.configurations.UnknownRunConfiguration) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) Element(org.jdom.Element) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) SmartList(com.intellij.util.SmartList) THashSet(gnu.trove.THashSet)

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