Search in sources :

Example 76 with FormLink

use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.

the class VideoTrackEditController method forgeRow.

private TrackTableRow forgeRow(String language, VFSLeaf track) {
    FormLink delButton = uifactory.addFormLink("lang_".concat(language), "deleteTrack", "track.delete", "track.delete", null, Link.LINK);
    delButton.setIconLeftCSS("o_icon o_icon-fw o_icon_delete_item");
    TrackTableRow row = new TrackTableRow(language, track, delButton);
    delButton.setUserObject(row);
    return row;
}
Also used : FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 77 with FormLink

use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.

the class VideoQualityTableFormController method initTable.

private void initTable() {
    List<QualityTableRow> rows = new ArrayList<>();
    VideoMeta videoMetadata = videoManager.getVideoMetadata(videoResource);
    // Add master video file
    FormLink previewMasterLink = uifactory.addFormLink("view", "viewQuality", "quality.master", "quality.master", flc, Link.LINK);
    Object[] statusMaster = new Object[] { 100, Formatter.formatBytes(videoManager.getVideoFile(videoResource).length()) };
    rows.add(new QualityTableRow(previewMasterLink, videoMetadata.getWidth() + "x" + videoMetadata.getHeight(), statusMaster, "mp4", null));
    // Add all the transcoded versions
    List<VideoTranscoding> videoTranscodings = videoManager.getVideoTranscodings(videoResource);
    for (VideoTranscoding videoTranscoding : videoTranscodings) {
        String title = videoManager.getDisplayTitleForResolution(videoTranscoding.getResolution(), getTranslator());
        FormLink previewVersionLink = uifactory.addFormLink("res_" + count++, "viewQuality", title, title, flc, Link.LINK + Link.NONTRANSLATED);
        FormLink deleteLink = uifactory.addFormLink("del_" + count++, "deleteQuality", "quality.delete", "quality.delete", flc, Link.LINK);
        deleteLink.setUserObject(videoTranscoding);
        deleteLink.setIconLeftCSS("o_icon o_icon_delete_item o_icon-fw");
        previewVersionLink.setUserObject(videoTranscoding);
        if (videoTranscoding.getStatus() < VideoTranscoding.TRANSCODING_STATUS_DONE) {
            previewVersionLink.setEnabled(false);
        }
        int width = videoTranscoding.getWidth();
        int height = videoTranscoding.getHeight();
        String dimension = width + "x" + height;
        String fileSize = "";
        int status = videoTranscoding.getStatus();
        if (videoTranscoding.getSize() != 0 && status > -1) {
            fileSize = Formatter.formatBytes(videoTranscoding.getSize());
        } else if (status == VideoTranscoding.TRANSCODING_STATUS_WAITING) {
            fileSize = translate("transcoding.waiting");
        } else if (status <= VideoTranscoding.TRANSCODING_STATUS_DONE && status > -1) {
            fileSize = translate("transcoding.processing") + ": " + videoTranscoding.getStatus() + "%";
        } else if (status == VideoTranscoding.TRANSCODING_STATUS_INEFFICIENT) {
            fileSize = translate("transcoding.inefficient");
        } else if (status == VideoTranscoding.TRANSCODING_STATUS_ERROR) {
            fileSize = translate("transcoding.error");
        } else if (status == VideoTranscoding.TRANSCODING_STATUS_TIMEOUT) {
            fileSize = translate("transcoding.timeout");
        }
        Object[] statusTranscoding = new Object[] { status, fileSize };
        rows.add(new QualityTableRow(previewVersionLink, dimension, statusTranscoding, videoTranscoding.getFormat(), deleteLink));
    }
    List<Integer> missingResolutions = videoManager.getMissingTranscodings(videoResource);
    if (videoModule.isTranscodingEnabled()) {
        for (Integer missingRes : missingResolutions) {
            if (missingRes <= videoMetadata.getHeight()) {
                String title = videoManager.getDisplayTitleForResolution(missingRes, getTranslator());
                FormLink transcodeLink = uifactory.addFormLink("res_" + count++, "startTranscoding", "quality.transcode", "quality.transcode", flc, Link.LINK);
                transcodeLink.setUserObject(missingRes);
                transcodeLink.setIconLeftCSS("o_icon o_icon_refresh o_icon-fw");
                FormLink previewMissingLink = uifactory.addFormLink("res_" + count++, "viewQuality", title, title, flc, Link.LINK + Link.NONTRANSLATED);
                previewMissingLink.setEnabled(false);
                Object[] status = new Object[] { -1, "-" };
                rows.add(new QualityTableRow(previewMissingLink, missingRes.toString(), status, "mp4", transcodeLink));
            }
        }
    }
    rows.sort(new VideoComparator());
    tableModel.setObjects(rows);
    if (flc.hasFormComponent(tableEl)) {
        flc.remove(tableEl);
    }
    if (flc.hasFormComponent(refreshbtn)) {
        flc.remove(refreshbtn);
    }
    tableEl = uifactory.addTableElement(getWindowControl(), "qualityTable", tableModel, getTranslator(), flc);
    tableEl.setCustomizeColumns(false);
    tableEl.setNumOfRowsEnabled(false);
    refreshbtn = uifactory.addFormLink("button.refresh", flc, Link.BUTTON);
    refreshbtn.setIconLeftCSS("o_icon o_icon_refresh o_icon-fw");
}
Also used : VideoMeta(org.olat.modules.video.VideoMeta) VideoTranscoding(org.olat.modules.video.VideoTranscoding) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 78 with FormLink

use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.

the class VideoQualityTableFormController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source instanceof FormLink && ((FormLink) source).getCmd().equals("viewQuality")) {
        if (cmc == null) {
            // initialize preview controller only once
            previewVC = createVelocityContainer("video_preview");
            cmc = new CloseableModalController(getWindowControl(), "close", previewVC);
            listenTo(cmc);
        }
        // Get the user object from the link to access version object
        FormLink link = (FormLink) source;
        VideoTranscoding videoTranscoding = (VideoTranscoding) link.getUserObject();
        if (videoTranscoding == null) {
            // this is the master video
            // VideoMetadata videoMetadata = videoManager.readVideoMetadataFile(videoResource);
            VideoMeta videoMetadata = videoManager.getVideoMetadata(videoResource);
            previewVC.contextPut("width", videoMetadata.getWidth());
            previewVC.contextPut("height", videoMetadata.getHeight());
            previewVC.contextPut("filename", "video.mp4");
            VFSContainer container = videoManager.getMasterContainer(videoResource);
            String transcodedUrl = registerMapper(ureq, new VideoMediaMapper(container));
            previewVC.contextPut("mediaUrl", transcodedUrl);
        } else {
            // this is a version
            previewVC.contextPut("width", videoTranscoding.getWidth());
            previewVC.contextPut("height", videoTranscoding.getHeight());
            previewVC.contextPut("filename", videoTranscoding.getResolution() + "video.mp4");
            VFSContainer container = videoManager.getTranscodingContainer(videoResource);
            String transcodedUrl = registerMapper(ureq, new VideoMediaMapper(container));
            previewVC.contextPut("mediaUrl", transcodedUrl);
        }
        // activate dialog to bring it in front
        cmc.activate();
    } else if (source instanceof FormLink && ((FormLink) source).getCmd().equals("deleteQuality")) {
        FormLink link = (FormLink) source;
        VideoTranscoding videoTranscoding = (VideoTranscoding) link.getUserObject();
        videoManager.deleteVideoTranscoding(videoTranscoding);
    } else if (source instanceof FormLink && ((FormLink) source).getCmd().equals("startTranscoding")) {
        videoManager.createTranscoding(videoResource, (int) source.getUserObject(), "mp4");
    }
    initTable();
}
Also used : VideoMeta(org.olat.modules.video.VideoMeta) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) VideoTranscoding(org.olat.modules.video.VideoTranscoding) VFSContainer(org.olat.core.util.vfs.VFSContainer) VideoMediaMapper(org.olat.modules.video.manager.VideoMediaMapper) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 79 with FormLink

use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.

the class VideoQualityTableFormController method event.

@Override
protected void event(UserRequest ureq, Controller source, org.olat.core.gui.control.Event event) {
    if (source instanceof FormLink && ((FormLink) source).getCmd().equals("viewQuality")) {
        if (cmc == null) {
            // initialize preview controller only once
            previewVC = createVelocityContainer("video_preview");
            cmc = new CloseableModalController(getWindowControl(), "close", previewVC);
            listenTo(cmc);
        }
    }
    super.event(ureq, source, event);
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 80 with FormLink

use of org.olat.core.gui.components.form.flexible.elements.FormLink in project OpenOLAT by OpenOLAT.

the class TaxonomyListAdminController method forgeTaxonomyRow.

private TaxonomyRow forgeTaxonomyRow(TaxonomyInfos taxonomy) {
    String openLinkId = "open_" + (++counter);
    FormLink openLink = uifactory.addFormLink(openLinkId, "open.taxonomy", "open.taxonomy", null, flc, Link.LINK);
    openLink.setIconRightCSS("o_icon o_icon_start");
    boolean docPoolEnabled = taxonomy.getKey().toString().equals(docPoolModule.getTaxonomyTreeKey());
    boolean qPoolEnabled = taxonomy.getKey().toString().equals(questionPoolModule.getTaxonomyQPoolKey());
    String docPoolLinkId = "dpool_" + (++counter);
    String docPoolString = docPoolEnabled ? translate("taxonomy.infos.enabled") : translate("taxonomy.infos.not.enabled");
    FormLink docPoolLink = uifactory.addFormLink(docPoolLinkId, "open.docpool", docPoolString, null, flc, Link.LINK | Link.NONTRANSLATED);
    String qPoolLinkId = "qpool_" + (++counter);
    String qPoolString = qPoolEnabled ? translate("taxonomy.infos.enabled") : translate("taxonomy.infos.not.enabled");
    FormLink qPoolLink = uifactory.addFormLink(qPoolLinkId, "open.qpool", qPoolString, null, flc, Link.LINK | Link.NONTRANSLATED);
    TaxonomyRow row = new TaxonomyRow(taxonomy, docPoolEnabled, qPoolEnabled, openLink, docPoolLink, qPoolLink);
    openLink.setUserObject(row);
    docPoolLink.setUserObject(row);
    qPoolLink.setUserObject(row);
    return row;
}
Also used : FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Aggregations

FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)376 ArrayList (java.util.ArrayList)108 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)64 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)40 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)36 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)34 List (java.util.List)30 FormItem (org.olat.core.gui.components.form.flexible.FormItem)28 HashMap (java.util.HashMap)26 FlexiTableSearchEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)24 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)22 Date (java.util.Date)18 Map (java.util.Map)18 Link (org.olat.core.gui.components.link.Link)18 Identity (org.olat.core.id.Identity)18 Component (org.olat.core.gui.components.Component)16 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)16 FormEvent (org.olat.core.gui.components.form.flexible.impl.FormEvent)16 Controller (org.olat.core.gui.control.Controller)16 Event (org.olat.core.gui.control.Event)16