private void secureAddTab(ExplainTab tab) {
    SessionProperties props = _session.getProperties();

    if (s_log.isDebugEnabled()) {
      s_log.debug("secureAddTab - TabCount: " + _tabbedExecutionsPanel.getTabCount());
      s_log.debug("secureAddTab - Limited?: " + props.getLimitSQLResultTabs());
      s_log.debug("secureAddTab - TabLimit: " + props.getSqlResultTabLimit());
    }

    if (props.getLimitSQLResultTabs()
        && props.getSqlResultTabLimit() <= _tabbedExecutionsPanel.getTabCount()) {
      closeTabAt(0);
    }
    _tabbedExecutionsPanel.addTab(tab.getTitle(), null, tab, tab.getToolTip());
    _tabbedExecutionsPanel.setSelectedComponent(tab);
  }
  private void checkResultTabLimit() {
    SessionProperties props = _session.getProperties();

    while (props.getLimitSQLResultTabs()
        && props.getSqlResultTabLimit() < _tabbedExecutionsPanel.getTabCount()) {
      if (_tabbedExecutionsPanel.getComponentAt(0) instanceof CancelPanel) {
        break;
      }
      closeTabAt(0);
    }
  }