コード例 #1
0
  public void initTerminal(final ToolWindow toolWindow) {
    LocalTerminalDirectRunner terminalRunner =
        LocalTerminalDirectRunner.createTerminalRunner(myProject);

    toolWindow.setToHideOnEmptyContent(true);

    Content content = createTerminalInContentPanel(terminalRunner, toolWindow);

    toolWindow.getContentManager().addContent(content);

    ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject))
        .addToolWindowManagerListener(
            new ToolWindowManagerListener() {
              @Override
              public void toolWindowRegistered(@NotNull String id) {}

              @Override
              public void stateChanged() {
                ToolWindow window =
                    ToolWindowManager.getInstance(myProject)
                        .getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID);
                if (window != null) {
                  boolean visible = window.isVisible();
                  if (visible && toolWindow.getContentManager().getContentCount() == 0) {
                    initTerminal(window);
                  }
                }
              }
            });

    Disposer.register(
        myProject,
        new Disposable() {
          @Override
          public void dispose() {
            if (myTerminalWidget != null) {
              myTerminalWidget.dispose();
              myTerminalWidget = null;
            }
          }
        });

    if (myDockContainer == null) {
      myDockContainer = new TerminalDockContainer(toolWindow);

      Disposer.register(myProject, myDockContainer);
      DockManager.getInstance(myProject).register(myDockContainer);
    }
  }
コード例 #2
0
 public void openLocalSession(Project project, ToolWindow terminal) {
   LocalTerminalDirectRunner terminalRunner =
       LocalTerminalDirectRunner.createTerminalRunner(project);
   openSession(terminal, terminalRunner);
 }