Search in sources :

Example 6 with DownloadLink

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

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

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

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)

Example 8 with DownloadLink

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

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

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

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

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

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)

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