Search in sources :

Example 11 with DownloadLink

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

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 12 with DownloadLink

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

the class DialogElementListEditController method loadModel.

protected void loadModel() {
    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());
        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)

Example 13 with DownloadLink

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

the class DownloadComponentRenderer method render.

/**
 * @see org.olat.core.gui.components.ComponentRenderer#render(org.olat.core.gui.render.Renderer,
 *      org.olat.core.gui.render.StringOutput,
 *      org.olat.core.gui.components.Component,
 *      org.olat.core.gui.render.URLBuilder,
 *      org.olat.core.gui.translator.Translator,
 *      org.olat.core.gui.render.RenderResult, java.lang.String[])
 */
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    DownloadComponent comp = (DownloadComponent) source;
    if (comp.getDownloadMediaResoruce() == null)
        return;
    sb.append("<a id='o_c").append(comp.getDispatchID()).append("' href=\"");
    if (comp.getFormItem() != null) {
        DownloadLink formItem = comp.getFormItem();
        String linkText = formItem.getLinkText();
        ubu.createCopyFor(comp).buildURI(sb, null, null, linkText, AJAXFlags.MODE_NORMAL);
    } else {
        // rendered in new window anyway
        ubu.buildURI(sb, null, null, AJAXFlags.MODE_NORMAL);
    }
    sb.append("\"");
    // Tooltip
    String tip = comp.getLinkToolTip();
    if (tip != null) {
        sb.append(" title=\"").append(StringHelper.escapeHtml(tip)).append("\"");
    }
    sb.append(" target=\"_blank\">");
    // Icon css class
    String iconCssClass = comp.getLinkCssIconClass();
    // optional render argument
    String cssArg = (args != null && args.length > 1 ? args[0] : null);
    if (iconCssClass != null || cssArg != null) {
        sb.append("<i class=\"");
        if (iconCssClass != null) {
            sb.append("o_icon o_icon-fw ").append(iconCssClass).append(" ");
        }
        if (cssArg != null) {
            sb.append(cssArg);
        }
        sb.append("\"></i> ");
    }
    // Link Text
    String text = comp.getLinkText();
    if (text != null) {
        sb.append(text);
    }
    sb.append("</a>");
}
Also used : DownloadLink(org.olat.core.gui.components.form.flexible.elements.DownloadLink)

Example 14 with DownloadLink

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

the class CheckListBoxListEditController method updateModel.

private void updateModel() {
    CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
    List<CheckboxConfigRow> boxList = new ArrayList<CheckboxConfigRow>();
    if (list != null && list.getList() != null) {
        for (Checkbox checkbox : list.getList()) {
            DownloadLink download = null;
            VFSContainer container = checkboxManager.getFileContainer(courseEnv, courseNode);
            if (container != null) {
                VFSItem item = container.resolve(checkbox.getFilename());
                if (item instanceof VFSLeaf) {
                    download = uifactory.addDownloadLink("file_" + checkbox.getCheckboxId(), checkbox.getFilename(), null, (VFSLeaf) item, boxTable);
                }
            }
            boxList.add(new CheckboxConfigRow(checkbox, download));
        }
    }
    model.setObjects(boxList);
    boxTable.reset();
}
Also used : DownloadLink(org.olat.core.gui.components.form.flexible.elements.DownloadLink) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) Checkbox(org.olat.course.nodes.cl.model.Checkbox) VFSContainer(org.olat.core.util.vfs.VFSContainer) ArrayList(java.util.ArrayList) VFSItem(org.olat.core.util.vfs.VFSItem)

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