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();
}
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);
}
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>");
}
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();
}
Aggregations