/**
   * Changes the shown method's configuration panel (used to display brief info about the method and
   * configure it) with a new one, based on a new method type. If {@code null} is provided as a
   * parameter, nothing is shown. If the provided method type does not require configuration, a
   * simple message is shown stating that no configuration is needed.
   *
   * @param newMethodType the new method type. If null, nothing is shown. If does not require
   *     config, a message is shown, on a panel returned by {@link
   *     #getNoMethodConfigurationPanel()}).
   */
  private void changeMethodConfigPanel(SessionManagementMethodType newMethodType) {
    // If there's no new method, don't display anything
    if (newMethodType == null) {
      getConfigContainerPanel().removeAll();
      getConfigContainerPanel().setVisible(false);
      this.shownMethodType = null;
      this.shownConfigPanel = null;
      return;
    }

    // If a panel of the correct type is already shown, do nothing
    if (shownMethodType != null && newMethodType.getClass().equals(shownMethodType.getClass())) {
      return;
    }

    log.debug("Creating new panel for configuring: " + newMethodType.getName());
    this.getConfigContainerPanel().removeAll();

    // show the panel according to whether the session management type needs configuration
    if (newMethodType.hasOptionsPanel()) {
      this.shownConfigPanel = newMethodType.buildOptionsPanel(getUISharedContext());
      getConfigContainerPanel().add(this.shownConfigPanel, BorderLayout.CENTER);
    } else {
      this.shownConfigPanel = null;
      getConfigContainerPanel()
          .add(new JLabel("<html><p>" + CONFIG_NOT_NEEDED + "</p></html>"), BorderLayout.CENTER);
    }
    this.shownMethodType = newMethodType;

    this.getConfigContainerPanel().setVisible(true);
    this.getConfigContainerPanel().revalidate();
  }