/*
   * (non-Javadoc)
   *
   * @see com.intel.stl.ui.console.IConsoleEventListener#onConnect(boolean,
   * String)
   */
  @Override
  public void onConnect(boolean connected, String command) {

    if (connected) {
      consoleLogin.hideLogin();
      consoleControllers.put(consoleNum, console);

      LoginBean loginBean = console.getLoginInfo();
      console.updateInfoPanel(loginBean);

      // Revise the name of the console
      String cmd = (command == null) ? " " : command;

      if (loginBean != null) {
        console.setName(loginBean.getUserName() + "," + cmd);
        subpageView.updatePersonalizedTab(loginBean.getUserName(), cmd);

        Session session = loginBean.getSession();
        if (sessionMap.get(session) == null) {
          sessionMap.put(session, new AtomicInteger(1));
        } else {

          if (sessionMap.get(session) == null) {
            sessionMap.put(session, new AtomicInteger(1));
          } else {
            incrementSessionUsers(session);
          }
        }
      }
    }

    consoleLogin.killProgress();
    tabListener.enableNewTab(true);
    consoleTerminalView.enableCommanding(true);

    // Use the console initializer to issue a "history" command to the
    // remote host, capture the result, and display it in the command field
    // of the console view
    try {
      ConsoleTerminalController.ConsoleInitializer consoleInitializer =
          console.new ConsoleInitializer();
      consoleInitializer.initializeCommands(console.getLoginInfo());
    } catch (NumberFormatException e) {
    } catch (JSchException e) {
      e.printStackTrace();
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * com.intel.stl.ui.console.IConsoleEventListener#initializeConsole(com.
   * intel.stl.ui.console.LoginBean, java.lang.String)
   */
  @Override
  public void initializeConsole(LoginBean loginBean, String command) throws NumberFormatException {

    try {
      tabListener = subpageView.getNewTabView();
      tabListener.enableNewTab(false);
      consoleTerminalView.enableCommanding(false);
      if (command == null) {
        // Add new console with a new session
        console.initializeTerminal(loginBean);

      } else {
        console.initializeTerminal(loginBean, command);
      }
    } catch (NumberFormatException e) {
      throw e;
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * com.intel.stl.ui.console.IConsoleDispatchListener#updateTab(java.lang
   * .String, java.lang.String)
   */
  @Override
  public void updatePersonalizedTab(LoginBean loginBean, String command) {

    // Put the username and command on the subpage tab
    subpageView.updatePersonalizedTab(loginBean.getUserName(), command);
  }