예제 #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
    @Override
    public void actionPerformed(AnActionEvent e) {
      myTerminal.closeCurrentSession();

      hideIfNoActiveSessions(myToolWindow, myTerminal);
    }
예제 #3
0
 private static void hideIfNoActiveSessions(
     @NotNull final ToolWindow toolWindow, @NotNull JBTabbedTerminalWidget terminal) {
   if (terminal.isNoActiveSessions()) {
     toolWindow.getContentManager().removeAllContents(true);
   }
 }
예제 #4
0
 private JComponent getComponentToFocus() {
   return myTerminalWidget != null ? myTerminalWidget.getComponent() : null;
 }