Search in sources :

Example 6 with FileUploadWrapper

use of org.olat.modules.forms.ui.model.FileUploadWrapper in project openolat by klemens.

the class EvaluationFormController method forgeFileUpload.

private EvaluationFormElementWrapper forgeFileUpload(UserRequest ureq, FileUpload element) {
    FileElement fileEl = uifactory.addFileElement(getWindowControl(), "file_upload_" + CodeHelper.getRAMUniqueID(), "", flc);
    fileEl.setPreview(ureq.getUserSession(), true);
    fileEl.addActionListener(FormEvent.ONCHANGE);
    fileEl.setDeleteEnabled(true);
    fileEl.setMaxUploadSizeKB(element.getMaxUploadSizeKB(), "file.upload.error.limit.exeeded", null);
    Set<String> mimeTypes = MimeTypeSetFactory.getMimeTypes(element.getMimeTypeSetKey());
    fileEl.limitToMimeType(mimeTypes, "file.upload.error.mime.type.wrong", null);
    EvaluationFormResponse response = identifierToResponses.get(element.getId());
    File responseFile = evaluationFormManager.loadResponseFile(response);
    if (responseFile != null) {
        fileEl.setInitialFile(responseFile);
    }
    fileEl.setEnabled(!readOnly);
    FileUploadWrapper fileUploadWrapper = new FileUploadWrapper(fileEl, element);
    fileEl.setUserObject(fileUploadWrapper);
    EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
    wrapper.setFileUploadWrapper(fileUploadWrapper);
    return wrapper;
}
Also used : EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) FileElement(org.olat.core.gui.components.form.flexible.elements.FileElement) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) FileUploadWrapper(org.olat.modules.forms.ui.model.FileUploadWrapper) File(java.io.File)

Aggregations

FileUploadWrapper (org.olat.modules.forms.ui.model.FileUploadWrapper)6 File (java.io.File)4 FileElement (org.olat.core.gui.components.form.flexible.elements.FileElement)4 EvaluationFormElementWrapper (org.olat.modules.forms.ui.model.EvaluationFormElementWrapper)4 SliderWrapper (org.olat.modules.forms.ui.model.SliderWrapper)4 TextInputWrapper (org.olat.modules.forms.ui.model.TextInputWrapper)4 BigDecimal (java.math.BigDecimal)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)2 SliderElement (org.olat.core.gui.components.form.flexible.elements.SliderElement)2 FileElementEvent (org.olat.core.gui.components.form.flexible.impl.elements.FileElementEvent)2 EvaluationFormResponse (org.olat.modules.forms.EvaluationFormResponse)2 ValidationMessage (org.olat.modules.portfolio.ui.editor.ValidationMessage)2