Пример #1
0
  private Content createTerminalInContentPanel(
      @NotNull AbstractTerminalRunner terminalRunner, final @NotNull ToolWindow toolWindow) {
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);

    final Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false);
    content.setCloseable(true);

    myTerminalWidget = terminalRunner.createTerminalWidget(content);
    myTerminalWidget.addTabListener(
        new TabbedTerminalWidget.TabListener() {
          @Override
          public void tabClosed(JediTermWidget terminal) {
            UIUtil.invokeLaterIfNeeded(
                () -> {
                  if (myTerminalWidget != null) {
                    hideIfNoActiveSessions(toolWindow, myTerminalWidget);
                  }
                });
          }
        });

    panel.setContent(myTerminalWidget.getComponent());
    panel.addFocusListener(createFocusListener());

    ActionToolbar toolbar = createToolbar(terminalRunner, myTerminalWidget, toolWindow);
    toolbar.getComponent().addFocusListener(createFocusListener());
    toolbar.setTargetComponent(panel);
    panel.setToolbar(toolbar.getComponent());

    content.setPreferredFocusableComponent(myTerminalWidget.getComponent());

    return content;
  }
Пример #2
0
  private void openSession(
      @NotNull ToolWindow toolWindow, @NotNull AbstractTerminalRunner terminalRunner) {
    if (myTerminalWidget == null) {
      toolWindow.getContentManager().removeAllContents(true);
      final Content content = createTerminalInContentPanel(terminalRunner, toolWindow);
      toolWindow.getContentManager().addContent(content);
    } else {
      terminalRunner.openSession(myTerminalWidget);
    }

    toolWindow.activate(() -> {}, true);
  }
Пример #3
0
 @Override
 public void actionPerformed(AnActionEvent e) {
   myTerminalRunner.openSession(myTerminal);
 }