Java Code Examples for com.intellij.execution.ui.ConsoleView#createConsoleActions()

The following examples show how to use com.intellij.execution.ui.ConsoleView#createConsoleActions() . 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: RNUtil.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void addAdditionalConsoleEditorActions(final ConsoleView console, final Content consoleContent) {
    final DefaultActionGroup consoleActions = new DefaultActionGroup();
        for (AnAction action : console.createConsoleActions()) {
            consoleActions.add(action);
        }

    consoleContent.setActions(consoleActions, ActionPlaces.RUNNER_TOOLBAR, console.getComponent());
}
 
Example 2
Source File: AnalyzeStacktraceUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: RNUtil.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static void processConsole(Project project, ProcessHandler processHandler) {
        ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();
        consoleView.clear();
        consoleView.attachToProcess(processHandler);
        processHandler.startNotify();

        ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
        ToolWindow toolWindow;
        toolWindow = toolWindowManager.getToolWindow(TOOL_ID);

        // if already exist tool window then show it
        if (toolWindow != null) {
            toolWindow.show(null);// TODO add more tabs here?
            return;
        }

        toolWindow = toolWindowManager.registerToolWindow(TOOL_ID, true, ToolWindowAnchor.BOTTOM);
        toolWindow.setTitle("Android....");
        toolWindow.setStripeTitle("Android Console");
        toolWindow.setShowStripeButton(true);
        toolWindow.setIcon(PluginIcons.ICON_TOOL_WINDOW);

        JPanel panel = new JPanel((LayoutManager) new BorderLayout());
        panel.add((Component) consoleView.getComponent(), "Center");

        // Create toolbars
        DefaultActionGroup toolbarActions = new DefaultActionGroup();
        AnAction[]
                consoleActions = consoleView.createConsoleActions();// 必须在 consoleView.getComponent() 调用后组件真正初始化之后调用
        toolbarActions.addAll((AnAction[]) Arrays.copyOf(consoleActions, consoleActions.length));
        toolbarActions.add((AnAction) new StopProcessAction("Stop process", "Stop process", processHandler));
//        toolbarActions.add((AnAction) new CloseAction(defaultExecutor, runDescriptor, project));


        ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("unknown", (ActionGroup) toolbarActions, false);
        toolbar.setTargetComponent(consoleView.getComponent());
        panel.add((Component) toolbar.getComponent(), "West");

        ContentImpl consoleContent = new ContentImpl(panel, "Build", false);
        consoleContent.setManager(toolWindow.getContentManager());

        toolbarActions.add(new CloseTabAction(consoleContent));

//        addAdditionalConsoleEditorActions(consoleView, consoleContent);
//        consoleComponent.setActions();
        toolWindow.getContentManager().addContent(consoleContent);
        toolWindow.getContentManager().addContent(new ContentImpl(new JButton("Test"), "Build2", false));
        toolWindow.show(null);
    }