예제 #1
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);
   }
 }
예제 #2
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);
    }
  }
  @Override
  protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source instanceof MultipleSelectionElement) {
      MultipleSelectionElement publishCheckbox = (MultipleSelectionElement) source;
      if (publishCheckbox.isEnabled()) {
        boolean enabled = publishCheckbox.isAtLeastSelected(1);
        String propName = (String) publishCheckbox.getUserObject();

        // load and update config
        HomePageConfig conf = hpcm.loadConfigFor(identityToModify.getName());
        conf.setEnabled(propName, enabled);
        hpcm.saveConfigTo(identityToModify.getName(), conf);
        updatePreview(ureq, conf);
      }
    }
    super.formInnerEvent(ureq, source, event);
  }
예제 #4
0
  private void create(MultipleSelectionElement selection, ICourse course, CourseNode parentNode) {
    SelectNodeObject node = (SelectNodeObject) selection.getUserObject();
    if (selection.isMultiselect() && selection.isSelected(0)) {
      VFSItem item = node.getItem();

      CourseNode newNode = null;
      if (item instanceof VFSLeaf) {
        // create node
        newNode = createCourseNode(item, "sp");
        ModuleConfiguration moduleConfig = newNode.getModuleConfiguration();
        String path = getRelativePath(item);
        moduleConfig.set(SPEditController.CONFIG_KEY_FILE, path);
        moduleConfig.setBooleanEntry(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS, true);
      } else if (item instanceof VFSContainer) {
        // add structure
        newNode = createCourseNode(item, "st");
      }

      int pos = -1;
      if (position >= 0 && selectedNode.getCourseNode().getIdent().equals(parentNode.getIdent())) {
        pos = position++;
      }

      if (pos < 0 || pos >= parentNode.getChildCount()) {
        course.getEditorTreeModel().addCourseNode(newNode, parentNode);
      } else {
        course.getEditorTreeModel().insertCourseNodeAt(newNode, parentNode, pos);
      }

      if (item instanceof VFSContainer) {
        parentNode = newNode;
      }
    }

    // recurse
    for (MultipleSelectionElement childElement : node.getChildren()) {
      create(childElement, course, parentNode);
    }
  }