use of com.intellij.execution.ui.ConsoleView in project android by JetBrains.
the class AndroidTestRunConfiguration method getConsoleProvider.
@NotNull
@Override
protected ConsoleProvider getConsoleProvider() {
return new ConsoleProvider() {
@NotNull
@Override
public ConsoleView createAndAttach(@NotNull Disposable parent, @NotNull ProcessHandler handler, @NotNull Executor executor) throws ExecutionException {
AndroidTestConsoleProperties properties = new AndroidTestConsoleProperties(AndroidTestRunConfiguration.this, executor);
ConsoleView consoleView = SMTestRunnerConnectionUtil.createAndAttachConsole("Android", handler, properties);
Disposer.register(parent, consoleView);
return consoleView;
}
};
}
use of com.intellij.execution.ui.ConsoleView in project android by JetBrains.
the class AndroidToolWindowFactory method createToolWindowContent.
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {
// In order to use the runner layout ui, the runner infrastructure needs to be initialized.
// Otherwise it is not possible to for example drag one of the tabs out of the tool window.
// The object that needs to be created is the content manager of the execution manager for this project.
ExecutionManager.getInstance(project).getContentManager();
RunnerLayoutUi layoutUi = RunnerLayoutUi.Factory.getInstance(project).create("Android", TOOL_WINDOW_ID, "Profiling Tools", project);
toolWindow.setIcon(AndroidIcons.AndroidToolWindow);
toolWindow.setAvailable(true, null);
toolWindow.setToHideOnEmptyContent(true);
toolWindow.setTitle(TOOL_WINDOW_ID);
DeviceContext deviceContext = new DeviceContext();
// TODO Remove global handlers. These handlers are global, but are set per project.
// if there are two projects opened, things go very wrong.
ClientData.setMethodProfilingHandler(new OpenVmTraceHandler(project));
Content logcatContent = createLogcatContent(layoutUi, project, deviceContext);
final AndroidLogcatView logcatView = logcatContent.getUserData(AndroidLogcatView.ANDROID_LOGCAT_VIEW_KEY);
assert logcatView != null;
logcatContent.setSearchComponent(logcatView.createSearchComponent());
layoutUi.addContent(logcatContent, 0, PlaceInGrid.center, false);
MonitorContentFactory.createMonitorContent(project, deviceContext, layoutUi);
layoutUi.getOptions().setLeftToolbar(getToolbarActions(project, deviceContext), ActionPlaces.UNKNOWN);
layoutUi.addListener(new ContentManagerAdapter() {
@Override
public void selectionChanged(ContentManagerEvent event) {
Content selectedContent = event.getContent();
BaseMonitorView view = selectedContent.getUserData(BaseMonitorView.MONITOR_VIEW_KEY);
if (view != null && event.getOperation() == ContentManagerEvent.ContentOperation.add) {
UsageTracker.getInstance().log(AndroidStudioEvent.newBuilder().setCategory(AndroidStudioEvent.EventCategory.PROFILING).setKind(AndroidStudioEvent.EventKind.MONITOR_RUNNING).setMonitorType(view.getMonitorType()));
}
}
}, project);
final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), project);
DevicePanel devicePanel = new DevicePanel(project, deviceContext);
JPanel panel = devicePanel.getComponent();
panel.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
loadingPanel.add(panel, BorderLayout.NORTH);
loadingPanel.add(layoutUi.getComponent(), BorderLayout.CENTER);
final ContentManager contentManager = toolWindow.getContentManager();
Content c = contentManager.getFactory().createContent(loadingPanel, "", true);
// Store references to the logcat & device panel views, so that these views can be retrieved directly from
// the DDMS tool window. (e.g. to clear logcat before a launch, select a particular device, etc)
c.putUserData(AndroidLogcatView.ANDROID_LOGCAT_VIEW_KEY, logcatView);
c.putUserData(DEVICES_PANEL_KEY, devicePanel);
contentManager.addContent(c);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
logcatView.activate();
final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID);
if (window != null && window.isVisible()) {
ConsoleView console = logcatView.getLogConsole().getConsole();
if (console != null) {
checkFacetAndSdk(project, console);
}
}
}
}, project.getDisposed());
final File adb = AndroidSdkUtils.getAdb(project);
if (adb == null) {
return;
}
loadingPanel.setLoadingText("Initializing ADB");
loadingPanel.startLoading();
ListenableFuture<AndroidDebugBridge> future = AdbService.getInstance().getDebugBridge(adb);
Futures.addCallback(future, new FutureCallback<AndroidDebugBridge>() {
@Override
public void onSuccess(@Nullable AndroidDebugBridge bridge) {
Logger.getInstance(AndroidToolWindowFactory.class).info("Successfully obtained debug bridge");
loadingPanel.stopLoading();
}
@Override
public void onFailure(@NotNull Throwable t) {
loadingPanel.stopLoading();
// If we cannot connect to ADB in a reasonable amount of time (10 seconds timeout in AdbService), then something is seriously
// wrong. The only identified reason so far is that some machines have incompatible versions of adb that were already running.
// e.g. Genymotion, some HTC flashing software, Ubuntu's adb package may all conflict with the version of adb in the SDK.
Logger.getInstance(AndroidToolWindowFactory.class).info("Unable to obtain debug bridge", t);
String msg;
if (t.getMessage() != null) {
msg = t.getMessage();
} else {
msg = String.format("Unable to establish a connection to adb.\n\n" + "Check the Event Log for possible issues.\n" + "This can happen if you have an incompatible version of adb running already.\n" + "Try re-opening %1$s after killing any existing adb daemons.\n\n" + "If this happens repeatedly, please file a bug at http://b.android.com including the following:\n" + " 1. Output of the command: '%2$s devices'\n" + " 2. Your idea.log file (Help | Show Log in Explorer)\n", ApplicationNamesInfo.getInstance().getProductName(), adb.getAbsolutePath());
}
Messages.showErrorDialog(msg, "ADB Connection Error");
}
}, EdtExecutor.INSTANCE);
}
use of com.intellij.execution.ui.ConsoleView in project intellij-plugins by JetBrains.
the class CucumberJavaRunConfiguration method getState.
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
return new JavaApplicationCommandLineState<CucumberJavaRunConfiguration>(CucumberJavaRunConfiguration.this, env) {
protected JavaParameters createJavaParameters() throws ExecutionException {
final JavaParameters params = new JavaParameters();
final JavaRunConfigurationModule module = getConfigurationModule();
final int classPathType = JavaParameters.JDK_AND_CLASSES_AND_TESTS;
final String jreHome = CucumberJavaRunConfiguration.this.ALTERNATIVE_JRE_PATH_ENABLED ? ALTERNATIVE_JRE_PATH : null;
JavaParametersUtil.configureModule(module, params, classPathType, jreHome);
JavaParametersUtil.configureConfiguration(params, CucumberJavaRunConfiguration.this);
String path = getSMRunnerPath();
params.getClassPath().add(path);
params.setMainClass(MAIN_CLASS_NAME);
for (RunConfigurationExtension ext : Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) {
ext.updateJavaParameters(CucumberJavaRunConfiguration.this, params, getRunnerSettings());
}
final String glueValue = getGlue();
if (glueValue != null && !StringUtil.isEmpty(glueValue)) {
final String[] glues = glueValue.split(" ");
for (String glue : glues) {
if (!StringUtil.isEmpty(glue)) {
params.getProgramParametersList().addParametersString(" --glue " + glue);
}
}
}
File f = new File(myFilePath);
if (!f.isDirectory()) {
f = f.getParentFile();
}
params.getVMParametersList().addParametersString("-Dorg.jetbrains.run.directory=\"" + f.getAbsolutePath() + "\"");
params.getProgramParametersList().addParametersString("\"" + myFilePath + "\"");
return params;
}
@Nullable
private ConsoleView createConsole(@NotNull final Executor executor, ProcessHandler processHandler) throws ExecutionException {
// console view
final String testFrameworkName = "cucumber";
final CucumberJavaRunConfiguration runConfiguration = CucumberJavaRunConfiguration.this;
final SMTRunnerConsoleProperties consoleProperties = new SMTRunnerConsoleProperties(runConfiguration, testFrameworkName, executor);
return SMTestRunnerConnectionUtil.createAndAttachConsole(testFrameworkName, processHandler, consoleProperties);
}
@NotNull
@Override
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
final ProcessHandler processHandler = startProcess();
final ConsoleView console = createConsole(executor, processHandler);
return new DefaultExecutionResult(console, processHandler, createActions(console, processHandler, executor));
}
};
}
use of com.intellij.execution.ui.ConsoleView in project intellij-plugins by JetBrains.
the class JstdRunProfileState method executeWithServer.
@NotNull
public ExecutionResult executeWithServer(@Nullable JstdServer ideServer) throws ExecutionException {
if (!myRunSettings.isExternalServerType() && ideServer == null) {
throw new ExecutionException("[Internal error] Local JsTestDriver server running in IDE not found");
}
ProcessHandler processHandler = createProcessHandler(ideServer);
ConsoleView consoleView = createSMTRunnerConsoleView(ideServer);
consoleView.attachToProcess(processHandler);
DefaultExecutionResult executionResult = new DefaultExecutionResult(consoleView, processHandler);
executionResult.setRestartActions(new ToggleAutoTestAction());
return executionResult;
}
use of com.intellij.execution.ui.ConsoleView in project intellij-plugins by JetBrains.
the class OutgoingCodePointerLocalMessage method createConsoleMessage.
public ConsoleMessage createConsoleMessage(User user) {
return new OwnConsoleMessage(user, StringUtil.getMsg("code.pointer"), getWhen()) {
public void printMessage(Project project, ConsoleView console) {
final IDEAFacade ideFacade = (IDEAFacade) Pico.getInstance().getComponentInstanceOfType(IDEFacade.class);
IncomingCodePointerMessage printer = new IncomingCodePointerMessage(myEvent, ideFacade);
printer.outputMessage(console);
}
};
}
Aggregations