use of com.intellij.execution.ui.RunContentDescriptor in project android by JetBrains.
the class RestartActivityAction method findDevices.
/**
* Finds the devices associated with all run configurations for the given project
*/
@NotNull
private static List<IDevice> findDevices(@Nullable Project project) {
if (project == null) {
return Collections.emptyList();
}
List<RunContentDescriptor> runningProcesses = ExecutionManager.getInstance(project).getContentManager().getAllDescriptors();
if (runningProcesses.isEmpty()) {
return Collections.emptyList();
}
List<IDevice> devices = Lists.newArrayList();
for (RunContentDescriptor descriptor : runningProcesses) {
ProcessHandler processHandler = descriptor.getProcessHandler();
if (processHandler == null || processHandler.isProcessTerminated() || processHandler.isProcessTerminating()) {
continue;
}
devices.addAll(getConnectedDevices(processHandler));
}
return devices;
}
use of com.intellij.execution.ui.RunContentDescriptor in project android by JetBrains.
the class AndroidProgramRunner method doExecute.
@Override
protected RunContentDescriptor doExecute(@NotNull final RunProfileState state, @NotNull final ExecutionEnvironment env) throws ExecutionException {
boolean showRunContent = env.getRunProfile() instanceof AndroidTestRunConfiguration;
RunnerAndConfigurationSettings runnerAndConfigurationSettings = env.getRunnerAndConfigurationSettings();
if (runnerAndConfigurationSettings != null) {
runnerAndConfigurationSettings.setActivateToolWindowBeforeRun(showRunContent);
}
RunContentDescriptor descriptor = super.doExecute(state, env);
if (descriptor != null) {
ProcessHandler processHandler = descriptor.getProcessHandler();
assert processHandler != null;
RunProfile runProfile = env.getRunProfile();
int uniqueId = runProfile instanceof RunConfigurationBase ? ((RunConfigurationBase) runProfile).getUniqueID() : -1;
AndroidSessionInfo sessionInfo = new AndroidSessionInfo(processHandler, descriptor, uniqueId, env.getExecutor().getId(), InstantRunUtils.isInstantRunEnabled(env));
processHandler.putUserData(AndroidSessionInfo.KEY, sessionInfo);
}
return descriptor;
}
use of com.intellij.execution.ui.RunContentDescriptor in project android by JetBrains.
the class AndroidJavaDebugger method hasExistingDebugSession.
private static boolean hasExistingDebugSession(@NotNull Project project, @NotNull final String debugPort, @NotNull final String runConfigName) {
Collection<RunContentDescriptor> descriptors = null;
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
Project targetProject = null;
// Scan through open project to find if this port has been opened in any session.
for (Project openProject : openProjects) {
targetProject = openProject;
// First check the titles of the run configurations.
descriptors = ExecutionHelper.findRunningConsoleByTitle(targetProject, new NotNullFunction<String, Boolean>() {
@NotNull
@Override
public Boolean fun(String title) {
return runConfigName.equals(title);
}
});
// If it can't find a matching title, check the debugger sessions.
if (descriptors.isEmpty()) {
DebuggerSession debuggerSession = findJdwpDebuggerSession(targetProject, debugPort);
if (debuggerSession != null) {
XDebugSession session = debuggerSession.getXDebugSession();
if (session != null) {
descriptors = Collections.singletonList(session.getRunContentDescriptor());
} else {
// Detach existing session.
debuggerSession.getProcess().stop(false);
}
}
}
if (!descriptors.isEmpty()) {
break;
}
}
if (descriptors != null && !descriptors.isEmpty()) {
return activateDebugSessionWindow(project, descriptors.iterator().next());
}
return false;
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-plugins by JetBrains.
the class JstdCoverageProgramRunner method start.
@Nullable
private static RunContentDescriptor start(@Nullable JstdServer server, @NotNull ExecutionEnvironment environment) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
JstdRunConfiguration runConfiguration = (JstdRunConfiguration) environment.getRunProfile();
CoverageEnabledConfiguration coverageEnabledConfiguration = CoverageEnabledConfiguration.getOrCreate(runConfiguration);
String coverageFilePath = coverageEnabledConfiguration.getCoverageFilePath();
JstdRunProfileState jstdState = new JstdRunProfileState(environment, runConfiguration.getRunSettings(), coverageFilePath);
ExecutionResult executionResult = jstdState.executeWithServer(server);
RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, environment);
final RunContentDescriptor descriptor = contentBuilder.showRunContent(environment.getContentToReuse());
ProcessHandler processHandler = executionResult.getProcessHandler();
if (processHandler instanceof NopProcessHandler) {
if (server != null) {
server.addLifeCycleListener(new JstdServerLifeCycleAdapter() {
@Override
public void onBrowserCaptured(@NotNull JstdBrowserInfo info) {
ExecutionUtil.restartIfActive(descriptor);
server.removeLifeCycleListener(this);
}
}, contentBuilder);
}
} else {
CoverageHelper.attachToProcess(runConfiguration, processHandler, environment.getRunnerSettings());
}
return descriptor;
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-plugins by JetBrains.
the class JstdRunProgramRunner method start.
public static RunContentDescriptor start(@Nullable JstdServer server, boolean fromDebug, @NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
JstdRunProfileState jstdState = JstdRunProfileState.cast(state);
ExecutionResult executionResult = jstdState.executeWithServer(server);
RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, environment);
final RunContentDescriptor descriptor = contentBuilder.showRunContent(environment.getContentToReuse());
if (server != null && executionResult.getProcessHandler() instanceof NopProcessHandler) {
server.addLifeCycleListener(new JstdServerLifeCycleAdapter() {
@Override
public void onBrowserCaptured(@NotNull JstdBrowserInfo info) {
if (fromDebug) {
final Alarm alarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, descriptor);
alarm.addRequest(() -> ExecutionUtil.restartIfActive(descriptor), 1000);
} else {
ExecutionUtil.restartIfActive(descriptor);
}
server.removeLifeCycleListener(this);
}
}, contentBuilder);
}
return descriptor;
}
Aggregations