use of com.intellij.execution.ui.RunContentDescriptor in project intellij-plugins by JetBrains.
the class AdlUtil method runDebugger.
// http://kb2.adobe.com/cps/407/kb407625.html
public static void runDebugger(final Module module, final Runnable postTask) throws ExecutionException {
final Project project = module.getProject();
final RunnerAndConfigurationSettings settings = RunManager.getInstance(project).createConfiguration("FlashUIDesigner", RemoteFlashRunConfigurationType.getFactory());
final RemoteFlashRunConfiguration configuration = (RemoteFlashRunConfiguration) settings.getConfiguration();
RunManagerEx.disableTasks(project, settings.getConfiguration(), CompileStepBeforeRun.ID, CompileStepBeforeRunNoErrorCheck.ID);
final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();
ProgramRunner.Callback callback = new ProgramRunner.Callback() {
@Override
public void processStarted(final RunContentDescriptor descriptor) {
final ProcessHandler processHandler = descriptor.getProcessHandler();
assert processHandler != null;
DesignerApplication application = DesignerApplicationManager.getApplication();
if (application != null) {
Disposer.register(application, new Disposable() {
@Override
public void dispose() {
if (!project.isDisposed()) {
ApplicationManager.getApplication().invokeLater(() -> ExecutionManager.getInstance(project).getContentManager().removeRunContent(executor, descriptor));
}
processHandler.destroyProcess();
}
});
postTask.run();
}
}
};
FlexBuildConfiguration buildConfiguration = FlexBuildConfigurationManager.getInstance(module).getActiveConfiguration();
configuration.getRunnerParameters().setModuleName(module.getName());
configuration.getRunnerParameters().setBCName(buildConfiguration.getName());
final FlexRunner runner = new FlexRunner(callback, buildConfiguration);
runner.execute(new ExecutionEnvironment(executor, runner, settings, project));
}
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 KarmaDebugProgramRunner method execute.
@NotNull
@Override
protected Promise<RunContentDescriptor> execute(@NotNull ExecutionEnvironment environment, @NotNull RunProfileState state) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
ExecutionResult executionResult = state.execute(environment.getExecutor(), this);
if (executionResult == null) {
return Promise.resolve(null);
}
KarmaConsoleView consoleView = KarmaConsoleView.get(executionResult, state);
if (consoleView == null) {
return Promise.resolve(KarmaUtil.createDefaultDescriptor(executionResult, environment));
}
KarmaServer karmaServer = consoleView.getKarmaExecutionSession().getKarmaServer();
if (karmaServer.areBrowsersReady()) {
KarmaDebugBrowserSelector browserSelector = new KarmaDebugBrowserSelector(karmaServer.getCapturedBrowsers(), environment, consoleView);
DebuggableWebBrowser debuggableWebBrowser = browserSelector.selectDebugEngine();
if (debuggableWebBrowser == null) {
return Promises.resolvedPromise(KarmaUtil.createDefaultDescriptor(executionResult, environment));
}
return KarmaKt.prepareKarmaDebugger(environment.getProject(), debuggableWebBrowser, () -> createDescriptor(environment, executionResult, consoleView, karmaServer, debuggableWebBrowser));
} else {
RunContentDescriptor descriptor = KarmaUtil.createDefaultDescriptor(executionResult, environment);
karmaServer.onBrowsersReady(() -> ExecutionUtil.restartIfActive(descriptor));
return Promises.resolvedPromise(descriptor);
}
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-plugins by JetBrains.
the class KarmaCoverageProgramRunner method doExecute.
@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull final ExecutionEnvironment env) throws ExecutionException {
FileDocumentManager.getInstance().saveAllDocuments();
ExecutionResult executionResult = state.execute(env.getExecutor(), this);
if (executionResult == null) {
return null;
}
RunContentDescriptor descriptor = KarmaUtil.createDefaultDescriptor(executionResult, env);
KarmaConsoleView consoleView = KarmaConsoleView.get(executionResult, state);
if (consoleView == null) {
return descriptor;
}
KarmaServer server = consoleView.getKarmaExecutionSession().getKarmaServer();
if (server.areBrowsersReady()) {
listenForCoverageFile(env, server);
} else {
server.onBrowsersReady(() -> ExecutionUtil.restartIfActive(descriptor));
}
return descriptor;
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-leiningen-plugin by derkork.
the class LeiningenRunConfigurationType method runConfiguration.
public static void runConfiguration(Project project, LeiningenRunnerParameters params, DataContext context) {
RunnerAndConfigurationSettings configSettings = createRunnerAndConfigurationSettings(params, project);
ProgramRunner runner = RunnerRegistry.getInstance().findRunnerById(DefaultRunExecutor.EXECUTOR_ID);
Executor executor = DefaultRunExecutor.getRunExecutorInstance();
ExecutionEnvironment env = new ExecutionEnvironment(executor, runner, configSettings, project);
try {
runner.execute(env, new ProgramRunner.Callback() {
public void processStarted(RunContentDescriptor runContentDescriptor) {
final ProcessHandler runContentDescriptorProcessHandler = runContentDescriptor.getProcessHandler();
if (runContentDescriptorProcessHandler != null) {
runContentDescriptorProcessHandler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
LocalFileSystem.getInstance().refreshWithoutFileWatcher(true);
}
});
}
}
});
} catch (ExecutionException e) {
}
}
Aggregations