Search in sources :

Example 1 with DownloadLink

use of org.olat.core.gui.components.form.flexible.elements.DownloadLink in project OpenOLAT by OpenOLAT.

the class CheckListRunController method forgeCheckboxWrapper.

private CheckboxWrapper forgeCheckboxWrapper(Checkbox checkbox, DBCheck check, boolean readOnly, FormItemContainer formLayout) {
    String[] values = new String[] { translate(checkbox.getLabel().i18nKey()) };
    boolean canCheck = CheckboxReleaseEnum.userAndCoach.equals(checkbox.getRelease());
    String boxId = "box_" + checkbox.getCheckboxId();
    MultipleSelectionElement el = uifactory.addCheckboxesHorizontal(boxId, null, formLayout, onKeys, values);
    el.setEnabled(canCheck && !readOnly && !userCourseEnv.isCourseReadOnly());
    el.addActionListener(FormEvent.ONCHANGE);
    DownloadLink downloadLink = null;
    if (StringHelper.containsNonWhitespace(checkbox.getFilename())) {
        VFSContainer container = checkboxManager.getFileContainer(userCourseEnv.getCourseEnvironment(), courseNode);
        VFSItem item = container.resolve(checkbox.getFilename());
        if (item instanceof VFSLeaf) {
            String name = "file_" + checkbox.getCheckboxId();
            downloadLink = uifactory.addDownloadLink(name, checkbox.getFilename(), null, (VFSLeaf) item, formLayout);
        }
    }
    CheckboxWrapper wrapper = new CheckboxWrapper(checkbox, downloadLink, el);
    el.setUserObject(wrapper);
    if (check != null && check.getChecked() != null && check.getChecked().booleanValue()) {
        el.select(onKeys[0], true);
        wrapper.setDbCheckbox(check.getCheckbox());
        wrapper.setScore(check.getScore());
    }
    if (downloadLink != null) {
        downloadLink.setUserObject(wrapper);
    }
    return wrapper;
}
Also used : DownloadLink(org.olat.core.gui.components.form.flexible.elements.DownloadLink) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 2 with DownloadLink

use of org.olat.core.gui.components.form.flexible.elements.DownloadLink in project OpenOLAT by OpenOLAT.

the class GTASampleSolutionsEditController method updateModel.

private void updateModel() {
    List<Solution> solutionList = gtaManager.getSolutions(courseEnv, gtaNode);
    List<SolutionRow> rows = new ArrayList<>(solutionList.size());
    for (Solution solution : solutionList) {
        String filename = solution.getFilename();
        String author = null;
        VFSItem item = solutionContainer.resolve(filename);
        if (item instanceof MetaTagged) {
            MetaInfo metaInfo = ((MetaTagged) item).getMetaInfo();
            if (metaInfo != null && metaInfo.getAuthorIdentityKey() != null) {
                author = userManager.getUserDisplayName(metaInfo.getAuthorIdentityKey());
            }
        }
        DownloadLink downloadLink = null;
        if (item instanceof VFSLeaf) {
            downloadLink = uifactory.addDownloadLink("file_" + (++linkCounter), filename, null, (VFSLeaf) item, solutionTable);
        }
        rows.add(new SolutionRow(solution, author, downloadLink));
    }
    solutionModel.setObjects(rows);
    solutionTable.reset();
}
Also used : DownloadLink(org.olat.core.gui.components.form.flexible.elements.DownloadLink) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ArrayList(java.util.ArrayList) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) VFSItem(org.olat.core.util.vfs.VFSItem) Solution(org.olat.course.nodes.gta.model.Solution)

Example 3 with DownloadLink

use of org.olat.core.gui.components.form.flexible.elements.DownloadLink in project OpenOLAT by OpenOLAT.

the class DialogElementListController method loadModel.

protected void loadModel() {
    RepositoryEntry entry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    List<DialogElement> elements = dialogElementsManager.getDialogElements(entry, courseNode.getIdent());
    List<DialogElementRow> rows = new ArrayList<>(elements.size());
    for (DialogElement element : elements) {
        DialogElementRow row = new DialogElementRow(element, userPropertyHandlers, getLocale());
        int msgCount = forumManager.countMessagesByForumID(element.getForum().getKey());
        int newMsg = msgCount - forumManager.countReadMessagesByUserAndForum(getIdentity(), element.getForum().getKey());
        row.setNumOfMessages(msgCount);
        row.setNumOfUnreadMessages(newMsg);
        VFSLeaf item = dialogElementsManager.getDialogLeaf(element);
        if (item != null) {
            DownloadLink downloadLink = uifactory.addDownloadLink("file_" + (++counter), row.getFilename(), null, item, flc);
            row.setDownloadLink(downloadLink);
        }
        rows.add(row);
    }
    tableModel.setObjects(rows);
    tableEl.reset(true, true, true);
}
Also used : DownloadLink(org.olat.core.gui.components.form.flexible.elements.DownloadLink) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ArrayList(java.util.ArrayList) DialogElement(org.olat.course.nodes.dialog.DialogElement) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 4 with DownloadLink

use of org.olat.core.gui.components.form.flexible.elements.DownloadLink in project OpenOLAT by OpenOLAT.

the class AbstractAssignmentEditController method updateModel.

protected void updateModel() {
    fileExistsRenderer.setFilenames(tasksFolder.list());
    List<TaskDefinition> taskDefinitions = gtaManager.getTaskDefinitions(courseEnv, gtaNode);
    List<TaskDefinitionRow> rows = new ArrayList<>(taskDefinitions.size());
    for (TaskDefinition def : taskDefinitions) {
        DownloadLink downloadLink = null;
        VFSItem item = tasksContainer.resolve(def.getFilename());
        if (item instanceof VFSLeaf) {
            downloadLink = uifactory.addDownloadLink("file_" + (++linkCounter), def.getFilename(), null, (VFSLeaf) item, taskDefTableEl);
        }
        rows.add(new TaskDefinitionRow(def, downloadLink));
    }
    taskModel.setObjects(rows);
    taskDefTableEl.reset();
}
Also used : DownloadLink(org.olat.core.gui.components.form.flexible.elements.DownloadLink) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) TaskDefinition(org.olat.course.nodes.gta.model.TaskDefinition) ArrayList(java.util.ArrayList) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 5 with DownloadLink

use of org.olat.core.gui.components.form.flexible.elements.DownloadLink in project openolat by klemens.

the class DialogElementListController method loadModel.

protected void loadModel() {
    RepositoryEntry entry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    List<DialogElement> elements = dialogElementsManager.getDialogElements(entry, courseNode.getIdent());
    List<DialogElementRow> rows = new ArrayList<>(elements.size());
    for (DialogElement element : elements) {
        DialogElementRow row = new DialogElementRow(element, userPropertyHandlers, getLocale());
        int msgCount = forumManager.countMessagesByForumID(element.getForum().getKey());
        int newMsg = msgCount - forumManager.countReadMessagesByUserAndForum(getIdentity(), element.getForum().getKey());
        row.setNumOfMessages(msgCount);
        row.setNumOfUnreadMessages(newMsg);
        VFSLeaf item = dialogElementsManager.getDialogLeaf(element);
        if (item != null) {
            DownloadLink downloadLink = uifactory.addDownloadLink("file_" + (++counter), row.getFilename(), null, item, flc);
            row.setDownloadLink(downloadLink);
        }
        rows.add(row);
    }
    tableModel.setObjects(rows);
    tableEl.reset(true, true, true);
}
Also used : DownloadLink(org.olat.core.gui.components.form.flexible.elements.DownloadLink) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ArrayList(java.util.ArrayList) DialogElement(org.olat.course.nodes.dialog.DialogElement) RepositoryEntry(org.olat.repository.RepositoryEntry)

Aggregations

DownloadLink (org.olat.core.gui.components.form.flexible.elements.DownloadLink)14 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)12 ArrayList (java.util.ArrayList)10 VFSItem (org.olat.core.util.vfs.VFSItem)8 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 DialogElement (org.olat.course.nodes.dialog.DialogElement)4 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)2 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)2 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)2 Checkbox (org.olat.course.nodes.cl.model.Checkbox)2 CheckboxList (org.olat.course.nodes.cl.model.CheckboxList)2 Solution (org.olat.course.nodes.gta.model.Solution)2 TaskDefinition (org.olat.course.nodes.gta.model.TaskDefinition)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2