use of com.intellij.execution.configurations.ConfigurationFactory in project intellij-community by JetBrains.
the class PyCommandLineTestCase method createConfiguration.
protected <T extends AbstractPythonRunConfiguration> T createConfiguration(final ConfigurationType configurationType, Class<T> cls) {
final ConfigurationFactory factory = configurationType.getConfigurationFactories()[0];
final Project project = myFixture.getProject();
return cls.cast(factory.createTemplateConfiguration(project));
}
use of com.intellij.execution.configurations.ConfigurationFactory in project intellij-community by JetBrains.
the class PyDebuggerTask method runTestOn.
public void runTestOn(String sdkHome) throws Exception {
final Project project = getProject();
final ConfigurationFactory factory = PythonConfigurationType.getInstance().getConfigurationFactories()[0];
final RunnerAndConfigurationSettings settings = RunManager.getInstance(project).createRunConfiguration("test", factory);
myRunConfiguration = (PythonRunConfiguration) settings.getConfiguration();
myRunConfiguration.setSdkHome(sdkHome);
myRunConfiguration.setScriptName(getScriptName());
myRunConfiguration.setWorkingDirectory(myFixture.getTempDirPath());
myRunConfiguration.setScriptParameters(getScriptParameters());
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
RunManagerEx.getInstanceEx(project).addConfiguration(settings, false);
RunManagerEx.getInstanceEx(project).setSelectedConfiguration(settings);
Assert.assertSame(settings, RunManagerEx.getInstanceEx(project).getSelectedConfiguration());
}
}.execute();
final PyDebugRunner runner = (PyDebugRunner) ProgramRunnerUtil.getRunner(getExecutorId(), settings);
Assert.assertTrue(runner.canRun(getExecutorId(), myRunConfiguration));
final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();
final ExecutionEnvironment env = new ExecutionEnvironment(executor, runner, settings, project);
final PythonCommandLineState pyState = (PythonCommandLineState) myRunConfiguration.getState(executor, env);
assert pyState != null;
pyState.setMultiprocessDebug(isMultiprocessDebug());
final ServerSocket serverSocket;
try {
//noinspection SocketOpenedButNotSafelyClosed
serverSocket = new ServerSocket(0);
} catch (IOException e) {
throw new ExecutionException("Failed to find free socket port", e);
}
final int serverLocalPort = serverSocket.getLocalPort();
final RunProfile profile = env.getRunProfile();
//turn off exception breakpoints by default
PythonDebuggerTest.createExceptionBreak(myFixture, false, false, false);
before();
setProcessCanTerminate(false);
myTerminateSemaphore = new Semaphore(0);
new WriteAction<ExecutionResult>() {
@Override
protected void run(@NotNull Result<ExecutionResult> result) throws Throwable {
myExecutionResult = pyState.execute(executor, runner.createCommandLinePatchers(myFixture.getProject(), pyState, profile, serverLocalPort));
mySession = XDebuggerManager.getInstance(getProject()).startSession(env, new XDebugProcessStarter() {
@NotNull
public XDebugProcess start(@NotNull final XDebugSession session) {
myDebugProcess = new PyDebugProcess(session, serverSocket, myExecutionResult.getExecutionConsole(), myExecutionResult.getProcessHandler(), isMultiprocessDebug());
StringBuilder output = new StringBuilder();
myDebugProcess.getProcessHandler().addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
output.append(event.getText());
}
@Override
public void processTerminated(ProcessEvent event) {
myTerminateSemaphore.release();
if (event.getExitCode() != 0 && !myProcessCanTerminate) {
Assert.fail("Process terminated unexpectedly\n" + output.toString());
}
}
});
myDebugProcess.getProcessHandler().startNotify();
return myDebugProcess;
}
});
result.setResult(myExecutionResult);
}
}.execute().getResultObject();
OutputPrinter myOutputPrinter = null;
if (shouldPrintOutput) {
myOutputPrinter = new OutputPrinter();
myOutputPrinter.start();
}
myPausedSemaphore = new Semaphore(0);
mySession.addSessionListener(new XDebugSessionListener() {
@Override
public void sessionPaused() {
if (myPausedSemaphore != null) {
myPausedSemaphore.release();
}
}
});
doTest(myOutputPrinter);
}
use of com.intellij.execution.configurations.ConfigurationFactory 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);
}
}
use of com.intellij.execution.configurations.ConfigurationFactory in project intellij-community by JetBrains.
the class BaseExecuteBeforeRunDialog method doOKAction.
@Override
protected void doOKAction() {
final RunManagerImpl runManager = (RunManagerImpl) RunManagerEx.getInstanceEx(myProject);
for (Enumeration nodes = myRoot.depthFirstEnumeration(); nodes.hasMoreElements(); ) {
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) nodes.nextElement();
final Descriptor descriptor = (Descriptor) node.getUserObject();
final boolean isChecked = descriptor.isChecked();
if (descriptor instanceof ConfigurationTypeDescriptor) {
ConfigurationTypeDescriptor typeDesc = (ConfigurationTypeDescriptor) descriptor;
for (ConfigurationFactory factory : typeDesc.getConfigurationType().getConfigurationFactories()) {
RunnerAndConfigurationSettings settings = runManager.getConfigurationTemplate(factory);
update(settings.getConfiguration(), isChecked, runManager);
}
} else if (descriptor instanceof ConfigurationDescriptor) {
ConfigurationDescriptor configDesc = (ConfigurationDescriptor) descriptor;
update(configDesc.getConfiguration(), isChecked, runManager);
}
}
RunManagerImpl.getInstanceImpl(myProject).fireBeforeRunTasksUpdated();
close(OK_EXIT_CODE);
}
use of com.intellij.execution.configurations.ConfigurationFactory in project intellij-community by JetBrains.
the class ProjectStartupConfigurable method createNewWrapper.
private ChooseRunConfigurationPopup.ItemWrapper<Void> createNewWrapper(final AnActionButton button) {
return new ChooseRunConfigurationPopup.ItemWrapper<Void>(null) {
@Override
public Icon getIcon() {
return IconUtil.getAddIcon();
}
@Override
public String getText() {
return UIUtil.removeMnemonic(ExecutionBundle.message("add.new.run.configuration.acrtion.name"));
}
@Override
public void perform(@NotNull final Project project, @NotNull final Executor executor, @NotNull DataContext context) {
final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
final ConfigurationType[] factories = runManager.getConfigurationFactories();
final Condition<ConfigurationType> filter = new Condition<ConfigurationType>() {
private final RunnerRegistry myRegistry = RunnerRegistry.getInstance();
@Override
public boolean value(ConfigurationType configurationType) {
ConfigurationFactory factory;
return !UnknownConfigurationType.INSTANCE.equals(configurationType) && ((factory = runManager.getFactory(configurationType.getId(), null)) != null) && myRegistry.getRunner(executor.getId(), runManager.getConfigurationTemplate(factory).getConfiguration()) != null;
}
};
final List<ConfigurationType> factoriesList = ContainerUtil.filter(Arrays.asList(factories), filter);
final ListPopup popup = NewRunConfigurationPopup.createAddPopup(factoriesList, "", factory -> ApplicationManager.getApplication().invokeLater(() -> {
final EditConfigurationsDialog dialog = new EditConfigurationsDialog(project, factory);
if (dialog.showAndGet()) {
ApplicationManager.getApplication().invokeLater(() -> {
RunnerAndConfigurationSettings configuration = RunManager.getInstance(project).getSelectedConfiguration();
if (configuration != null) {
addConfiguration(configuration);
}
}, ModalityState.any(), project.getDisposed());
}
}, ModalityState.any(), project.getDisposed()), null, EmptyRunnable.getInstance(), false);
showPopup(button, popup);
}
@Override
public boolean available(Executor executor) {
return true;
}
};
}
Aggregations