Search in sources :

Example 6 with ModuleBasedConfiguration

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

the class TemplateModuleBuilder method fixModuleName.

private void fixModuleName(Module module) {
    List<RunConfiguration> configurations = RunManager.getInstance(module.getProject()).getAllConfigurationsList();
    for (RunConfiguration configuration : configurations) {
        if (configuration instanceof ModuleBasedConfiguration) {
            ((ModuleBasedConfiguration) configuration).getConfigurationModule().setModule(module);
        }
    }
    ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
    for (WizardInputField field : myAdditionalFields) {
        ProjectTemplateParameterFactory factory = WizardInputField.getFactoryById(field.getId());
        factory.applyResult(field.getValue(), model);
    }
    model.commit();
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ModuleBasedConfiguration(com.intellij.execution.configurations.ModuleBasedConfiguration)

Example 7 with ModuleBasedConfiguration

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

the class PyRunConfigurationFactoryImpl method createConfigurationSettings.

private static RunnerAndConfigurationSettings createConfigurationSettings(ConfigurationFactory factory, @NotNull final Module module) {
    final RunnerAndConfigurationSettings settings = RunManager.getInstance(module.getProject()).createRunConfiguration(module.getName(), factory);
    ModuleBasedConfiguration configuration = (ModuleBasedConfiguration) settings.getConfiguration();
    configuration.setModule(module);
    return settings;
}
Also used : RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ModuleBasedConfiguration(com.intellij.execution.configurations.ModuleBasedConfiguration)

Example 8 with ModuleBasedConfiguration

use of com.intellij.execution.configurations.ModuleBasedConfiguration in project android by JetBrains.

the class HotswapAction method doUpdate.

@Override
protected void doUpdate(@NotNull AnActionEvent e, @NotNull Project project) {
    Presentation presentation = e.getPresentation();
    presentation.setEnabled(false);
    if (!InstantRunSettings.isInstantRunEnabled()) {
        presentation.setText("Apply Changes: Instant Run has been disabled");
        return;
    }
    RunnerAndConfigurationSettings settings = RunManager.getInstance(project).getSelectedConfiguration();
    if (settings == null) {
        presentation.setText("Apply Changes: No run configuration selected");
        return;
    }
    AndroidSessionInfo session = getAndroidSessionInfo(project, settings);
    if (session == null) {
        presentation.setText(String.format("Apply Changes: No active '%1$s' launch", settings.getName()));
        return;
    }
    ProcessHandler processHandler = getActiveProcessHandler(project, settings);
    if (processHandler == null) {
        presentation.setText(String.format("Apply Changes: No active '%1$s' launch", settings.getName()));
        return;
    }
    RunConfiguration configuration = settings.getConfiguration();
    if (!(configuration instanceof ModuleBasedConfiguration)) {
        presentation.setText(String.format("Apply Changes: '%1$s' is not a module based configuration", settings.getName()));
        return;
    }
    Module module = ((ModuleBasedConfiguration) configuration).getConfigurationModule().getModule();
    if (module == null) {
        presentation.setText(String.format("Apply Changes: No module specified in '%1$s'", settings.getName()));
        return;
    }
    if (!(configuration instanceof AndroidRunConfigurationBase)) {
        presentation.setText(String.format("Apply Changes: '%1$s' is not an Android launch configuration", settings.getName()));
        return;
    }
    if (!((AndroidRunConfigurationBase) configuration).supportsInstantRun()) {
        presentation.setText(String.format("Apply Changes: Configuration '%1$s' does not support instant run", settings.getName()));
        return;
    }
    AndroidVersion androidVersion = InstantRunManager.getMinDeviceApiLevel(processHandler);
    if (androidVersion == null) {
        presentation.setText(String.format("Apply Changes: Cannot locate device from '%1$s'", settings.getName()));
        return;
    }
    if (!InstantRunManager.isInstantRunCapableDeviceVersion(androidVersion)) {
        presentation.setText(String.format("Apply Changes: Target device API level (%1$s) too low for Instant Run", androidVersion));
        return;
    }
    InstantRunGradleSupport status = InstantRunGradleUtils.getIrSupportStatus(InstantRunGradleUtils.getAppModel(module), androidVersion);
    if (status != SUPPORTED) {
        String notification = status.getUserNotification();
        if (notification == null) {
            notification = status.toString();
        }
        presentation.setText("Apply Changes: " + notification);
        return;
    }
    presentation.setText("Apply Changes" + getShortcutText());
    presentation.setEnabled(true);
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) AndroidRunConfigurationBase(com.android.tools.idea.run.AndroidRunConfigurationBase) AndroidSessionInfo(com.android.tools.idea.run.AndroidSessionInfo) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ProcessHandler(com.intellij.execution.process.ProcessHandler) InstantRunGradleSupport(com.android.tools.idea.fd.gradle.InstantRunGradleSupport) Presentation(com.intellij.openapi.actionSystem.Presentation) ModuleBasedConfiguration(com.intellij.execution.configurations.ModuleBasedConfiguration) Module(com.intellij.openapi.module.Module) AndroidVersion(com.android.sdklib.AndroidVersion)

Aggregations

ModuleBasedConfiguration (com.intellij.execution.configurations.ModuleBasedConfiguration)8 Module (com.intellij.openapi.module.Module)5 Project (com.intellij.openapi.project.Project)4 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 CommonJavaRunConfigurationParameters (com.intellij.execution.CommonJavaRunConfigurationParameters)2 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2 AndroidVersion (com.android.sdklib.AndroidVersion)1 InstantRunGradleSupport (com.android.tools.idea.fd.gradle.InstantRunGradleSupport)1 AndroidRunConfigurationBase (com.android.tools.idea.run.AndroidRunConfigurationBase)1 AndroidSessionInfo (com.android.tools.idea.run.AndroidSessionInfo)1 BaseCoverageSuite (com.intellij.coverage.BaseCoverageSuite)1 CoverageRunner (com.intellij.coverage.CoverageRunner)1 ExecutionException (com.intellij.execution.ExecutionException)1 Executor (com.intellij.execution.Executor)1 JavaRunConfigurationModule (com.intellij.execution.configurations.JavaRunConfigurationModule)1 RunConfigurationBase (com.intellij.execution.configurations.RunConfigurationBase)1 RunProfile (com.intellij.execution.configurations.RunProfile)1 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)1 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1