Exemple #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);
 }
Exemple #2
0
  @Override
  protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == mediaDialogBox) {
      removeAsListenerAndDispose(mediaDialogBox);
      removeAsListenerAndDispose(mediaChooserController);
      mediaDialogBox = null;
      mediaChooserController = null;
    } else if (source == mediaChooserController) {
      if (event instanceof URLChoosenEvent) {
        URLChoosenEvent choosenEvent = (URLChoosenEvent) event;
        String url = choosenEvent.getURL();
        if (url.startsWith(Settings.getServerContextPathURI())) {
          // doesn't allow absolute path -> the mapper check if the link is in the list!
          url = url.substring(Settings.getServerContextPathURI().length());
        }
        currentLink.setTarget(url);
        currentLink.setIntern(true);
        currentLink.setHtmlTarget(SELF_KEY);
        if (StringHelper.containsNonWhitespace(choosenEvent.getDisplayName())) {
          currentLink.setDescription(choosenEvent.getDisplayName());
        }

        int index = 0;
        for (TextElement targetEl : lTargetInputList) {
          if (currentLink.equals(targetEl.getUserObject())) {
            targetEl.setValue(url);
            targetEl.setEnabled(false);
            lDescriptionInputList.get(index).setValue(currentLink.getDescription());
            lHtmlTargetInputList.get(index).select(SELF_KEY, true);
            break;
          }
          index++;
        }
      }
      mediaDialogBox.deactivate();
      removeAsListenerAndDispose(mediaDialogBox);
      removeAsListenerAndDispose(mediaChooserController);
      mediaDialogBox = null;
      mediaChooserController = null;
    }

    super.event(ureq, source, event);
  }