Java源码示例:com.intellij.execution.ExecutionManager

示例1
@Nullable
public static FlutterApp firstFromProjectProcess(@NotNull Project project) {
  final List<RunContentDescriptor> runningProcesses =
    ExecutionManager.getInstance(project).getContentManager().getAllDescriptors();
  for (RunContentDescriptor descriptor : runningProcesses) {
    final ProcessHandler process = descriptor.getProcessHandler();
    if (process != null) {
      final FlutterApp app = FlutterApp.fromProcess(process);
      if (app != null) {
        return app;
      }
    }
  }

  return null;
}
 
示例2
@NotNull
public static List<FlutterApp> allFromProjectProcess(@NotNull Project project) {
  final List<FlutterApp> allRunningApps = new ArrayList<>();
  final List<RunContentDescriptor> runningProcesses =
    ExecutionManager.getInstance(project).getContentManager().getAllDescriptors();
  for (RunContentDescriptor descriptor : runningProcesses) {
    final ProcessHandler process = descriptor.getProcessHandler();
    if (process != null) {
      final FlutterApp app = FlutterApp.fromProcess(process);
      if (app != null) {
        allRunningApps.add(app);
      }
    }
  }

  return allRunningApps;
}
 
示例3
@Nullable
public static FlutterApp firstFromProjectProcess(@NotNull Project project) {
  final List<RunContentDescriptor> runningProcesses =
    ExecutionManager.getInstance(project).getContentManager().getAllDescriptors();
  for (RunContentDescriptor descriptor : runningProcesses) {
    final ProcessHandler process = descriptor.getProcessHandler();
    if (process != null) {
      final FlutterApp app = FlutterApp.fromProcess(process);
      if (app != null) {
        return app;
      }
    }
  }

  return null;
}
 
示例4
@NotNull
public static List<FlutterApp> allFromProjectProcess(@NotNull Project project) {
  final List<FlutterApp> allRunningApps = new ArrayList<>();
  final List<RunContentDescriptor> runningProcesses =
    ExecutionManager.getInstance(project).getContentManager().getAllDescriptors();
  for (RunContentDescriptor descriptor : runningProcesses) {
    final ProcessHandler process = descriptor.getProcessHandler();
    if (process != null) {
      final FlutterApp app = FlutterApp.fromProcess(process);
      if (app != null) {
        allRunningApps.add(app);
      }
    }
  }

  return allRunningApps;
}
 
示例5
/**
 * Stops the applications via the descriptor of configuration.  This gets called when the application finishes on the client side without maniually closing it.
 *
 * @param javaExitCode
 */
public void stopApplication(@NotNull int javaExitCode) {
    final RunManagerImpl runManager = (RunManagerImpl) RunManager.getInstance(project);
    final Collection<RunnerAndConfigurationSettings> allConfigurations = runManager.getSortedConfigurations();
    List<RunContentDescriptor> allDescriptors = ExecutionManager.getInstance(project).getContentManager().getAllDescriptors();
    boolean exitMsgDisplay = false;
    for (RunnerAndConfigurationSettings runConfiguration : allConfigurations) {
        if (runConfiguration.getConfiguration().getFactory().getType() instanceof EmbeddedLinuxJVMConfigurationType) {
            for (RunContentDescriptor descriptor : allDescriptors) {
                if (runConfiguration.getName().equals(descriptor.getDisplayName())) {
                    try {
                        if (!exitMsgDisplay) {
                            consoleView.print(EmbeddedLinuxJVMBundle.message("exit.code.message", javaExitCode), ConsoleViewContentType.SYSTEM_OUTPUT);
                            exitMsgDisplay = true;
                        }
                        descriptor.setProcessHandler(null);
                    } catch (Exception e) {

                    }
                }
            }

        }

    }
}
 
示例6
@Nonnull
private static List<RunContentDescriptor> getActiveStoppableDescriptors(final DataContext dataContext) {
  final Project project = dataContext.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return Collections.emptyList();
  }
  final List<RunContentDescriptor> runningProcesses = ExecutionManager.getInstance(project).getContentManager().getAllDescriptors();
  if (runningProcesses.isEmpty()) {
    return Collections.emptyList();
  }
  final List<RunContentDescriptor> activeDescriptors = new ArrayList<>();
  for (RunContentDescriptor descriptor : runningProcesses) {
    if (canBeStopped(descriptor)) {
      activeDescriptors.add(descriptor);
    }
  }
  return activeDescriptors;
}
 
示例7
@Nonnull
private static RunContentDescriptor createConsoleView(@Nonnull Project project, @Nonnull PsiFile psiFile) {
  ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();

  DefaultActionGroup toolbarActions = new DefaultActionGroup();
  JComponent panel = new JPanel(new BorderLayout());
  panel.add(consoleView.getComponent(), BorderLayout.CENTER);
  ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false);
  toolbar.setTargetComponent(consoleView.getComponent());
  panel.add(toolbar.getComponent(), BorderLayout.WEST);

  final RunContentDescriptor descriptor = new RunContentDescriptor(consoleView, null, panel, psiFile.getName()) {
    @Override
    public boolean isContentReuseProhibited() {
      return true;
    }
  };
  Executor executor = DefaultRunExecutor.getRunExecutorInstance();
  toolbarActions.addAll(consoleView.createConsoleActions());
  toolbarActions.add(new CloseAction(executor, descriptor, project));
  ExecutionManager.getInstance(project).getContentManager().showRunContent(executor, descriptor);

  return descriptor;
}
 
示例8
@Nullable
private RunContentManager getRunContentManager() {
  // Creating a RunContentManager causes a blank window to appear, so don't create it here.
  // See https://github.com/flutter/flutter-intellij/issues/4217
  if (ServiceManager.getServiceIfCreated(project, RunContentManager.class) == null) {
    return null;
  }
  return ExecutionManager.getInstance(project).getContentManager();
}
 
示例9
@Nullable
private RunContentManager getRunContentManager() {
  // Creating a RunContentManager causes a blank window to appear, so don't create it here.
  // See https://github.com/flutter/flutter-intellij/issues/4217
  if (ServiceManager.getServiceIfCreated(project, RunContentManager.class) == null) {
    return null;
  }
  return ExecutionManager.getInstance(project).getContentManager();
}
 
示例10
@Nullable
private ProcessHandler getHandler(@NotNull DataContext dataContext) {
    final RunContentDescriptor contentDescriptor = LangDataKeys.RUN_CONTENT_DESCRIPTOR.getData(dataContext);
    if(contentDescriptor != null) {
        // toolwindow case
        return contentDescriptor.getProcessHandler();
    } else {
        // main menu toolbar
        final Project project = CommonDataKeys.PROJECT.getData(dataContext);
        final RunContentDescriptor selectedContent =
            project == null ? null : ExecutionManager.getInstance(project).getContentManager().getSelectedContent();
        return selectedContent == null ? null : selectedContent.getProcessHandler();
    }
}
 
示例11
private boolean hasEnabledAutoTests() {
  RunContentManager contentManager = ExecutionManager.getInstance(myProject).getContentManager();
  for (RunContentDescriptor descriptor : contentManager.getAllDescriptors()) {
    if (isAutoTestEnabledForDescriptor(descriptor)) {
      return true;
    }
  }
  return false;
}
 
示例12
protected void restartAllAutoTests(int modificationStamp) {
  RunContentManager contentManager = ExecutionManager.getInstance(myProject).getContentManager();
  boolean active = false;
  for (RunContentDescriptor descriptor : contentManager.getAllDescriptors()) {
    if (isAutoTestEnabledForDescriptor(descriptor)) {
      restartAutoTest(descriptor, modificationStamp, myWatcher);
      active = true;
    }
  }
  if (!active) {
    myWatcher.deactivate();
  }
}
 
示例13
private static boolean getAction(@Nonnull AnActionEvent e, boolean execute) {
  Project project = e.getProject();
  if (project == null) {
    return false;
  }

  RunContentDescriptor contentDescriptor = ExecutionManager.getInstance(project).getContentManager().getSelectedContent();
  if (contentDescriptor == null) {
    return false;
  }

  JComponent component = contentDescriptor.getComponent();
  if (component == null) {
    return false;
  }

  ExecutionEnvironment environment = DataManager.getInstance().getDataContext(component).getData(LangDataKeys.EXECUTION_ENVIRONMENT);
  if (environment == null) {
    return false;
  }

  AnAction[] actions = contentDescriptor.getRestartActions();
  if (actions.length == 0) {
    return false;
  }

  for (AnAction action : actions) {
    if (action instanceof AbstractRerunFailedTestsAction) {
      if (execute) {
        ((AbstractRerunFailedTestsAction)action).execute(e, environment);
      }
      return true;
    }
  }
  return false;
}
 
示例14
@Override
public void actionPerformed(AnActionEvent e) {
  final RunContentDescriptor contentDescriptor = getContentDescriptor();
  if (contentDescriptor == null) {
    return;
  }
  final boolean removedOk = ExecutionManager.getInstance(myProject).getContentManager().removeRunContent(getExecutor(), contentDescriptor);
  if (removedOk) {
    myContentDescriptor = null;
    myExecutor = null;
  }
}
 
示例15
protected static void startRunProfile(ExecutionEnvironment environment,
                                      RunProfileState state,
                                      ProgramRunner.Callback callback,
                                      @javax.annotation.Nullable RunProfileStarter starter) {

  ThrowableComputable<AsyncResult<RunContentDescriptor>, ExecutionException> func = () -> {
    AsyncResult<RunContentDescriptor> promise = starter == null ? AsyncResult.done(null) : starter.executeAsync(state, environment);
    return promise.doWhenDone(it -> BaseProgramRunner.postProcess(environment, it, callback));
  };

  ExecutionManager.getInstance(environment.getProject()).startRunProfile(runProfileStarter(func), state, environment);
}
 
示例16
public void toFront(boolean focus, @Nullable final Runnable onShowCallback) {
  if (ApplicationManager.getApplication().isUnitTestMode()) return;

  ApplicationManager.getApplication().invokeLater(() -> {
    if (myRunContentDescriptor != null) {
      RunContentManager manager = ExecutionManager.getInstance(myProject).getContentManager();
      ToolWindow toolWindow = manager.getToolWindowByDescriptor(myRunContentDescriptor);
      if (toolWindow != null) {
        if (!toolWindow.isVisible()) {
          toolWindow.show(() -> {
            if (onShowCallback != null) {
              onShowCallback.run();
            }
            myRebuildWatchesRunnable.run();
          });
        }
        manager.selectRunContent(myRunContentDescriptor);
      }
    }
  });

  if (focus) {
    ApplicationManager.getApplication().invokeLater(() -> {
      boolean focusWnd = XDebuggerSettingManagerImpl.getInstanceImpl().getGeneralSettings().isMayBringFrameToFrontOnBreakpoint();
      ProjectUtil.focusProjectWindow(myProject, focusWnd);
      if (!focusWnd) {
        AppIcon.getInstance().requestAttention(myProject, true);
      }
    });
  }
}
 
示例17
public void select() {
  if (ApplicationManager.getApplication().isUnitTestMode()) return;

  UIUtil.invokeLaterIfNeeded(() -> {
    if (myRunContentDescriptor != null) {
      RunContentManager manager = ExecutionManager.getInstance(myProject).getContentManager();
      ToolWindow toolWindow = manager.getToolWindowByDescriptor(myRunContentDescriptor);
      Content content = myRunContentDescriptor.getAttachedContent();
      if (toolWindow == null || content == null) return;
      manager.selectRunContent(myRunContentDescriptor);
    }
  });
}
 
示例18
public void removeSession(@Nonnull final XDebugSessionImpl session) {
  XDebugSessionTab sessionTab = session.getSessionTab();
  mySessions.remove(session.getDebugProcess().getProcessHandler());
  if (sessionTab != null &&
      !myProject.isDisposed() &&
      !ApplicationManager.getApplication().isUnitTestMode() &&
      XDebuggerSettingManagerImpl.getInstanceImpl().getGeneralSettings().isHideDebuggerOnProcessTermination()) {
    ExecutionManager.getInstance(myProject).getContentManager().hideRunContent(DefaultDebugExecutor.getDebugExecutorInstance(), sessionTab.getRunContentDescriptor());
  }
  if (myActiveSession.compareAndSet(session, null)) {
    onActiveSessionChanged();
  }
}
 
示例19
@Nullable
static RunContentDescriptor getRecentlyStartedContentDescriptor(@Nonnull DataContext dataContext) {
  final RunContentDescriptor contentDescriptor = dataContext.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
  if (contentDescriptor != null) {
    // toolwindow case
    return contentDescriptor;
  }
  else {
    // main menu toolbar
    final Project project = dataContext.getData(CommonDataKeys.PROJECT);
    return project == null ? null : ExecutionManager.getInstance(project).getContentManager().getSelectedContent();
  }
}
 
示例20
@Nullable
protected ExecutionEnvironment getEnvironment(@Nonnull AnActionEvent event) {
  ExecutionEnvironment environment = event.getData(LangDataKeys.EXECUTION_ENVIRONMENT);
  if (environment == null) {
    Project project = event.getProject();
    RunContentDescriptor contentDescriptor = project == null ? null : ExecutionManager.getInstance(project).getContentManager().getSelectedContent();
    if (contentDescriptor != null) {
      JComponent component = contentDescriptor.getComponent();
      if (component != null) {
        environment = DataManager.getInstance().getDataContext(component).getData(LangDataKeys.EXECUTION_ENVIRONMENT);
      }
    }
  }
  return environment;
}
 
示例21
@Override
public void contentAdded(Collection<ConsoleViewContentType> types) {
  if (myProject.isDisposed() || myUi.isDisposed())
    return;
  for (ConsoleViewContentType type : types) {
    if ((type == ConsoleViewContentType.NORMAL_OUTPUT) && myRunConfigurationBase.isShowConsoleOnStdOut()
        || (type == ConsoleViewContentType.ERROR_OUTPUT) && myRunConfigurationBase.isShowConsoleOnStdErr()) {
      ExecutionManager.getInstance(myProject).getContentManager().toFrontRunContent(myExecutor, myRunContentDescriptor);
      myUi.selectAndFocus(myUi.findContent(ExecutionConsole.CONSOLE_CONTENT_ID), false, false);
      return;
    }
  }
}
 
示例22
public static RunContentDescriptor addConsole(Project project, @Nullable ConsoleFactory consoleFactory, final String tabTitle, String text, @Nullable consulo.ui.image.Image icon) {
  final TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
  builder.filters(EP_NAME.getExtensions(project));
  final ConsoleView consoleView = builder.getConsole();

  final DefaultActionGroup toolbarActions = new DefaultActionGroup();
  JComponent consoleComponent = consoleFactory != null ? consoleFactory.createConsoleComponent(consoleView, toolbarActions) : new MyConsolePanel(consoleView, toolbarActions);
  final RunContentDescriptor descriptor = new RunContentDescriptor(consoleView, null, consoleComponent, tabTitle, icon) {
    @Override
    public boolean isContentReuseProhibited() {
      return true;
    }
  };

  final Executor executor = DefaultRunExecutor.getRunExecutorInstance();
  for (AnAction action : consoleView.createConsoleActions()) {
    toolbarActions.add(action);
  }
  final ConsoleViewImpl console = (ConsoleViewImpl)consoleView;
  ConsoleViewUtil.enableReplaceActionForConsoleViewEditor(console.getEditor());
  console.getEditor().getSettings().setCaretRowShown(true);
  toolbarActions.add(new AnnotateStackTraceAction(console.getEditor(), console.getHyperlinks()));
  ExecutionManager.getInstance(project).getContentManager().showRunContent(executor, descriptor);
  consoleView.allowHeavyFilters();
  if (consoleFactory == null) {
    printStacktrace(consoleView, text);
  }
  return descriptor;
}
 
示例23
public static void showConsole(Project project, Executor defaultExecutor, @NotNull RunContentDescriptor contentDescriptor) {
    // Show in run toolwindow
    ExecutionManager.getInstance(project).getContentManager().showRunContent(defaultExecutor, contentDescriptor);
}
 
示例24
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {

    final File adb = AndroidSdkUtils.getAdb(project);
    ExecutionManager.getInstance(project).getContentManager();

    RunnerLayoutUi layoutUi = RunnerLayoutUi.Factory.getInstance(project).create("LogViewer", TOOL_WINDOW_ID, "Logview Tools", project);

    toolWindow.setIcon(LogviewerPluginIcons.TOOL_ICON);
    toolWindow.setAvailable(true, null);
    toolWindow.setToHideOnEmptyContent(true);
    toolWindow.setTitle(TOOL_WINDOW_ID);


    DeviceContext deviceContext = new DeviceContext();

    Content logcatContent = createLogcatContent(layoutUi, project, deviceContext);
    final LogView logcatView = logcatContent.getUserData(LOG_VIEW_KEY);
    layoutUi.addContent(logcatContent, 0, PlaceInGrid.center, false);

    final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), project);
    loadingPanel.add(layoutUi.getComponent(), BorderLayout.CENTER);

    final ContentManager contentManager = toolWindow.getContentManager();
    Content c = contentManager.getFactory().createContent(loadingPanel, "", true);
    c.putUserData(LOG_VIEW_KEY, logcatView);
    contentManager.addContent(c);
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            logcatView.activate();
        }
    }, project.getDisposed());


    if (adb != null) {
        loadingPanel.setLoadingText("Initializing ADB");
        loadingPanel.startLoading();

        //ListenableFuture<AndroidDebugBridge> future = AdbService.getInstance().getDebugBridge(adb);
        ListenableFuture<AndroidDebugBridge> future = AdbBridgeFactory.getAdb(adb);
        Futures.addCallback(future, new FutureCallback<AndroidDebugBridge>() {
            @Override
            public void onSuccess(@Nullable AndroidDebugBridge bridge) {
                Logger.getInstance(LogviewFactory.class).info("Successfully obtained debug bridge");
                loadingPanel.stopLoading();
            }

            @Override
            public void onFailure(@NotNull Throwable t) {
                loadingPanel.stopLoading();
                Logger.getInstance(LogviewFactory.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",
                            ApplicationNamesInfo.getInstance().getProductName(), adb.getAbsolutePath());
                }
                Messages.showErrorDialog(msg, "ADB Connection Error");
            }
        }, EdtExecutor.INSTANCE);
    } else {
        logcatView.showHint("No adb connection!.\n\nDrag and drop log files to view them.");
    }
}
 
示例25
public ExecutionChecker(ExecutionManager executionManager, String runConfigName, TestListener testListener) {
    this.executionManager = executionManager;
    this.runConfigName = runConfigName;
    this.testListener = testListener;
}
 
示例26
public void showSessionTab() {
  RunContentDescriptor descriptor = getRunContentDescriptor();
  ExecutionManager.getInstance(getProject()).getContentManager()
          .showRunContent(DefaultDebugExecutor.getDebugExecutorInstance(), descriptor);
}
 
示例27
private static void selectContent(RunContentDescriptor descriptor) {
  Executor executor = DefaultRunExecutor.getRunExecutorInstance();
  ConsoleViewImpl consoleView = ObjectUtils.assertNotNull((ConsoleViewImpl)descriptor.getExecutionConsole());
  ExecutionManager.getInstance(consoleView.getProject()).getContentManager().toFrontRunContent(executor, descriptor);
}
 
示例28
protected void showConsole(Executor defaultExecutor, @Nonnull RunContentDescriptor contentDescriptor) {
  // Show in run toolwindow
  ExecutionManager.getInstance(myProject).getContentManager().showRunContent(defaultExecutor, contentDescriptor);
}