mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-69057 print output of 'emulator' tool to execution console
This commit is contained in:
@@ -26,6 +26,8 @@ import com.android.sdklib.internal.avd.AvdManager;
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.execution.configurations.ParametersList;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.facet.Facet;
|
||||
import com.intellij.facet.FacetManager;
|
||||
import com.intellij.facet.FacetTypeId;
|
||||
@@ -319,7 +321,7 @@ public class AndroidFacet extends Facet<AndroidFacetConfiguration> {
|
||||
return myAvdManager;
|
||||
}
|
||||
|
||||
public void launchEmulator(@Nullable final String avdName, @NotNull final String commands) {
|
||||
public void launchEmulator(@Nullable final String avdName, @NotNull final String commands, @Nullable ProcessHandler handler) {
|
||||
AndroidPlatform platform = getConfiguration().getAndroidPlatform();
|
||||
if (platform != null) {
|
||||
final String emulatorPath = platform.getSdk().getLocation() + File.separator + AndroidUtils.toolPath(EMULATOR);
|
||||
@@ -335,7 +337,10 @@ public class AndroidFacet extends Facet<AndroidFacetConfiguration> {
|
||||
commandLine.addParameter(s);
|
||||
}
|
||||
}
|
||||
AndroidUtils.runExternalToolInSeparateThread(getModule().getProject(), commandLine);
|
||||
if (handler != null) {
|
||||
handler.notifyTextAvailable(commandLine.getCommandLineString() + '\n', ProcessOutputTypes.STDOUT);
|
||||
}
|
||||
AndroidUtils.runExternalToolInSeparateThread(getModule().getProject(), commandLine, handler);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ public class AndroidModuleBuilder extends JavaModuleBuilder {
|
||||
@Override
|
||||
public void run() {
|
||||
final Project project = module.getProject();
|
||||
AndroidUtils.runExternalTool(project, commandLine, true);
|
||||
AndroidUtils.runExternalTool(project, commandLine, true, null);
|
||||
|
||||
StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {
|
||||
public void run() {
|
||||
|
||||
@@ -357,14 +357,14 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
|
||||
chooseAvd();
|
||||
}
|
||||
if (myAvdName != null) {
|
||||
myFacet.launchEmulator(myAvdName, myCommandLine);
|
||||
myFacet.launchEmulator(myAvdName, myCommandLine, getProcessHandler());
|
||||
}
|
||||
else if (getProcessHandler().isStartNotified()) {
|
||||
getProcessHandler().destroyProcess();
|
||||
}
|
||||
}
|
||||
else {
|
||||
myFacet.launchEmulator(myAvdName, myCommandLine);
|
||||
myFacet.launchEmulator(myAvdName, myCommandLine, getProcessHandler());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ public class DeviceChooser extends DialogWrapper implements AndroidDebugBridge.I
|
||||
if (chooser.getExitCode() != OK_EXIT_CODE) return;
|
||||
if (avd == null) return;
|
||||
}
|
||||
myFacet.launchEmulator(avd != null ? avd.getName() : null, "");
|
||||
myFacet.launchEmulator(avd != null ? avd.getName() : null, "", null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,7 @@ import com.intellij.execution.RunManagerEx;
|
||||
import com.intellij.execution.RunnerAndConfigurationSettings;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import com.intellij.execution.impl.ConsoleViewImpl;
|
||||
import com.intellij.execution.process.OSProcessHandler;
|
||||
import com.intellij.execution.process.ProcessAdapter;
|
||||
import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.execution.process.*;
|
||||
import com.intellij.execution.ui.ConsoleView;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.facet.ProjectFacetManager;
|
||||
@@ -445,14 +443,23 @@ public class AndroidUtils {
|
||||
|
||||
public static void runExternalToolInSeparateThread(@NotNull final Project project,
|
||||
@NotNull final GeneralCommandLine commandLine) {
|
||||
runExternalToolInSeparateThread(project, commandLine, null);
|
||||
}
|
||||
|
||||
public static void runExternalToolInSeparateThread(@NotNull final Project project,
|
||||
@NotNull final GeneralCommandLine commandLine,
|
||||
@Nullable final ProcessHandler processHandler) {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
public void run() {
|
||||
runExternalTool(project, commandLine, false);
|
||||
runExternalTool(project, commandLine, false, processHandler);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void runExternalTool(final Project project, GeneralCommandLine commandLine, boolean printOutputToConsole) {
|
||||
public static void runExternalTool(final Project project,
|
||||
GeneralCommandLine commandLine,
|
||||
boolean printOutputToAndroidConsole,
|
||||
ProcessHandler processHandler) {
|
||||
String[] commands = commandLine.getCommands();
|
||||
String command = StringUtil.join(commands, " ");
|
||||
LOG.info("Execute: " + command);
|
||||
@@ -468,17 +475,22 @@ public class AndroidUtils {
|
||||
result = e.getMessage();
|
||||
}
|
||||
|
||||
if (result != null && printOutputToConsole) {
|
||||
final ConsoleViewContentType contentType = success ?
|
||||
ConsoleViewContentType.NORMAL_OUTPUT :
|
||||
ConsoleViewContentType.ERROR_OUTPUT;
|
||||
final String finalResult = result;
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
printMessageToConsole(project, finalResult, contentType);
|
||||
}
|
||||
});
|
||||
if (result != null) {
|
||||
if (printOutputToAndroidConsole) {
|
||||
final ConsoleViewContentType contentType = success ?
|
||||
ConsoleViewContentType.NORMAL_OUTPUT :
|
||||
ConsoleViewContentType.ERROR_OUTPUT;
|
||||
final String finalResult = result;
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
printMessageToConsole(project, finalResult, contentType);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (processHandler != null) {
|
||||
processHandler.notifyTextAvailable(result + '\n', ProcessOutputTypes.STDOUT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user