示例#1
0
 /** {@inheritDoc} */
 @Override
 protected void formOK(UserRequest ureq) {
   // read data from form elements
   for (int i = 0; i < lTargetInputList.size(); i++) {
     LLModel link = (LLModel) lTargetInputList.get(i).getUserObject();
     String linkValue = lTargetInputList.get(i).getValue();
     if (link.isIntern()) {
       if (!linkValue.contains("://") && !linkValue.startsWith("/")) {
         linkValue = "/".concat(linkValue.trim());
         lTargetInputList.get(i).setValue(linkValue);
       }
     } else if (!linkValue.contains("://")) {
       linkValue = "http://".concat(linkValue.trim());
       lTargetInputList.get(i).setValue(linkValue);
     }
     link.setTarget(linkValue);
     boolean blank = lHtmlTargetInputList.get(i).isSelected(0);
     if (linkValue.startsWith(Settings.getServerContextPathURI())) {
       // links to OO pages open in same window
       blank = false;
       lHtmlTargetInputList.get(i).select(SELF_KEY, true);
     }
     link.setHtmlTarget(blank ? BLANK_KEY : SELF_KEY);
     link.setDescription(lDescriptionInputList.get(i).getValue());
     link.setComment(lCommentInputList.get(i).getValue());
   }
   moduleConfig.set(LLCourseNode.CONF_LINKLIST, linkList);
   // Inform all listeners about the changes
   fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
 }
示例#2
0
  /**
   * Add a new form link line to the list of link elements.
   *
   * @param link the link model object
   */
  private void addNewFormLink(int index, final LLModel link) {
    // add link target
    TextElement lTarget =
        uifactory.addTextElement("target" + counter, null, -1, link.getTarget(), flc);
    lTarget.clearError();
    lTarget.setEnabled(!link.isIntern());
    lTarget.setDisplaySize(40);
    lTarget.setMandatory(true);
    lTarget.setExampleKey("target.example", null);
    lTarget.setNotEmptyCheck("ll.table.target.error");
    lTarget.setItemValidatorProvider(
        new ItemValidatorProvider() {
          public boolean isValidValue(
              String value, ValidationError validationError, Locale locale) {
            try {
              if (!value.contains("://")) {
                value = "http://".concat(value);
              }
              new URL(value);
            } catch (MalformedURLException e) {
              validationError.setErrorKey("ll.table.target.error.format");
              return false;
            }
            return true;
          }
        });
    lTarget.addActionListener(FormEvent.ONCHANGE);
    lTarget.setUserObject(link);
    lTargetInputList.add(index, lTarget);
    // add html target
    SingleSelection htmlTargetSelection =
        uifactory.addDropdownSingleselect(
            "html_target" + counter,
            flc,
            new String[] {BLANK_KEY, SELF_KEY},
            new String[] {
              translate("ll.table.html_target"), translate("ll.table.html_target.self")
            },
            null);
    htmlTargetSelection.setUserObject(link);
    htmlTargetSelection.select(
        (SELF_KEY.equals(link.getHtmlTarget()) ? SELF_KEY : BLANK_KEY), true);
    lHtmlTargetInputList.add(index, htmlTargetSelection);

    // add link description
    TextElement lDescription =
        uifactory.addTextElement("description" + counter, null, -1, link.getDescription(), flc);
    lDescription.clearError();
    lDescription.setDisplaySize(20);
    lDescription.setNotEmptyCheck("ll.table.description.error");
    lDescription.setMandatory(true);
    lDescription.setExampleKey("ll.table.description", null);
    lDescription.setUserObject(link);
    lDescriptionInputList.add(index, lDescription);

    // add link comment
    TextElement lComment =
        uifactory.addTextAreaElement(
            "comment" + counter, null, -1, 2, 50, true, link.getComment(), flc);
    lComment.setDisplaySize(20);
    lComment.setExampleKey("ll.table.comment", null);
    lComment.setUserObject(link);
    lCommentInputList.add(index, lComment);

    // add link add action button
    FormLink addButton =
        new FormLinkImpl(
            "add" + counter, "add" + counter, "", Link.BUTTON_SMALL + Link.NONTRANSLATED);
    addButton.setUserObject(link);
    addButton.setIconLeftCSS("o_icon o_icon-lg o_icon-fw o_icon_add");
    flc.add(addButton);
    lAddButtonList.add(index, addButton);
    // add link deletion action button
    FormLink delButton =
        new FormLinkImpl(
            "delete" + counter, "delete" + counter, "", Link.BUTTON_SMALL + Link.NONTRANSLATED);
    delButton.setUserObject(link);
    delButton.setIconLeftCSS("o_icon o_icon-lg o_icon-fw o_icon_delete_item");
    flc.add(delButton);
    lDelButtonList.add(index, delButton);
    // custom media action button
    FormLink mediaButton =
        new FormLinkImpl("media" + counter, "media" + counter, "  ", Link.NONTRANSLATED);
    mediaButton.setIconLeftCSS("o_icon o_icon_browse o_icon-lg");
    mediaButton.setUserObject(link);
    flc.add(mediaButton);
    lCustomMediaButtonList.add(index, mediaButton);

    // increase the counter to enable unique component names
    counter++;
  }