com.intellij.execution.process.ProcessListener Java Examples

The following examples show how to use com.intellij.execution.process.ProcessListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlutterModuleBuilder.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Runs flutter create without showing a console, but with an indeterminate progress dialog.
 * <p>
 * Returns the PubRoot if successful.
 */
@Nullable
public static PubRoot runFlutterCreateWithProgress(@NotNull VirtualFile baseDir,
                                                   @NotNull FlutterSdk sdk,
                                                   @NotNull Project project,
                                                   @Nullable ProcessListener processListener,
                                                   @Nullable FlutterCreateAdditionalSettings additionalSettings) {
  final ProgressManager progress = ProgressManager.getInstance();
  final AtomicReference<PubRoot> result = new AtomicReference<>(null);

  FlutterUtils.disableGradleProjectMigrationNotification(project);

  progress.runProcessWithProgressSynchronously(() -> {
    progress.getProgressIndicator().setIndeterminate(true);
    result.set(sdk.createFiles(baseDir, null, processListener, additionalSettings));
  }, "Creating Flutter Project", false, project);

  return result.get();
}
 
Example #2
Source File: FlutterModuleBuilder.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Runs flutter create without showing a console, but with an indeterminate progress dialog.
 * <p>
 * Returns the PubRoot if successful.
 */
@Nullable
public static PubRoot runFlutterCreateWithProgress(@NotNull VirtualFile baseDir,
                                                   @NotNull FlutterSdk sdk,
                                                   @NotNull Project project,
                                                   @Nullable ProcessListener processListener,
                                                   @Nullable FlutterCreateAdditionalSettings additionalSettings) {
  final ProgressManager progress = ProgressManager.getInstance();
  final AtomicReference<PubRoot> result = new AtomicReference<>(null);

  FlutterUtils.disableGradleProjectMigrationNotification(project);

  progress.runProcessWithProgressSynchronously(() -> {
    progress.getProgressIndicator().setIndeterminate(true);
    result.set(sdk.createFiles(baseDir, null, processListener, additionalSettings));
  }, "Creating Flutter Project", false, project);

  return result.get();
}
 
Example #3
Source File: ScopedBlazeProcessHandler.java    From intellij with Apache License 2.0 6 votes vote down vote up
public ScopedBlazeProcessHandler(
    Project project,
    List<String> command,
    WorkspaceRoot workspaceRoot,
    ScopedProcessHandlerDelegate scopedProcessHandlerDelegate)
    throws ExecutionException {
  super(
      ProcessGroupUtil.newProcessGroupFor(
          new GeneralCommandLine(command)
              .withWorkDirectory(workspaceRoot.directory().getPath())
              .withRedirectErrorStream(true)));

  this.scopedProcessHandlerDelegate = scopedProcessHandlerDelegate;
  this.context = new BlazeContext();
  // The context is released in the ScopedProcessHandlerListener.
  this.context.hold();

  for (ProcessListener processListener :
      scopedProcessHandlerDelegate.createProcessListeners(context)) {
    addProcessListener(processListener);
  }
  addProcessListener(new ScopedProcessHandlerListener(project));
}
 
Example #4
Source File: AbstractAutoTestManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void clearRestarterListener(@Nonnull ProcessHandler processHandler) {
  ProcessListener restarterListener = ON_TERMINATION_RESTARTER_KEY.get(processHandler, null);
  if (restarterListener != null) {
    processHandler.removeProcessListener(restarterListener);
    ON_TERMINATION_RESTARTER_KEY.set(processHandler, null);
  }
}
 
Example #5
Source File: ToolAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * @return <code>true</code> if task has been started successfully
 */
static boolean runTool(String actionId, DataContext context, @Nullable AnActionEvent e, long executionId, @Nullable ProcessListener processListener) {
  Tool tool = findTool(actionId, context);
  if (tool != null) {
    return tool.execute(e, new HackyDataContext(context, e), executionId, processListener);
  }
  return false;
}
 
Example #6
Source File: ScopedBlazeProcessHandler.java    From intellij with Apache License 2.0 4 votes vote down vote up
/** Get a list of process listeners to add to the process. */
ImmutableList<ProcessListener> createProcessListeners(BlazeContext context);
 
Example #7
Source File: ExecutionMode.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void addProcessListener(@Nonnull final ProcessListener listener) {
  myListeners.add(listener);
}
 
Example #8
Source File: ExecutionMode.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public List<ProcessListener> getProcessListeners() {
  return myListeners;
}
 
Example #9
Source File: Tool.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * @return <code>true</code> if task has been started successfully
 */
public boolean execute(AnActionEvent event, DataContext dataContext, long executionId, @Nullable final ProcessListener processListener) {
  final Project project = dataContext.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return false;
  }
  FileDocumentManager.getInstance().saveAllDocuments();
  try {
    if (isUseConsole()) {
      final ToolRunProfile profile = new ToolRunProfile(this, dataContext);
      final ProgramRunner runner = RunnerRegistry.getInstance().getRunner(DefaultRunExecutor.EXECUTOR_ID, profile);
      assert runner != null;

      ExecutionEnvironment executionEnvironment = new ExecutionEnvironmentBuilder(project, DefaultRunExecutor.getRunExecutorInstance())
        .runProfile(profile)
        .build();
      executionEnvironment.setExecutionId(executionId);
      runner.execute(executionEnvironment, new ProgramRunner.Callback() {
        @Override
        public void processStarted(RunContentDescriptor descriptor) {
          ProcessHandler processHandler = descriptor.getProcessHandler();
          if (processHandler != null && processListener != null) {
            processHandler.addProcessListener(processListener);
          }
        }
      });
      return true;
    }
    else {
      GeneralCommandLine commandLine = createCommandLine(dataContext);
      if (commandLine == null) {
        return false;
      }
      OSProcessHandler handler = new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString());
      handler.addProcessListener(new ToolProcessAdapter(project, synchronizeAfterExecution(), getName()));
      if (processListener != null) {
        handler.addProcessListener(processListener);
      }
      handler.startNotify();
      return true;
    }
  }
  catch (ExecutionException ex) {
    ExecutionErrorDialog.show(ex, ToolsBundle.message("tools.process.start.error"), project);
  }
  return false;
}