コード例 #1
0
  @Override
  public void initContextData(Session session, Context uiSharedContext) {
    selectedMethod = uiSharedContext.getSessionManagementMethod();
    if (log.isDebugEnabled())
      log.debug(
          "Initializing configuration panel for session management method: "
              + selectedMethod
              + " for context "
              + uiSharedContext.getName());

    // If something was already configured, find the type and set the UI accordingly
    if (selectedMethod != null) {
      // If the proper type is already selected, just rebind the data
      if (shownMethodType != null && shownMethodType.isTypeForMethod(selectedMethod)) {
        if (shownMethodType.hasOptionsPanel()) shownConfigPanel.bindMethod(selectedMethod);
        return;
      }

      // Select what needs to be selected
      for (SessionManagementMethodType type : extension.getSessionManagementMethodTypes())
        if (type.isTypeForMethod(selectedMethod)) {
          // Selecting the type here will also force the selection listener to run and
          // change the config panel accordingly
          getSessionManagementMethodsComboBox().setSelectedItem(type);
          break;
        }
    }
  }
コード例 #2
0
  /**
   * 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();
  }