Search in sources :

Example 6 with RunManagerEx

use of com.intellij.execution.RunManagerEx 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 7 with RunManagerEx

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

the class ContextConfigurationTest method testReusingConfiguration.

public void testReusingConfiguration() {
    RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
    PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
    PsiPackage psiPackage = JUnitUtil.getContainingPackage(psiClass);
    ConfigurationContext context = createContext(psiClass);
    assertEquals(null, context.findExisting());
    RunnerAndConfigurationSettings testClass = context.getConfiguration();
    runManager.addConfiguration(testClass, false);
    context = createContext(psiClass);
    assertSame(testClass, context.findExisting());
    runManager.setSelectedConfiguration(testClass);
    context = createContext(psiPackage);
    assertEquals(null, context.findExisting());
    RunnerAndConfigurationSettings testPackage = context.getConfiguration();
    runManager.addConfiguration(testPackage, false);
    context = createContext(psiPackage);
    assertSame(testPackage, context.findExisting());
    assertSame(testClass, runManager.getSelectedConfiguration());
    runManager.setSelectedConfiguration(context.findExisting());
    assertSame(testPackage, runManager.getSelectedConfiguration());
}
Also used : RunManagerEx(com.intellij.execution.RunManagerEx) PsiClass(com.intellij.psi.PsiClass) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) PsiPackage(com.intellij.psi.PsiPackage)

Example 8 with RunManagerEx

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

the class RemoveExternalSystemRunConfigurationAction 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;
    int res = Messages.showYesNoDialog(project, "Delete \"" + settings.getName() + "\"?", "Confirmation", Messages.getQuestionIcon());
    if (res == Messages.YES) {
        ((RunManagerEx) RunManager.getInstance(project)).removeConfiguration(settings);
    }
}
Also used : Project(com.intellij.openapi.project.Project) RunManagerEx(com.intellij.execution.RunManagerEx) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ExternalSystemNode(com.intellij.openapi.externalSystem.view.ExternalSystemNode) RunConfigurationNode(com.intellij.openapi.externalSystem.view.RunConfigurationNode)

Example 9 with RunManagerEx

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

the class AntTargetNodeDescriptor method update.

public boolean update() {
    final CompositeAppearance oldText = myHighlightedText;
    final boolean isMeta = myTarget instanceof MetaTarget;
    setIcon(isMeta ? AntIcons.MetaTarget : AntIcons.Target);
    myHighlightedText = new CompositeAppearance();
    final AntBuildFile buildFile = isMeta ? ((MetaTarget) myTarget).getBuildFile() : myTarget.getModel().getBuildFile();
    final Color color = buildFile.isTargetVisible(myTarget) ? UIUtil.getLabelForeground() : UIUtil.getLabelDisabledForeground();
    TextAttributes nameAttributes = new TextAttributes(color, null, null, EffectType.BOXED, myTarget.isDefault() ? Font.BOLD : Font.PLAIN);
    myHighlightedText.getEnding().addText(myTarget.getDisplayName(), nameAttributes);
    AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(myProject);
    final ArrayList<String> addedNames = new ArrayList<>(4);
    for (final ExecutionEvent event : antConfiguration.getEventsForTarget(myTarget)) {
        final String presentableName;
        if ((event instanceof ExecuteCompositeTargetEvent)) {
            presentableName = ((ExecuteCompositeTargetEvent) event).getMetaTargetName();
            if (presentableName.equals(myTarget.getName())) {
                continue;
            }
        } else {
            presentableName = event.getPresentableName();
        }
        if (!addedNames.contains(presentableName)) {
            addedNames.add(presentableName);
            myHighlightedText.getEnding().addText(" (" + presentableName + ')', ourPostfixAttributes);
        }
    }
    final RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
    final VirtualFile vFile = buildFile.getVirtualFile();
    if (vFile != null) {
        for (AntBeforeRunTask task : runManager.getBeforeRunTasks(AntBeforeRunTaskProvider.ID)) {
            if (task.isRunningTarget(myTarget)) {
                myHighlightedText.getEnding().addText(" (Before Run/Debug)", ourPostfixAttributes);
                break;
            }
        }
    }
    myName = myHighlightedText.getText();
    final AntBuildTargetBase target = getTarget();
    if (!addShortcutText(target.getActionId())) {
        if (target.isDefault()) {
            addShortcutText(((AntBuildModelBase) target.getModel()).getDefaultTargetActionId());
        }
    }
    return !Comparing.equal(myHighlightedText, oldText);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RunManagerEx(com.intellij.execution.RunManagerEx) JBColor(com.intellij.ui.JBColor) MetaTarget(com.intellij.lang.ant.config.impl.MetaTarget) ArrayList(java.util.ArrayList) CompositeAppearance(com.intellij.openapi.roots.ui.util.CompositeAppearance) ExecuteCompositeTargetEvent(com.intellij.lang.ant.config.impl.ExecuteCompositeTargetEvent) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) AntBeforeRunTask(com.intellij.lang.ant.config.impl.AntBeforeRunTask)

Example 10 with RunManagerEx

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

the class GradleExecuteTaskAction method actionPerformed.

@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
    final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    ExecuteGradleTaskHistoryService historyService = ExecuteGradleTaskHistoryService.getInstance(project);
    GradleRunTaskDialog dialog = new GradleRunTaskDialog(project, historyService.getHistory());
    String lastWorkingDirectory = historyService.getWorkDirectory();
    if (lastWorkingDirectory.length() == 0) {
        lastWorkingDirectory = obtainAppropriateWorkingDirectory(e);
    }
    dialog.setWorkDirectory(lastWorkingDirectory);
    if (StringUtil.isEmptyOrSpaces(historyService.getCanceledCommand())) {
        if (historyService.getHistory().size() > 0) {
            dialog.setCommandLine(historyService.getHistory().get(0));
        }
    } else {
        dialog.setCommandLine(historyService.getCanceledCommand());
    }
    if (!dialog.showAndGet()) {
        historyService.setCanceledCommand(dialog.getCommandLine());
        return;
    }
    historyService.setCanceledCommand(null);
    String fullCommandLine = dialog.getCommandLine();
    fullCommandLine = fullCommandLine.trim();
    String workDirectory = dialog.getWorkDirectory();
    historyService.addCommand(fullCommandLine, workDirectory);
    final ExternalTaskExecutionInfo taskExecutionInfo;
    try {
        taskExecutionInfo = buildTaskInfo(workDirectory, fullCommandLine);
    } catch (CommandLineArgumentException ex) {
        final NotificationData notificationData = new NotificationData("<b>Command-line arguments cannot be parsed</b>", "<i>" + fullCommandLine + "</i> \n" + ex.getMessage(), NotificationCategory.WARNING, NotificationSource.TASK_EXECUTION);
        notificationData.setBalloonNotification(true);
        ExternalSystemNotificationManager.getInstance(project).showNotification(GradleConstants.SYSTEM_ID, notificationData);
        return;
    }
    RunManagerEx runManager = RunManagerEx.getInstanceEx(project);
    ExternalSystemUtil.runTask(taskExecutionInfo.getSettings(), taskExecutionInfo.getExecutorId(), project, GradleConstants.SYSTEM_ID);
    RunnerAndConfigurationSettings configuration = ExternalSystemUtil.createExternalSystemRunnerAndConfigurationSettings(taskExecutionInfo.getSettings(), project, GradleConstants.SYSTEM_ID);
    if (configuration == null)
        return;
    final RunnerAndConfigurationSettings existingConfiguration = runManager.findConfigurationByName(configuration.getName());
    if (existingConfiguration == null) {
        runManager.setTemporaryConfiguration(configuration);
    } else {
        runManager.setSelectedConfiguration(existingConfiguration);
    }
}
Also used : Project(com.intellij.openapi.project.Project) RunManagerEx(com.intellij.execution.RunManagerEx) ExternalTaskExecutionInfo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo) GradleRunTaskDialog(org.jetbrains.plugins.gradle.service.task.GradleRunTaskDialog) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) CommandLineArgumentException(org.gradle.cli.CommandLineArgumentException) ExecuteGradleTaskHistoryService(org.jetbrains.plugins.gradle.service.task.ExecuteGradleTaskHistoryService) NotificationData(com.intellij.openapi.externalSystem.service.notification.NotificationData)

Aggregations

RunManagerEx (com.intellij.execution.RunManagerEx)19 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)14 Project (com.intellij.openapi.project.Project)5 ConfigurationFactoryEx (com.intellij.execution.configuration.ConfigurationFactoryEx)3 ExternalTaskExecutionInfo (com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo)3 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)2 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)2 DataContext (com.intellij.openapi.actionSystem.DataContext)2 ArrayList (java.util.ArrayList)2 CfmlRunConfiguration (com.intellij.coldFusion.UI.runner.CfmlRunConfiguration)1 BeforeRunTask (com.intellij.execution.BeforeRunTask)1 RunManagerListener (com.intellij.execution.RunManagerListener)1 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)1 RunnerAndConfigurationSettingsImpl (com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl)1 AntBeforeRunTask (com.intellij.lang.ant.config.impl.AntBeforeRunTask)1 ExecuteCompositeTargetEvent (com.intellij.lang.ant.config.impl.ExecuteCompositeTargetEvent)1 MetaTarget (com.intellij.lang.ant.config.impl.MetaTarget)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 ExternalSystemTaskExecutionSettings (com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)1 AbstractExternalSystemTaskConfigurationType (com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType)1