Search in sources :

Example 1 with FileMediaResource

use of org.olat.core.gui.media.FileMediaResource in project OpenOLAT by OpenOLAT.

the class ReturnboxFullAccessCallback method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (source == taskLaunchButton) {
        File fTaskfolder = new File(FolderConfig.getCanonicalRoot() + TACourseNode.getTaskFolderPathRelToFolderRoot(userCourseEnv.getCourseEnvironment(), node));
        if (assignedTask.toLowerCase().endsWith(".html") || assignedTask.toLowerCase().endsWith(".htm") || assignedTask.toLowerCase().endsWith(".txt")) {
            // render content for other users always in iframe
            removeAsListenerAndDispose(iFrameCtr);
            iFrameCtr = new IFrameDisplayController(ureq, getWindowControl(), fTaskfolder);
            listenTo(iFrameCtr);
            iFrameCtr.setCurrentURI(assignedTask);
            removeAsListenerAndDispose(cmc);
            cmc = new CloseableModalController(getWindowControl(), translate("close"), iFrameCtr.getInitialComponent());
            listenTo(cmc);
            cmc.activate();
        } else {
            ureq.getDispatchResult().setResultingMediaResource(new FileMediaResource(new File(fTaskfolder, assignedTask)));
        }
    } else if (source == cancelTaskButton) {
        // confirm cancel task assignment
        dialogBoxController = this.activateYesNoDialog(ureq, "", translate("task.cancel.reassign"), dialogBoxController);
    }
}
Also used : IFrameDisplayController(org.olat.core.gui.control.generic.iframe.IFrameDisplayController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) FileMediaResource(org.olat.core.gui.media.FileMediaResource) File(java.io.File)

Example 2 with FileMediaResource

use of org.olat.core.gui.media.FileMediaResource in project OpenOLAT by OpenOLAT.

the class DirectoryController method doDownload.

private void doDownload(UserRequest ureq, File file) {
    if (file.getName().endsWith(".html")) {
        previewCtrl = new SinglePageController(ureq, getWindowControl(), documentsContainer, file.getName(), false);
        listenTo(previewCtrl);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), previewCtrl.getInitialComponent(), true, file.getName());
        listenTo(cmc);
        cmc.activate();
    } else {
        MediaResource mdr = new FileMediaResource(file, true);
        ureq.getDispatchResult().setResultingMediaResource(mdr);
    }
}
Also used : SinglePageController(org.olat.core.commons.modules.singlepage.SinglePageController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) FileMediaResource(org.olat.core.gui.media.FileMediaResource) FileMediaResource(org.olat.core.gui.media.FileMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) ZippedDirectoryMediaResource(org.olat.fileresource.ZippedDirectoryMediaResource)

Example 3 with FileMediaResource

use of org.olat.core.gui.media.FileMediaResource in project OpenOLAT by OpenOLAT.

the class GTAAssignedTaskController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (downloadLink == source) {
        if (taskFile.getName().endsWith(".html")) {
            doPreview(ureq);
        } else {
            MediaResource mdr = new FileMediaResource(taskFile, true);
            ureq.getDispatchResult().setResultingMediaResource(mdr);
        }
    } else if (downloadButton == source) {
        MediaResource mdr;
        if (taskFile.getName().endsWith(".html")) {
            File taskDir = gtaManager.getTasksDirectory(courseEnv, gtaNode);
            mdr = new HTMLZippedMediaResource(taskFile.getName(), taskDir);
        } else {
            mdr = new FileMediaResource(taskFile, true);
        }
        ureq.getDispatchResult().setResultingMediaResource(mdr);
    }
}
Also used : FileMediaResource(org.olat.core.gui.media.FileMediaResource) FileMediaResource(org.olat.core.gui.media.FileMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) File(java.io.File)

Example 4 with FileMediaResource

use of org.olat.core.gui.media.FileMediaResource in project OpenOLAT by OpenOLAT.

the class DisplayPortraitManager method getPortraitResource.

/**
 * Get the portrait media resource by identity name (username)
 * @param identity
 * @return imageResource portrait
 */
private MediaResource getPortraitResource(String username, String portraitName) {
    MediaResource imageResource = null;
    File imgFile = getPortraitFile(username, portraitName);
    if (imgFile != null && imgFile.exists()) {
        imageResource = new FileMediaResource(imgFile);
    }
    return imageResource;
}
Also used : FileMediaResource(org.olat.core.gui.media.FileMediaResource) FileMediaResource(org.olat.core.gui.media.FileMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) File(java.io.File)

Example 5 with FileMediaResource

use of org.olat.core.gui.media.FileMediaResource in project openolat by klemens.

the class DirectoryController method doDownload.

private void doDownload(UserRequest ureq, File file) {
    if (file.getName().endsWith(".html")) {
        previewCtrl = new SinglePageController(ureq, getWindowControl(), documentsContainer, file.getName(), false);
        listenTo(previewCtrl);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), previewCtrl.getInitialComponent(), true, file.getName());
        listenTo(cmc);
        cmc.activate();
    } else {
        MediaResource mdr = new FileMediaResource(file, true);
        ureq.getDispatchResult().setResultingMediaResource(mdr);
    }
}
Also used : SinglePageController(org.olat.core.commons.modules.singlepage.SinglePageController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) FileMediaResource(org.olat.core.gui.media.FileMediaResource) FileMediaResource(org.olat.core.gui.media.FileMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) ZippedDirectoryMediaResource(org.olat.fileresource.ZippedDirectoryMediaResource)

Aggregations

FileMediaResource (org.olat.core.gui.media.FileMediaResource)16 File (java.io.File)14 MediaResource (org.olat.core.gui.media.MediaResource)10 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 CustomStaticFolderManager (org.olat.admin.sysinfo.manager.CustomStaticFolderManager)2 SinglePageController (org.olat.core.commons.modules.singlepage.SinglePageController)2 ImageService (org.olat.core.commons.services.image.ImageService)2 IFrameDisplayController (org.olat.core.gui.control.generic.iframe.IFrameDisplayController)2 ForbiddenMediaResource (org.olat.core.gui.media.ForbiddenMediaResource)2 NotFoundMediaResource (org.olat.core.gui.media.NotFoundMediaResource)2 ZippedDirectoryMediaResource (org.olat.fileresource.ZippedDirectoryMediaResource)2