Ejemplo n.º 1
0
  @Override
  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("rest.title");
    setFormContextHelp("REST API");

    if (formLayout instanceof FormLayoutContainer) {
      FormLayoutContainer layoutContainer = (FormLayoutContainer) formLayout;

      boolean restEnabled = restModule.isEnabled();
      docLinkFlc =
          FormLayoutContainer.createCustomFormLayout(
              "doc_link", getTranslator(), velocity_root + "/docLink.html");
      layoutContainer.add(docLinkFlc);
      docLinkFlc.setVisible(restEnabled);

      String link =
          Settings.getServerContextPathURI() + RestSecurityHelper.SUB_CONTEXT + "/api/doc";
      docLinkFlc.contextPut("docLink", link);

      FormLayoutContainer accessDataFlc =
          FormLayoutContainer.createDefaultFormLayout("flc_access_data", getTranslator());
      layoutContainer.add(accessDataFlc);

      String[] values = new String[] {getTranslator().translate("rest.on")};
      enabled = uifactory.addCheckboxesHorizontal("rest.enabled", accessDataFlc, keys, values);
      enabled.select(keys[0], restEnabled);
      enabled.addActionListener(FormEvent.ONCHANGE);

      accessDataFlc.setVisible(true);
      formLayout.add(accessDataFlc);

      FormLayoutContainer managedFlc =
          FormLayoutContainer.createDefaultFormLayout("flc_managed", getTranslator());
      layoutContainer.add(managedFlc);

      String[] valueGrps = new String[] {getTranslator().translate("rest.on")};
      managedGroupsEl =
          uifactory.addCheckboxesHorizontal("managed.group", managedFlc, keys, valueGrps);
      managedGroupsEl.addActionListener(FormEvent.ONCHANGE);
      managedGroupsEl.select(keys[0], groupModule.isManagedBusinessGroups());

      String[] valueRes = new String[] {getTranslator().translate("rest.on")};
      managedRepoEl = uifactory.addCheckboxesHorizontal("managed.repo", managedFlc, keys, valueRes);
      managedRepoEl.addActionListener(FormEvent.ONCHANGE);
      managedRepoEl.select(keys[0], repositoryModule.isManagedRepositoryEntries());

      String[] valueCal = new String[] {getTranslator().translate("rest.on")};
      managedCalendarEl =
          uifactory.addCheckboxesHorizontal("managed.cal", managedFlc, keys, valueCal);
      managedCalendarEl.addActionListener(FormEvent.ONCHANGE);
      managedCalendarEl.select(keys[0], calendarModule.isManagedCalendars());
    }
  }
  private void updateGUI(ModelInfos modelInfos) {
    if (modelInfos.isSame()) {
      applyToAllEl.select(onKeys[0], true);
      table.setVisible(false);

      if (groupPassedEl != null) {
        groupPassedEl.setVisible(true);
        Boolean passed = modelInfos.getPassed();
        groupPassedEl.select(onKeys[0], passed != null && passed.booleanValue());
      }
      if (groupScoreEl != null) {
        groupScoreEl.setVisible(true);
        Float score = modelInfos.getScore();
        if (score != null) {
          String scoreVal = AssessmentHelper.getRoundedScore(score);
          groupScoreEl.setValue(scoreVal);
        } else {
          groupScoreEl.setValue("");
        }
      }
      if (groupCommentEl != null) {
        groupCommentEl.setVisible(true);
        String comment = modelInfos.getComment();
        if (comment != null) {
          groupCommentEl.setValue(comment);
        }
      }
    } else {
      applyToAllEl.select(onKeys[0], false);
      table.setVisible(true);
      if (groupPassedEl != null) {
        groupPassedEl.setVisible(false);
      }
      if (groupScoreEl != null) {
        groupScoreEl.setVisible(false);
      }
      if (groupCommentEl != null) {
        groupCommentEl.setVisible(false);
      }
    }

    if (StringHelper.containsNonWhitespace(modelInfos.getDuplicates())) {
      String warning =
          translate(
              "error.duplicate.memberships",
              new String[] {gtaNode.getShortTitle(), modelInfos.getDuplicates()});
      flc.contextPut("duplicateWarning", warning);
    } else {
      flc.contextRemove("duplicateWarning");
    }
  }
  @Override
  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // Add the "accept" checkbox to the form.
    acceptCheckbox =
        uifactory.addCheckboxesVertical(
            ACKNOWLEDGE_CHECKBOX_NAME,
            null,
            formLayout,
            new String[] {DCL_CHECKBOX_KEY},
            new String[] {translate(NLS_DISCLAIMER_ACKNOWLEDGED)},
            null,
            1);
    acceptCheckbox.setEscapeHtml(false);
    acceptCheckbox.setMandatory(false);
    acceptCheckbox.select(DCL_CHECKBOX_KEY, readOnly);

    // Add the additional checkbox to the form (depending on the configuration)
    if (CoreSpringFactory.getImpl(RegistrationModule.class).isDisclaimerAdditionalCheckbox()) {
      String additionalCheckboxText = translate("disclaimer.additionalcheckbox");
      if (additionalCheckboxText != null) {
        additionalCheckbox =
            uifactory.addCheckboxesVertical(
                ADDITIONAL_CHECKBOX_NAME,
                null,
                formLayout,
                new String[] {DCL_CHECKBOX_KEY2},
                new String[] {additionalCheckboxText},
                null,
                1);
        additionalCheckbox.setEscapeHtml(false);
        additionalCheckbox.select(DCL_CHECKBOX_KEY2, readOnly);
      }
    }

    if (readOnly) {
      // Disable when set to read only
      formLayout.setEnabled(!readOnly);
    } else {
      // Create submit and cancel buttons
      final FormLayoutContainer buttonLayout =
          FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
      formLayout.add(buttonLayout);
      buttonLayout.setElementCssClass("o_sel_disclaimer_buttons");
      uifactory.addFormSubmitButton(DCL_ACCEPT, NLS_DISCLAIMER_OK, buttonLayout);
      uifactory.addFormCancelButton(NLS_DISCLAIMER_NOK, buttonLayout, ureq, getWindowControl());
    }
  }
Ejemplo n.º 4
0
 @Override
 protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
   if (nodeSelections.contains(source)) {
     MultipleSelectionElement nodeSelection = (MultipleSelectionElement) source;
     if (nodeSelection.isMultiselect()) {
       selectRec(nodeSelection, nodeSelection.isSelected(0));
     }
   } else if (source == selectAll) {
     for (MultipleSelectionElement nodeSelection : nodeSelections) {
       if (nodeSelection.isMultiselect() && !nodeSelection.isSelected(0)) {
         SelectNodeObject treeNode = (SelectNodeObject) nodeSelection.getUserObject();
         String id = treeNode.getId();
         nodeSelection.select(id, true);
       }
     }
   } else if (source == deselectAll) {
     for (MultipleSelectionElement nodeSelection : nodeSelections) {
       if (nodeSelection.isMultiselect() && nodeSelection.isSelected(0)) {
         SelectNodeObject treeNode = (SelectNodeObject) nodeSelection.getUserObject();
         String id = treeNode.getId();
         nodeSelection.select(id, false);
       }
     }
   } else if (source == asChild) {
     position = -1;
     ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
     create(rootSelection, course, selectedNode.getCourseNode());
     fireEvent(ureq, Event.CHANGED_EVENT);
   } else if (source == sameLevel) {
     ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
     CourseEditorTreeNode parentNode = (CourseEditorTreeNode) selectedNode.getParent();
     position = 0;
     for (position = parentNode.getChildCount(); position-- > 0; ) {
       if (selectedNode.getIdent().equals(parentNode.getChildAt(position).getIdent())) {
         position++;
         break;
       }
     }
     create(rootSelection, course, parentNode.getCourseNode());
     fireEvent(ureq, Event.CHANGED_EVENT);
   } else {
     super.formInnerEvent(ureq, source, event);
   }
 }
Ejemplo n.º 5
0
  /**
   * @param nodeSelection The node that should be selected recursively
   * @param select true: select the node and its children; false: deselect the node and its children
   */
  private void selectRec(MultipleSelectionElement nodeSelection, boolean select) {
    SelectNodeObject userObject = (SelectNodeObject) nodeSelection.getUserObject();
    String id = userObject.getId();
    if (nodeSelection.isMultiselect()) {
      nodeSelection.select(id, select);
    }

    for (MultipleSelectionElement childSelection : userObject.getChildren()) {
      selectRec(childSelection, select);
    }
  }
 private void updateStandardMode() {
   boolean standard = standardModeEl.isSelected(0);
   if (standard) {
     jsOptionEl.select(jsKeys[0], true);
     cssOptionEl.select(cssKeys[0], true);
     glossarEl.select("on", false);
     if (heightEl.isSelected(0)) {
       heightEl.select("600", true);
     }
   }
 }
  private void setValues(DeliveryOptions cfg) {
    Boolean mode = (cfg == null ? null : cfg.getStandardMode());
    if (mode == null || mode.booleanValue()) {
      standardModeEl.select("standard", true);
    } else {
      standardModeEl.select("configured", true);
    }

    if (cfg != null) {
      if (cfg.getjQueryEnabled() != null && cfg.getjQueryEnabled().booleanValue()) {
        jsOptionEl.select(jsKeys[1], true); // jQuery
      } else if (cfg.getPrototypeEnabled() != null && cfg.getPrototypeEnabled().booleanValue()) {
        jsOptionEl.select(jsKeys[2], true); // prototype
      } else {
        jsOptionEl.select(jsKeys[0], true); // default is none
      }
    } else {
      jsOptionEl.select(jsKeys[0], true); // default is none
    }

    Boolean glossarEnabled = (cfg == null ? null : cfg.getGlossaryEnabled());
    if (glossarEnabled != null && glossarEnabled.booleanValue()) {
      glossarEl.select("on", true);
    }

    String height = cfg == null ? null : cfg.getHeight();
    if (height != null && Arrays.asList(keys).contains(height)) {
      heightEl.select(height, true);
    } else {
      heightEl.select(DeliveryOptions.CONFIG_HEIGHT_AUTO, true);
    }

    if (cfg != null && cfg.getOpenolatCss() != null && cfg.getOpenolatCss().booleanValue()) {
      cssOptionEl.select(cssKeys[1], true);
    } else {
      cssOptionEl.select(cssKeys[0], false); // default none
    }

    String encodingContent = (cfg == null ? null : cfg.getContentEncoding());
    if (encodingContent != null && Arrays.asList(encodingContentKeys).contains(encodingContent)) {
      encodingContentEl.select(encodingContent, true);
    } else {
      encodingContentEl.select(NodeEditController.CONFIG_CONTENT_ENCODING_AUTO, true);
    }

    String encodingJS = (cfg == null ? null : cfg.getJavascriptEncoding());
    if (encodingJS != null && Arrays.asList(encodingJSKeys).contains(encodingJS)) {
      encodingJSEl.select(encodingJS, true);
    } else {
      encodingJSEl.select(NodeEditController.CONFIG_JS_ENCODING_AUTO, true);
    }
  }
Ejemplo n.º 8
0
  @Override
  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("settings.title");
    formLayout.setElementCssClass("o_sel_course_forum_settings");

    if (forumModule.isAnonymousPostingWithPseudonymEnabled()) {
      String[] allowPseudonymValues = new String[] {translate("allow.pseudonym.post")};
      allowPseudonymEl =
          uifactory.addCheckboxesHorizontal(
              "allow.pseudonym", formLayout, allowKeys, allowPseudonymValues);
      allowPseudonymEl.setElementCssClass("o_sel_course_forum_allow_pseudo");
      allowPseudonymEl.setLabel(null, null);
      allowPseudonymEl.addActionListener(FormEvent.ONCHANGE);

      if ("true"
          .equals(
              foNode
                  .getModuleConfiguration()
                  .getStringValue(FOCourseNodeEditController.PSEUDONYM_POST_ALLOWED))) {
        allowPseudonymEl.select(allowKeys[0], true);
      }
    }

    String[] allowGuestValues = new String[] {translate("allow.guest.post")};
    allowGuestEl =
        uifactory.addCheckboxesHorizontal("allow.guest", formLayout, allowKeys, allowGuestValues);
    allowGuestEl.setElementCssClass("o_sel_course_forum_allow_guest");
    allowGuestEl.setLabel(null, null);
    allowGuestEl.addActionListener(FormEvent.ONCHANGE);
    if ("true"
        .equals(
            foNode
                .getModuleConfiguration()
                .getStringValue(FOCourseNodeEditController.GUEST_POST_ALLOWED))) {
      allowGuestEl.select(allowKeys[0], true);
    }
  }
Ejemplo n.º 9
0
  @Override
  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {

    // options
    String[] optionKeys = new String[] {OPTION_GUEST_ACCESS};
    String[] optionVals = new String[] {translate(OPTION_GUEST_ACCESS)};
    multiSelectOptions =
        uifactory.addCheckboxesVertical(
            "vc.options", "vc.options.label", formLayout, optionKeys, optionVals, 1);
    multiSelectOptions.select(OPTION_GUEST_ACCESS, config.isGuestAccessAllowed());
    multiSelectOptions.showLabel(false);

    submit = new FormSubmit("subm", "submit");

    formLayout.add(submit);
  }
  /**
   * @see
   *     org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
   *     org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
   */
  @Override
  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // Create the business group name input text element
    if (bulkMode) {
      businessGroupName =
          uifactory.addTextElement(
              "create.form.title.bgnames",
              "create.form.title.bgnames",
              10 * BusinessGroup.MAX_GROUP_NAME_LENGTH,
              "",
              formLayout);
      businessGroupName.setExampleKey("create.form.message.example.group", null);
    } else {
      businessGroupName =
          uifactory.addTextElement(
              "create.form.title.bgname",
              "create.form.title.bgname",
              BusinessGroup.MAX_GROUP_NAME_LENGTH,
              "",
              formLayout);
      businessGroupName.setNotLongerThanCheck(
          BusinessGroup.MAX_GROUP_NAME_LENGTH, "create.form.error.nameTooLong");
      businessGroupName.setRegexMatchCheck(
          BusinessGroup.VALID_GROUPNAME_REGEXP, "create.form.error.illegalName");
    }
    businessGroupName.setElementCssClass("o_sel_group_edit_title");
    businessGroupName.setMandatory(true);
    businessGroupName.setEnabled(
        !BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.title));

    formLayout.setElementCssClass("o_sel_group_edit_group_form");

    // Create the business group description input rich text element
    businessGroupDescription =
        uifactory.addRichTextElementForStringDataMinimalistic(
            "create.form.title.description",
            "create.form.title.description",
            "",
            10,
            -1,
            formLayout,
            getWindowControl());
    businessGroupDescription.setEnabled(
        !BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.description));

    if (businessGroup != null && !bulkMode) {
      // link to group direct jump in business path
      BusinessControlFactory bcf = BusinessControlFactory.getInstance();
      List<ContextEntry> entries =
          bcf.createCEListFromString("[BusinessGroup:" + businessGroup.getKey() + "]");
      String url = bcf.getAsURIString(entries, true);
      StaticTextElement urlEl =
          uifactory.addStaticTextElement("create.form.businesspath", url, formLayout);
      urlEl.setElementCssClass("o_sel_group_url");
      // link to group visiting card
      bcf = BusinessControlFactory.getInstance();
      entries = bcf.createCEListFromString("[GroupCard:" + businessGroup.getKey() + "]");
      url = bcf.getAsURIString(entries, true);
      StaticTextElement cardEl =
          uifactory.addStaticTextElement("create.form.groupcard", url, formLayout);
      cardEl.setElementCssClass("o_sel_group_card_url");
    }

    uifactory.addSpacerElement("myspacer", formLayout, true);

    // Minimum members input
    businessGroupMinimumMembers =
        uifactory.addTextElement(
            "create.form.title.min", "create.form.title.min", 5, "", formLayout);
    businessGroupMinimumMembers.setDisplaySize(6);
    businessGroupMinimumMembers.setVisible(false); // currently the minimum feature is not enabled
    businessGroupMinimumMembers.setElementCssClass("o_sel_group_edit_min_members");

    // Maximum members input
    businessGroupMaximumMembers =
        uifactory.addTextElement(
            "create.form.title.max", "create.form.title.max", 5, "", formLayout);
    businessGroupMaximumMembers.setDisplaySize(6);
    businessGroupMaximumMembers.setElementCssClass("o_sel_group_edit_max_members");

    // Checkboxes
    enableWaitingList =
        uifactory.addCheckboxesHorizontal(
            "create.form.enableWaitinglist", null, formLayout, waitingListKeys, waitingListValues);
    enableWaitingList.setElementCssClass("o_sel_group_edit_waiting_list");
    enableAutoCloseRanks =
        uifactory.addCheckboxesHorizontal(
            "create.form.enableAutoCloseRanks", null, formLayout, autoCloseKeys, autoCloseValues);
    enableAutoCloseRanks.setElementCssClass("o_sel_group_edit_auto_close_ranks");

    // Enable only if specification of min and max members is possible
    businessGroupMinimumMembers.setVisible(false); // currently the minimum feature is not enabled
    businessGroupMaximumMembers.setVisible(true);
    enableWaitingList.setVisible(true);
    enableAutoCloseRanks.setVisible(true);

    boolean managedSettings =
        BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.settings);
    businessGroupMinimumMembers.setEnabled(!managedSettings);
    businessGroupMaximumMembers.setEnabled(!managedSettings);
    enableWaitingList.setEnabled(!managedSettings);
    enableAutoCloseRanks.setEnabled(!managedSettings);

    if ((businessGroup != null) && (!bulkMode)) {
      businessGroupName.setValue(businessGroup.getName());
      businessGroupDescription.setValue(businessGroup.getDescription());
      Integer minimumMembers = businessGroup.getMinParticipants();
      Integer maximumMembers = businessGroup.getMaxParticipants();
      businessGroupMinimumMembers.setValue(
          minimumMembers == null || minimumMembers.intValue() <= 0
              ? ""
              : minimumMembers.toString());
      businessGroupMaximumMembers.setValue(
          maximumMembers == null || maximumMembers.intValue() < 0 ? "" : maximumMembers.toString());
      if (businessGroup.getWaitingListEnabled() != null) {
        enableWaitingList.select(
            "create.form.enableWaitinglist", businessGroup.getWaitingListEnabled());
      }
      if (businessGroup.getAutoCloseRanksEnabled() != null) {
        enableAutoCloseRanks.select(
            "create.form.enableAutoCloseRanks", businessGroup.getAutoCloseRanksEnabled());
      }
    }

    if (!embbeded) {
      // Create submit and cancel buttons
      final FormLayoutContainer buttonLayout =
          FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
      formLayout.add(buttonLayout);
      FormSubmit submit = uifactory.addFormSubmitButton("finish", buttonLayout);
      submit.setEnabled(
          !BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.details));
      uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
    }

    if ((businessGroup != null) && (!bulkMode)) {
      // managed group information
      boolean managed =
          StringHelper.containsNonWhitespace(businessGroup.getExternalId())
              || businessGroup.getManagedFlags().length > 0;
      if (managed) {
        uifactory.addSpacerElement("managedspacer", formLayout, false);

        String extId = businessGroup.getExternalId() == null ? "" : businessGroup.getExternalId();
        StaticTextElement externalIdEl =
            uifactory.addStaticTextElement("create.form.externalid", extId, formLayout);
        externalIdEl.setElementCssClass("o_sel_group_external_id");

        FormLayoutContainer flagsFlc =
            FormLayoutContainer.createHorizontalFormLayout("flc_flags", getTranslator());
        flagsFlc.setLabel("create.form.managedflags", null);
        formLayout.add(flagsFlc);

        String flags =
            businessGroup.getManagedFlagsString() == null
                ? ""
                : businessGroup.getManagedFlagsString().trim();
        String flagsFormatted = null;
        if (flags.length() > 0) {
          // use translator from REST admin package to import managed flags context help strings
          Translator managedTrans =
              Util.createPackageTranslator(RestapiAdminController.class, ureq.getLocale());
          StringBuffer flagList = new StringBuffer();
          flagList.append("<p class=\"o_important\">");
          flagList.append(translate("create.form.managedflags.intro"));
          flagList.append("</div>");
          flagList.append("<ul>");
          for (String flag : flags.split(",")) {
            flagList.append("<li>");
            flagList.append(managedTrans.translate("managed.flags.group." + flag));
            flagList.append("</li>");
          }

          flagsFormatted = flagList.toString();

        } else {
          flagsFormatted = flags;
        }

        StaticTextElement flagsEl =
            uifactory.addStaticTextElement("create.form.managedflags", flagsFormatted, flagsFlc);
        flagsEl.showLabel(false);
        flagsEl.setElementCssClass("o_sel_group_managed_flags");
      }
    }
  }
Ejemplo n.º 11
0
  /** @return True if all results are the same */
  private ModelInfos loadModel() {
    // load participants, load datas
    ICourse course = CourseFactory.loadCourse(courseEnv.getCourseResourceableId());
    List<Identity> identities =
        businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name());

    Map<Identity, AssessmentEntry> identityToEntryMap = new HashMap<>();
    List<AssessmentEntry> entries =
        course
            .getCourseEnvironment()
            .getAssessmentManager()
            .getAssessmentEntries(assessedGroup, gtaNode);
    for (AssessmentEntry entry : entries) {
      identityToEntryMap.put(entry.getIdentity(), entry);
    }

    int count = 0;
    boolean same = true;
    StringBuilder duplicateWarning = new StringBuilder();
    Float scoreRef = null;
    Boolean passedRef = null;
    String commentRef = null;

    List<AssessmentRow> rows = new ArrayList<>(identities.size());
    for (Identity identity : identities) {
      AssessmentEntry entry = identityToEntryMap.get(identity);

      ScoreEvaluation scoreEval = null;
      if (withScore || withPassed) {
        scoreEval = gtaNode.getUserScoreEvaluation(entry);
        if (scoreEval == null) {
          scoreEval = ScoreEvaluation.EMPTY_EVALUATION;
        }
      }

      String comment = null;
      if (withComment && entry != null) {
        comment = entry.getComment();
      }

      boolean duplicate = duplicateMemberKeys.contains(identity.getKey());
      if (duplicate) {
        if (duplicateWarning.length() > 0) duplicateWarning.append(", ");
        duplicateWarning.append(StringHelper.escapeHtml(userManager.getUserDisplayName(identity)));
      }

      AssessmentRow row = new AssessmentRow(identity, duplicate);
      rows.add(row);

      if (withScore) {
        Float score = scoreEval.getScore();
        String pointVal = AssessmentHelper.getRoundedScore(score);
        TextElement pointEl = uifactory.addTextElement("point" + count, null, 5, pointVal, flc);
        pointEl.setDisplaySize(5);
        row.setScoreEl(pointEl);
        if (count == 0) {
          scoreRef = score;
        } else if (!same(scoreRef, score)) {
          same = false;
        }
      }

      if (withPassed && cutValue == null) {
        Boolean passed = scoreEval.getPassed();
        MultipleSelectionElement passedEl =
            uifactory.addCheckboxesHorizontal("check" + count, null, flc, onKeys, onValues);
        if (passed != null && passed.booleanValue()) {
          passedEl.select(onKeys[0], passed.booleanValue());
        }
        row.setPassedEl(passedEl);
        if (count == 0) {
          passedRef = passed;
        } else if (!same(passedRef, passed)) {
          same = false;
        }
      }

      if (withComment) {
        FormLink commentLink =
            uifactory.addFormLink(
                "comment-" + CodeHelper.getRAMUniqueID(),
                "comment",
                "comment",
                null,
                flc,
                Link.LINK);
        if (StringHelper.containsNonWhitespace(comment)) {
          commentLink.setIconLeftCSS("o_icon o_icon_comments");
        } else {
          commentLink.setIconLeftCSS("o_icon o_icon_comments_none");
        }
        commentLink.setUserObject(row);
        row.setComment(comment);
        row.setCommentEditLink(commentLink);

        if (count == 0) {
          commentRef = comment;
        } else if (!same(commentRef, comment)) {
          same = false;
        }
      }

      count++;
    }

    model.setObjects(rows);
    table.reset();

    return new ModelInfos(same, scoreRef, passedRef, commentRef, duplicateWarning.toString());
  }
  @Override
  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    boolean firstGroup = true;

    List<UserPropertyHandler> homepagePropertyHanders =
        userManager.getUserPropertyHandlersFor(
            HomePageConfig.class.getCanonicalName(), isAdministrativeUser);

    Map<String, FormLayoutContainer> groupContainerMap = new HashMap<>();
    HomePageConfig conf = hpcm.loadConfigFor(identityToModify.getName());
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
      if (userPropertyHandler == null) {
        continue;
      }

      // add spacer if necessary (i.e. when group name changes)
      String group = userPropertyHandler.getGroup();
      FormLayoutContainer groupContainer;
      if (groupContainerMap.containsKey(group)) {
        groupContainer = groupContainerMap.get(group);
      } else {
        groupContainer =
            FormLayoutContainer.createDefaultFormLayout("group." + group, getTranslator());
        groupContainer.setFormTitle(translate("form.group." + group));
        formLayout.add(groupContainer);
        groupContainerMap.put(group, groupContainer);
        if (firstGroup) {
          groupContainer.setFormContextHelp("Configuration");
          firstGroup = false;
        }
      }

      if (homepagePropertyHanders.contains(userPropertyHandler)) {
        // add checkbox to container if configured for homepage usage identifier
        String checkboxName = userPropertyHandler.getName();
        MultipleSelectionElement publishCheckbox =
            uifactory.addCheckboxesHorizontal(
                checkboxName,
                userPropertyHandler.i18nFormElementLabelKey(),
                groupContainer,
                checkKeys,
                checkValues);

        boolean isEnabled = conf.isEnabled(userPropertyHandler.getName());
        publishCheckbox.select(checkKeys[0], isEnabled);
        publishCheckbox.setUserObject(userPropertyHandler.getName());

        // Mandatory homepage properties can not be changed by user
        if (userManager.isMandatoryUserProperty(
            HomePageConfig.class.getCanonicalName(), userPropertyHandler)) {
          publishCheckbox.select(checkKeys[0], true);
          publishCheckbox.setEnabled(false);
        } else {
          publishCheckbox.addActionListener(FormEvent.ONCHANGE);
        }
      }
    }

    String previewPage = velocity_root + "/homepage_preview.html";
    previewContainer =
        FormLayoutContainer.createCustomFormLayout("preview", getTranslator(), previewPage);
    previewContainer.setFormTitle(translate("tab.preview"));
    previewContainer.setRootForm(mainForm);
    formLayout.add(previewContainer);
    updatePreview(ureq);
  }
  /** Initialize form. */
  @Override
  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {

    // create form elements
    projectTitle =
        uifactory.addTextElement(
            "title", "detailsform.title.label", 100, project.getTitle(), formLayout);

    // account-Managers
    StringBuilder projectLeaderString = new StringBuilder();
    for (Iterator iterator = project.getProjectLeaders().iterator(); iterator.hasNext(); ) {
      Identity identity = (Identity) iterator.next();
      String last = identity.getUser().getProperty(UserConstants.LASTNAME, getLocale());
      String first = identity.getUser().getProperty(UserConstants.FIRSTNAME, getLocale());
      if (projectLeaderString.length() > 0) {
        projectLeaderString.append(",");
      }
      projectLeaderString.append(first);
      projectLeaderString.append(" ");
      projectLeaderString.append(last);
    }
    projectLeaders =
        uifactory.addTextElement(
            "projectleaders",
            "detailsform.projectleaders.label",
            100,
            projectLeaderString.toString(),
            formLayout);
    projectLeaders.setEnabled(false);

    // add the learning objectives rich text input element
    projectDescription =
        uifactory.addRichTextElementForStringData(
            "description",
            "detailsform.description.label",
            project.getDescription(),
            10,
            -1,
            false,
            null,
            null,
            formLayout,
            ureq.getUserSession(),
            getWindowControl());
    projectDescription.setMaxLength(2500);

    stateLayout = FormLayoutContainer.createHorizontalFormLayout("stateLayout", getTranslator());
    stateLayout.setLabel("detailsform.state.label", null);
    formLayout.add(stateLayout);
    String stateValue =
        getTranslator()
            .translate(
                ProjectBrokerManagerFactory.getProjectBrokerManager()
                    .getStateFor(project, ureq.getIdentity(), projectBrokerModuleConfiguration));
    projectState =
        uifactory.addStaticTextElement(
            "detailsform.state", stateValue + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", stateLayout);
    projectState.setLabel(null, null);

    String keyDetailsformMax = null;
    if (projectBrokerModuleConfiguration.isAcceptSelectionManually()) {
      keyDetailsformMax = "detailsform.max.candidates.label";
    } else {
      keyDetailsformMax = "detailsform.max.members.label";
    }
    selectionMaxMembers =
        uifactory.addCheckboxesHorizontal(keyDetailsformMax, formLayout, keys, values, null);
    maxMembers =
        uifactory.addIntegerElement(
            "form.options.number.of.participants.per.topic_nbr",
            project.getMaxMembers(),
            formLayout);
    maxMembers.setMinValueCheck(0, null);
    maxMembers.setDisplaySize(3);
    if (project.getMaxMembers() == Project.MAX_MEMBERS_UNLIMITED) {
      maxMembers.setVisible(false);
      selectionMaxMembers.select(keys[0], false);
    } else {
      selectionMaxMembers.select(keys[0], true);
    }
    selectionMaxMembers.addActionListener(listener, FormEvent.ONCLICK);
    uifactory.addSpacerElement("spacer_1", formLayout, false);

    // customfields
    List<CustomField> customFields = projectBrokerModuleConfiguration.getCustomFields();
    int customFieldIndex = 0;
    for (Iterator<CustomField> iterator = customFields.iterator(); iterator.hasNext(); ) {
      CustomField customField = iterator.next();
      getLogger().debug("customField: " + customField.getName() + "=" + customField.getValue());
      StringTokenizer tok =
          new StringTokenizer(
              customField.getValue(), ProjectBrokerManager.CUSTOMFIELD_LIST_DELIMITER);
      if (customField.getValue() == null
          || customField.getValue().equals("")
          || !tok.hasMoreTokens()) {
        // no value define => Text-input
        // Add StaticTextElement as workaroung for non translated label
        uifactory.addStaticTextElement(
            "customField_label" + customFieldIndex,
            null,
            customField.getName(),
            formLayout); // null > no label
        TextElement textElement =
            uifactory.addTextElement(
                "customField_" + customFieldIndex,
                "",
                150,
                project.getCustomFieldValue(customFieldIndex),
                formLayout);
        textElement.setDisplaySize(60);
        //				textElement.setTranslator(null);
        //				textElement.setLabel(customField.getName(), null);
        textElement.showLabel(false);
        customfieldElementList.add(textElement);
      } else {
        // values define => dropdown selection
        List<String> valueList = new ArrayList<String>();
        while (tok.hasMoreTokens()) {
          String value = tok.nextToken();
          valueList.add(value);
          getLogger().debug("valueList add: " + value);
        }
        String[] theValues = new String[valueList.size() + 1];
        String[] theKeys = new String[valueList.size() + 1];
        int arrayIndex = 0;
        theValues[arrayIndex] = translate(DROPDOWN_NO_SELECETION);
        theKeys[arrayIndex] = DROPDOWN_NO_SELECETION;
        arrayIndex++;
        for (Iterator<String> iterator2 = valueList.iterator(); iterator2.hasNext(); ) {
          String value = iterator2.next();
          theValues[arrayIndex] = value;
          theKeys[arrayIndex] = Integer.toString(arrayIndex);
          arrayIndex++;
        }
        // Add StaticTextElement as workaround for non translated label
        uifactory.addStaticTextElement(
            "customField_label" + customFieldIndex,
            null,
            customField.getName(),
            formLayout); // null > no label
        SingleSelection selectionElement =
            uifactory.addDropdownSingleselect(
                "customField_" + customFieldIndex, null, formLayout, theKeys, theValues, null);
        if (project.getCustomFieldValue(customFieldIndex) != null
            && !project.getCustomFieldValue(customFieldIndex).equals("")) {
          if (valueList.contains(project.getCustomFieldValue(customFieldIndex))) {
            String key =
                Integer.toString(
                    valueList.indexOf(project.getCustomFieldValue(customFieldIndex))
                        + 1); // '+1' because no-selection at the beginning
            selectionElement.select(key, true);
          } else {
            this.showInfo(
                "warn.customfield.key.does.not.exist",
                project.getCustomFieldValue(customFieldIndex));
          }
        }
        customfieldElementList.add(selectionElement);
      }
      uifactory.addSpacerElement("customField_spacer" + customFieldIndex, formLayout, false);
      customFieldIndex++;
    }

    // Events
    for (Project.EventType eventType : Project.EventType.values()) {
      if (projectBrokerModuleConfiguration.isProjectEventEnabled(eventType)) {
        ProjectEvent projectEvent = project.getProjectEvent(eventType);
        DateChooser dateChooserStart =
            uifactory.addDateChooser(
                eventType + "start", eventType.getI18nKey() + ".start.label", null, formLayout);
        dateChooserStart.setDateChooserTimeEnabled(true);
        dateChooserStart.setDisplaySize(CUSTOM_DATE_FORMAT.length());
        getLogger().info("Event=" + eventType + ", startDate=" + projectEvent.getStartDate());
        dateChooserStart.setDate(projectEvent.getStartDate());
        eventStartElementList.put(eventType, dateChooserStart);
        DateChooser dateChooserEnd =
            uifactory.addDateChooser(
                eventType + "end", eventType.getI18nKey() + ".end.label", null, formLayout);
        dateChooserEnd.setDateChooserTimeEnabled(true);
        dateChooserEnd.setDisplaySize(CUSTOM_DATE_FORMAT.length());
        getLogger().debug("Event=" + eventType + ", endDate=" + projectEvent.getEndDate());
        dateChooserEnd.setDate(projectEvent.getEndDate());
        eventEndElementList.put(eventType, dateChooserEnd);
        uifactory.addSpacerElement(eventType + "spacer", formLayout, false);
      }
    }

    attachmentFileName =
        uifactory.addFileElement("detailsform.attachmentfilename.label", formLayout);
    attachmentFileName.setLabel("detailsform.attachmentfilename.label", null);
    if (project.getAttachmentFileName() != null && !project.getAttachmentFileName().equals("")) {
      attachmentFileName.setInitialFile(new File(project.getAttachmentFileName()));
      removeAttachmentLink =
          uifactory.addFormLink("detailsform.remove.attachment", formLayout, Link.BUTTON_XSMALL);
    }
    attachmentFileName.addActionListener(this, FormEvent.ONCHANGE);

    mailNotification =
        uifactory.addCheckboxesHorizontal(
            "detailsform.mail.notification.label", formLayout, keys, values, null);
    mailNotification.select(keys[0], project.isMailNotificationEnabled());

    FormLayoutContainer buttonGroupLayout =
        FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
    formLayout.add(buttonGroupLayout);
    uifactory.addFormSubmitButton("save", buttonGroupLayout);
    if (this.enableCancel) {
      uifactory.addFormCancelButton(
          "cancel",
          buttonGroupLayout,
          ureq,
          getWindowControl()); // TODO: Frage an PB: Warum flc hier noetig ???
    }
  }