private @Nullable GridImpl getGridFor(@NotNull Content content, boolean createIfMissing) {
    GridImpl grid = (GridImpl)findGridFor(content);
    if (grid != null || !createIfMissing) {
      return grid;
    }

    grid = new GridImpl(this, mySessionName);
    grid.setToolbarBefore(myContentToolbarBefore);

    if (myCurrentOver != null || myOriginal != null) {
      Integer forcedDropIndex = content.getUserData(RunnerLayout.DROP_INDEX);
      final int index = tabs.getDropInfoIndex() + (myOriginal != null ? myOriginal.getTabOffsetFor(this) : 0);
      final int dropIndex = forcedDropIndex != null ? forcedDropIndex : index;
      if (forcedDropIndex == null) {
        moveFollowingTabs(dropIndex);
      }

      final int defaultIndex = content.getUserData(RunnerLayout.DEFAULT_INDEX);
      final TabImpl tab = myLayoutSettings.getOrCreateTab(forcedDropIndex != null ? forcedDropIndex : -1);
      tab.setDefaultIndex(defaultIndex);
      tab.setIndex(dropIndex);
      getStateFor(content).assignTab(tab);
      content.putUserData(RunnerLayout.DROP_INDEX, null);
      content.putUserData(RunnerLayout.DEFAULT_INDEX, null);
    }

    TabInfo tab = new TabInfo(grid).setObject(getStateFor(content).getTab()).setText(ExecutionBundle.message("runner.context.tab"));

    Wrapper foreWrapper = new Wrapper();
    Wrapper leftWrapper = new Wrapper();
    Wrapper middleWrapper = new Wrapper();
    Wrapper rightWrapper = new Wrapper();
    myCommonActionsPlaceholder.put(grid, new TopToolbarWrappers(foreWrapper, leftWrapper, middleWrapper, rightWrapper));

    Wrapper minimizedToolbar = new Wrapper();
    myMinimizedButtonsPlaceholder.put(grid, minimizedToolbar);


    final Wrapper searchComponent = new Wrapper() {
      @Override
      public Dimension getPreferredSize() {
        Dimension size = super.getPreferredSize();
        if (size.height > 0) {
          size.height = JBRunnerTabs.getTabLabelPreferredHeight() - tabs.getBorderThickness();
        }
        return size;
      }
    };
    if (content.getSearchComponent() != null) {
      searchComponent.setContent(content.getSearchComponent());
    }

    TwoSideComponent right = new TwoSideComponent(searchComponent, minimizedToolbar);


    NonOpaquePanel sideComponent = new TwoSideComponent(leftWrapper, new TwoSideComponent(middleWrapper, new TwoSideComponent(right, rightWrapper)));
    sideComponent.setVisible(!tabs.isHideTopPanel());
    tab.setSideComponent(sideComponent);
    foreWrapper.setVisible(!tabs.isHideTopPanel());
    tab.setForeSideComponent(foreWrapper);

    tab.setTabLabelActions((ActionGroup)myActionManager.getAction(VIEW_TOOLBAR), TAB_TOOLBAR_PLACE);

    tabs.addTab(tab);
    tabs.sortTabs(myTabsComparator);

    return grid;
  }
private @Nullable GridImpl getGridFor(@NotNull Content content, boolean createIfMissing)