コード例 #1
0
  @Override
  @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
  protected void showSelectedObject(
      @Nonnull final WebPageExecutionContext aWPEC, @Nonnull final IUser aSelectedObject) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final AccessManager aMgr = AccessManager.getInstance();
    final IHCTableFormView<?> aTable =
        aNodeList.addAndReturnChild(getStyler().createTableFormView(new HCCol(170), HCCol.star()));
    aTable.setSpanningHeaderContent(
        EText.HEADER_DETAILS.getDisplayTextWithArgs(
            aDisplayLocale, SecurityUI.getUserDisplayName(aSelectedObject, aDisplayLocale)));
    onShowSelectedObjectTableStart(aTable, aSelectedObject, aDisplayLocale);
    if (!useEmailAddressAsLoginName()) {
      aTable
          .createItemRow()
          .setLabel(EText.LABEL_LOGINNAME.getDisplayText(aDisplayLocale))
          .setCtrl(aSelectedObject.getLoginName());
    }
    aTable
        .createItemRow()
        .setLabel(EText.LABEL_FIRSTNAME.getDisplayText(aDisplayLocale))
        .setCtrl(aSelectedObject.getFirstName());
    aTable
        .createItemRow()
        .setLabel(EText.LABEL_LASTNAME.getDisplayText(aDisplayLocale))
        .setCtrl(aSelectedObject.getLastName());
    aTable
        .createItemRow()
        .setLabel(EText.LABEL_EMAIL.getDisplayText(aDisplayLocale))
        .setCtrl(getStyler().createEmailLink(aSelectedObject.getEmailAddress()));
    aTable
        .createItemRow()
        .setLabel(EText.LABEL_ENABLED.getDisplayText(aDisplayLocale))
        .setCtrl(EWebBasicsText.getYesOrNo(aSelectedObject.isEnabled(), aDisplayLocale));
    aTable
        .createItemRow()
        .setLabel(EText.LABEL_DELETED.getDisplayText(aDisplayLocale))
        .setCtrl(EWebBasicsText.getYesOrNo(aSelectedObject.isDeleted(), aDisplayLocale));
    aTable
        .createItemRow()
        .setLabel(EText.LABEL_LAST_LOGIN.getDisplayText(aDisplayLocale))
        .setCtrl(
            aSelectedObject.getLastLoginDateTime() != null
                ? new HCTextNode(
                    PDTToString.getAsString(aSelectedObject.getLastLoginDateTime(), aDisplayLocale))
                : HCEM.create(EText.LABEL_LAST_LOGIN_NEVER.getDisplayText(aDisplayLocale)));
    aTable
        .createItemRow()
        .setLabel(EText.LABEL_LOGIN_COUNT.getDisplayText(aDisplayLocale))
        .setCtrl(Integer.toString(aSelectedObject.getLoginCount()));
    aTable
        .createItemRow()
        .setLabel(EText.LABEL_CONSECUTIVE_FAILED_LOGIN_COUNT.getDisplayText(aDisplayLocale))
        .setCtrl(Integer.toString(aSelectedObject.getConsecutiveFailedLoginCount()));

    // user groups
    final Collection<IUserGroup> aUserGroups =
        aMgr.getAllUserGroupsWithAssignedUser(aSelectedObject.getID());
    if (aUserGroups.isEmpty()) {
      aTable
          .createItemRow()
          .setLabel(EText.LABEL_USERGROUPS_0.getDisplayText(aDisplayLocale))
          .setCtrl(HCEM.create(EText.NONE_DEFINED.getDisplayText(aDisplayLocale)));
    } else {
      final HCNodeList aUserGroupUI = new HCNodeList();
      for (final IUserGroup aUserGroup :
          ContainerHelper.getSorted(aUserGroups, new ComparatorHasName<IUserGroup>(aDisplayLocale)))
        aUserGroupUI.addChild(HCDiv.create(aUserGroup.getName()));
      aTable
          .createItemRow()
          .setLabel(
              EText.LABEL_USERGROUPS_N.getDisplayTextWithArgs(
                  aDisplayLocale, Integer.toString(aUserGroups.size())))
          .setCtrl(aUserGroupUI);
    }

    // roles
    final Set<IRole> aUserRoles = aMgr.getAllUserRoles(aSelectedObject.getID());
    if (aUserRoles.isEmpty()) {
      aTable
          .createItemRow()
          .setLabel(EText.LABEL_ROLES_0.getDisplayText(aDisplayLocale))
          .setCtrl(HCEM.create(EText.NONE_DEFINED.getDisplayText(aDisplayLocale)));
    } else {
      final HCNodeList aRoleUI = new HCNodeList();
      for (final IRole aRole :
          ContainerHelper.getSorted(aUserRoles, new ComparatorHasName<IRole>(aDisplayLocale)))
        aRoleUI.addChild(HCDiv.create(aRole.getName()));
      aTable
          .createItemRow()
          .setLabel(
              EText.LABEL_ROLES_N.getDisplayTextWithArgs(
                  aDisplayLocale, Integer.toString(aUserRoles.size())))
          .setCtrl(aRoleUI);
    }

    // custom attributes
    final Map<String, Object> aCustomAttrs = aSelectedObject.getAllAttributes();

    // Callback
    final Set<String> aHandledAttrs =
        showCustomAttrsOfSelectedObject(aSelectedObject, aCustomAttrs, aTable, aDisplayLocale);

    if (!aCustomAttrs.isEmpty()) {
      final IHCTable<?> aAttrTable = getStyler().createTable(new HCCol(170), HCCol.star());
      aAttrTable
          .addHeaderRow()
          .addCells(
              EText.HEADER_NAME.getDisplayText(aDisplayLocale),
              EText.HEADER_VALUE.getDisplayText(aDisplayLocale));
      for (final Map.Entry<String, Object> aEntry : aCustomAttrs.entrySet()) {
        final String sName = aEntry.getKey();
        if (aHandledAttrs == null || !aHandledAttrs.contains(sName)) {
          final String sValue = String.valueOf(aEntry.getValue());
          aAttrTable.addBodyRow().addCells(sName, sValue);
        }
      }

      // Maybe all custom attributes where handled in
      // showCustomAttrsOfSelectedObject
      if (aAttrTable.hasBodyRows())
        aTable
            .createItemRow()
            .setLabel(EText.LABEL_ATTRIBUTES.getDisplayText(aDisplayLocale))
            .setCtrl(aAttrTable);
    }

    // Callback
    onShowSelectedObjectTableEnd(aTable, aSelectedObject, aDisplayLocale);
  }