Search in sources :

Example 46 with RunnerAndConfigurationSettings

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

the class ContextConfigurationTest method testMethodInAbstractJUnit3TestCase.

public void testMethodInAbstractJUnit3TestCase() throws Exception {
    String packageName = "abstractTests";
    String shortName = "AbstractTestImpl1";
    String qualifiedName = StringUtil.getQualifiedName(packageName, shortName);
    PsiClass psiClass = findClass(getModule1(), qualifiedName);
    PsiMethod testMethod = psiClass.findMethodsByName(METHOD_NAME, true)[0];
    MapDataContext dataContext = new MapDataContext();
    dataContext.put(CommonDataKeys.PROJECT, myProject);
    if (LangDataKeys.MODULE.getData(dataContext) == null) {
        dataContext.put(LangDataKeys.MODULE, ModuleUtilCore.findModuleForPsiElement(testMethod));
    }
    dataContext.put(Location.DATA_KEY, MethodLocation.elementInClass(testMethod, psiClass));
    ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
    RunnerAndConfigurationSettings settings = context.getConfiguration();
    JUnitConfiguration configuration = (JUnitConfiguration) settings.getConfiguration();
    checkClassName(qualifiedName, configuration);
    checkMethodName(METHOD_NAME, configuration);
    checkPackage(packageName, configuration);
    checkGeneretedName(configuration, shortName + "." + METHOD_NAME);
}
Also used : MapDataContext(com.intellij.testFramework.MapDataContext) PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Example 47 with RunnerAndConfigurationSettings

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

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

the class AppletConfigurationProducer method createConfigurationByElement.

@Override
protected RunnerAndConfigurationSettings createConfigurationByElement(Location location, ConfigurationContext context) {
    location = JavaExecutionUtil.stepIntoSingleClass(location);
    if (location == null)
        return null;
    final Project project = location.getProject();
    final PsiElement element = location.getPsiElement();
    myPsiClass = getAppletClass(element, PsiManager.getInstance(project));
    if (myPsiClass == null)
        return null;
    RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(project, context);
    final AppletConfiguration configuration = (AppletConfiguration) settings.getConfiguration();
    configuration.MAIN_CLASS_NAME = JavaExecutionUtil.getRuntimeQualifiedName(myPsiClass);
    configuration.setModule(myPsiClass.isValid() ? ModuleUtilCore.findModuleForPsiElement(myPsiClass) : null);
    configuration.setGeneratedName();
    return settings;
}
Also used : Project(com.intellij.openapi.project.Project) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) PsiElement(com.intellij.psi.PsiElement)

Example 49 with RunnerAndConfigurationSettings

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

the class RubyMotionUtilExt method createMotionRunConfiguration.

public static void createMotionRunConfiguration(final Module module) {
    final Project project = module.getProject();
    final String title = RBundle.message("rails.facet.builder.run.configuration.server.creating");
    final Task task = new Task.Backgroundable(project, title, true) {

        public void run(@NotNull ProgressIndicator indicator) {
            indicator.setText(RBundle.message("progress.backgnd.indicator.title.please.wait", getTitle()));
            final RunManager runManager = RunManager.getInstance(project);
            ApplicationManager.getApplication().runReadAction(() -> {
                // requires read action
                // Rake : "simulator"
                final String taskName = RubyMotionUtil.getInstance().getMainRakeTask(module);
                final RunnerAndConfigurationSettings simulator = createAndAddRakeConfiguration(taskName, module, runManager);
                // Rake : "spec"
                createAndAddRakeConfiguration(RakeUtilBase.TASKS_SPEC_FULLCMD, module, runManager);
                // make development config active
                runManager.setSelectedConfiguration(simulator);
            });
        }
    };
    final Runnable taskRunner = () -> ProgressManager.getInstance().run(task);
    if (!project.isInitialized()) {
        StartupManager.getInstance(project).registerPostStartupActivity(taskRunner);
    } else {
        taskRunner.run();
    }
}
Also used : Project(com.intellij.openapi.project.Project) Task(com.intellij.openapi.progress.Task) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) NotNull(org.jetbrains.annotations.NotNull) RunManager(com.intellij.execution.RunManager)

Example 50 with RunnerAndConfigurationSettings

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

the class DartProjectTemplate method createWebRunConfiguration.

static void createWebRunConfiguration(@NotNull final Module module, @NotNull final VirtualFile htmlFile) {
    DartModuleBuilder.runWhenNonModalIfModuleNotDisposed(() -> {
        final WebBrowser dartium = DartiumUtil.getDartiumBrowser();
        if (dartium == null)
            return;
        final Url url = WebBrowserServiceImpl.getDebuggableUrl(PsiManager.getInstance(module.getProject()).findFile(htmlFile));
        if (url == null)
            return;
        final RunManager runManager = RunManager.getInstance(module.getProject());
        try {
            final RunnerAndConfigurationSettings settings = runManager.createRunConfiguration("", JavascriptDebugConfigurationType.getTypeInstance().getFactory());
            ((JavaScriptDebugConfiguration) settings.getConfiguration()).setUri(url.toDecodedForm());
            ((JavaScriptDebugConfiguration) settings.getConfiguration()).setEngineId(dartium.getId().toString());
            settings.setName(((JavaScriptDebugConfiguration) settings.getConfiguration()).suggestedName());
            runManager.addConfiguration(settings, false);
            runManager.setSelectedConfiguration(settings);
        } catch (Throwable t) {
        /* ClassNotFound in IDEA Community or if JS Debugger plugin disabled */
        }
    }, module);
}
Also used : WebBrowser(com.intellij.ide.browsers.WebBrowser) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) JavaScriptDebugConfiguration(com.intellij.javascript.debugger.execution.JavaScriptDebugConfiguration) RunManager(com.intellij.execution.RunManager) Url(com.intellij.util.Url)

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