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