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);
});
}
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());
}
}
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());
}
Aggregations