Search in sources :

Example 36 with ConfigurationFactory

use of com.intellij.execution.configurations.ConfigurationFactory in project azure-tools-for-java by Microsoft.

the class PushToContainerRegistryAction method runConfiguration.

@SuppressWarnings({ "deprecation", "Duplicates" })
private void runConfiguration(@NotNull Project project) {
    final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
    final ConfigurationFactory factory = configType.getPushImageRunConfigurationFactory();
    RunnerAndConfigurationSettings settings = manager.findConfigurationByName(String.format("%s: %s", factory.getName(), project.getName()));
    Observable.fromCallable(() -> {
        Registry registry = ContainerRegistryMvpModel.getInstance().getContainerRegistry(currentNode.getSubscriptionId(), currentNode.getResourceId());
        return ContainerRegistryMvpModel.getInstance().createImageSettingWithRegistry(registry);
    }).subscribeOn(SchedulerProviderFactory.getInstance().getSchedulerProvider().io()).subscribe(ret -> {
        if (settings != null) {
            PushImageRunConfiguration conf = (PushImageRunConfiguration) settings.getConfiguration();
            PrivateRegistryImageSetting imageSetting = conf.getPrivateRegistryImageSetting();
            imageSetting.setServerUrl(ret.getServerUrl());
            imageSetting.setUsername(ret.getUsername());
            imageSetting.setPassword(ret.getPassword());
            AzureTaskManager.getInstance().runLater(() -> openRunDialog(project, settings));
            return;
        }
        AzureTaskManager.getInstance().runLater(() -> openRunDialog(project, ret));
    }, err -> {
        err.printStackTrace();
        Notification notification = new Notification(NOTIFICATION_GROUP_ID, DIALOG_TITLE, err.getMessage(), NotificationType.ERROR);
        Notifications.Bus.notify(notification);
    });
}
Also used : PrivateRegistryImageSetting(com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting) RunManagerEx(com.intellij.execution.RunManagerEx) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) PushImageRunConfiguration(com.microsoft.azure.toolkit.intellij.webapp.docker.pushimage.PushImageRunConfiguration) Registry(com.microsoft.azure.management.containerregistry.Registry) Notification(com.intellij.notification.Notification)

Example 37 with ConfigurationFactory

use of com.intellij.execution.configurations.ConfigurationFactory in project azure-tools-for-java by Microsoft.

the class RunOnDockerHostAction method runConfiguration.

@SuppressWarnings({ "deprecation", "Duplicates" })
private void runConfiguration(Module module) {
    Project project = module.getProject();
    final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
    final ConfigurationFactory factory = configType.getDockerHostRunConfigurationFactory();
    RunnerAndConfigurationSettings settings = manager.findConfigurationByName(String.format("%s: %s:%s", factory.getName(), project.getName(), module.getName()));
    if (settings == null) {
        settings = manager.createConfiguration(String.format("%s: %s:%s", factory.getName(), project.getName(), module.getName()), factory);
    }
    if (RunDialog.editConfiguration(project, settings, DIALOG_TITLE, DefaultRunExecutor.getRunExecutorInstance())) {
        List<BeforeRunTask> tasks = new ArrayList<>(manager.getBeforeRunTasks(settings.getConfiguration()));
        manager.addConfiguration(settings, false, tasks, false);
        manager.setSelectedConfiguration(settings);
        ProgramRunnerUtil.executeConfiguration(project, settings, DefaultRunExecutor.getRunExecutorInstance());
    }
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) Project(com.intellij.openapi.project.Project) RunManagerEx(com.intellij.execution.RunManagerEx) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) ArrayList(java.util.ArrayList) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Example 38 with ConfigurationFactory

use of com.intellij.execution.configurations.ConfigurationFactory in project intellij by bazelbuild.

the class BlazeNativeAndroidDebugger method attachToClient.

@Override
public void attachToClient(Project project, Client client) {
    final String clientDescr = client.getClientData().getClientDescription();
    Module module = null;
    final List<AndroidFacet> facets = ProjectFacetManager.getInstance(project).getFacets(AndroidFacet.ID);
    for (AndroidFacet facet : facets) {
        try {
            final String packageName = ApkProviderUtil.computePackageName(facet);
            if (clientDescr.startsWith(packageName)) {
                module = facet.getModule();
                break;
            }
        } catch (ApkProvisionException ignored) {
        // ignored
        }
    }
    if (module == null) {
        throw new RuntimeException("Cannot find module by package name");
    }
    if (hasExistingSession(project, client)) {
        return;
    }
    // Detach any existing JDWP debug session - reusing an existing session is troublesome
    // because we need to setup a custom XDebugProcess.
    DebuggerSession debuggerSession = findJdwpDebuggerSession(project, getClientDebugPort(client));
    if (debuggerSession != null) {
        debuggerSession.getProcess().stop(false);
    }
    // Create run configuration
    // TODO: Important modification here. Make sure to keep this in refactor.
    // We need a custom BlazeAndroidNativeAttachConfiguration to skip a bunch of launch checks so
    // validate passes.
    ConfigurationFactory factory = BlazeAndroidNativeAttachConfigurationFactory.getInstance();
    String runConfigurationName = String.format("Android Native Debugger (%d)", client.getClientData().getPid());
    RunnerAndConfigurationSettings runSettings = RunManager.getInstance(project).createRunConfiguration(runConfigurationName, factory);
    AndroidNativeAttachConfiguration configuration = (AndroidNativeAttachConfiguration) runSettings.getConfiguration();
    configuration.setClient(client);
    configuration.getAndroidDebuggerContext().setDebuggerType(getId());
    configuration.getConfigurationModule().setModule(module);
    // TODO: Important modification here. Make sure to keep this in refactor.
    // We need to set the correct working dir to find sources while debugging.
    // See BlazeAndroidRunConfigurationDebuggerManager#getAndroidDebuggerState
    AndroidDebuggerState state = configuration.getAndroidDebuggerContext().getAndroidDebuggerState();
    if (state instanceof NativeAndroidDebuggerState) {
        NativeAndroidDebuggerState nativeState = (NativeAndroidDebuggerState) state;
        nativeState.setWorkingDir(WorkspaceRoot.fromProject(project).directory().getPath());
    }
    ProgramRunnerUtil.executeConfiguration(project, runSettings, DefaultDebugExecutor.getDebugExecutorInstance());
}
Also used : DebuggerSession(com.intellij.debugger.impl.DebuggerSession) ApkProvisionException(com.android.tools.idea.run.ApkProvisionException) AndroidDebuggerState(com.android.tools.idea.run.editor.AndroidDebuggerState) NativeAndroidDebuggerState(com.android.tools.ndk.run.editor.NativeAndroidDebuggerState) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) BlazeAndroidNativeAttachConfigurationFactory(com.google.idea.blaze.android.run.attach.BlazeAndroidNativeAttachConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) AndroidNativeAttachConfiguration(com.android.tools.ndk.run.attach.AndroidNativeAttachConfiguration) Module(com.intellij.openapi.module.Module) NativeAndroidDebuggerState(com.android.tools.ndk.run.editor.NativeAndroidDebuggerState) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Aggregations

ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)38 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)23 Project (com.intellij.openapi.project.Project)14 RunManagerEx (com.intellij.execution.RunManagerEx)11 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)9 BeforeRunTask (com.intellij.execution.BeforeRunTask)7 RunManagerImpl (com.intellij.execution.impl.RunManagerImpl)6 ArrayList (java.util.ArrayList)6 NotNull (org.jetbrains.annotations.NotNull)6 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)4 RemoteConfiguration (com.intellij.execution.remote.RemoteConfiguration)4 Module (com.intellij.openapi.module.Module)4 RunManager (com.intellij.execution.RunManager)3 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)3 RunnerAndConfigurationSettingsImpl (com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl)3 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)3 MakeBeforeRunTaskProvider (com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider)2 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)2 ExecutionException (com.intellij.execution.ExecutionException)2 ConfigurationFactoryEx (com.intellij.execution.configuration.ConfigurationFactoryEx)2