Search in sources :

Example 71 with NameValuePair

use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project openolat by klemens.

the class AbstractFlexiTableRenderer method renderHeaderButtons.

protected void renderHeaderButtons(Renderer renderer, StringOutput sb, FlexiTableElementImpl ftE, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    Component searchCmp = ftE.getExtendedSearchComponent();
    if (searchCmp == null && !ftE.isExtendedSearchExpanded() && !ftE.isNumOfRowsEnabled() && !ftE.isFilterEnabled() && !ftE.isSortEnabled() && !ftE.isExportEnabled() && !ftE.isCustomizeColumns() && ftE.getAvailableRendererTypes().length <= 1) {
        return;
    }
    if (searchCmp != null && ftE.isExtendedSearchExpanded()) {
        renderer.render(searchCmp, sb, args);
    }
    sb.append("<div class='row clearfix o_table_toolbar'>").append("<div class='col-sm-6 col-xs-12 o_table_toolbar_left'>");
    if (searchCmp == null || !ftE.isExtendedSearchExpanded()) {
        renderHeaderSearch(renderer, sb, ftE, ubu, translator, renderResult, args);
    }
    sb.append("</div>");
    sb.append("<div class='col-sm-2 col-xs-4 o_table_row_count'>");
    if (ftE.isNumOfRowsEnabled()) {
        int rowCount = ftE.getTableDataModel().getRowCount();
        if (rowCount == 1) {
            sb.append(rowCount).append(" ").append(ftE.getTranslator().translate("table.entry"));
        } else if (rowCount > 1) {
            sb.append(rowCount).append(" ").append(ftE.getTranslator().translate("table.entries"));
        }
    }
    sb.append("</div><div class='col-sm-4 col-xs-8'><div class='pull-right'><div class='o_table_tools o_noprint'>");
    boolean empty = ftE.getTableDataModel().getRowCount() == 0;
    String filterIndication = null;
    // filter
    if (ftE.isFilterEnabled()) {
        List<FlexiTableFilter> filters = ftE.getFilters();
        if (filters != null && filters.size() > 0) {
            filterIndication = renderFilterDropdown(sb, ftE, filters);
        }
    }
    // sort
    if (ftE.isSortEnabled()) {
        List<FlexiTableSort> sorts = ftE.getSorts();
        if (sorts != null && sorts.size() > 0) {
            renderSortDropdown(sb, ftE, sorts);
        }
    }
    if (ftE.getExportButton() != null && ftE.isExportEnabled()) {
        sb.append("<div class='btn-group'>");
        ftE.getExportButton().setEnabled(!empty);
        renderFormItem(renderer, sb, ftE.getExportButton(), ubu, translator, renderResult, args);
        sb.append("</div> ");
    }
    if (ftE.getCustomButton() != null && ftE.isCustomizeColumns() && (ftE.getRendererType() == null || ftE.getRendererType() == FlexiTableRendererType.classic)) {
        sb.append("<div class='btn-group'>");
        renderFormItem(renderer, sb, ftE.getCustomButton(), ubu, translator, renderResult, args);
        sb.append("</div> ");
    }
    // switch type of tables
    FlexiTableRendererType[] types = ftE.getAvailableRendererTypes();
    if (types.length > 1) {
        sb.append("<div class='btn-group'>");
        for (FlexiTableRendererType type : types) {
            renderHeaderSwitchType(type, renderer, sb, ftE, ubu, translator, renderResult, args);
        }
        sb.append("</div> ");
    }
    sb.append("</div>");
    if (StringHelper.containsNonWhitespace(filterIndication)) {
        Form theForm = ftE.getRootForm();
        String dispatchId = ftE.getFormDispatchId();
        sb.append("<div class='o_table_tools_indications'>").append(filterIndication).append(" <a href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, dispatchId, 1, true, true, true, new NameValuePair("rm-filter", "true"))).append("\" title=\"").append(translator.translate("remove.filters")).append("\">").append("<i class='o_icon o_icon_remove o_icon-fw'> </i></a></div>");
    }
    sb.append("</div>");
    sb.append("</div></div>");
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) Component(org.olat.core.gui.components.Component) FlexiTableSort(org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)

Example 72 with NameValuePair

use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project openolat by klemens.

the class AbstractFlexiTableRenderer method renderPageNextLink.

private void renderPageNextLink(StringOutput sb, FlexiTableComponent ftC, int page, int maxPage) {
    boolean disabled = (page >= maxPage);
    FlexiTableElementImpl ftE = ftC.getFlexiTableElement();
    Form theForm = ftE.getRootForm();
    sb.append("<li ").append(" class='disabled'", disabled).append("><a href=\"");
    if (disabled) {
        sb.append("#");
    } else {
        sb.append("javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, ftC.getFormDispatchId(), 1, true, true, true, new NameValuePair("page", Integer.toString(page + 1))));
    }
    sb.append("\">").append("&raquo;").append("</a></li>");
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form)

Example 73 with NameValuePair

use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project openolat by klemens.

the class AbstractFlexiTableRenderer method appendPagenNumberLink.

private void appendPagenNumberLink(StringOutput sb, FlexiTableComponent ftC, int page, int i) {
    FlexiTableElementImpl ftE = ftC.getFlexiTableElement();
    Form theForm = ftE.getRootForm();
    sb.append("<li").append(" class='active'", (page == i)).append("><a href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, ftC.getFormDispatchId(), 1, true, true, true, new NameValuePair("page", Integer.toString(i)))).append(";\">").append(i + 1).append("</a></li>");
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form)

Example 74 with NameValuePair

use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project openolat by klemens.

the class RichTextElementRenderer method render.

@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    RichTextElementComponent teC = (RichTextElementComponent) source;
    RichTextElementImpl te = teC.getRichTextElementImpl();
    // DOM ID used to identify the rich text element in the browser DOM
    String domID = teC.getFormDispatchId();
    if (!source.isEnabled()) {
        renderDisabled(sb, domID, teC);
    } else {
        sb.append("<div id='").append(domID).append("_diw' class='o_richtext_mce");
        if (!te.getEditorConfiguration().isPathInStatusBar()) {
            sb.append(" o_richtext_mce_without_path");
        }
        sb.append("'>");
        // switches
        TextMode currentTextMode;
        if (te.getEditorConfiguration().getTextModes().size() > 1) {
            TextModeState textModeState = te.getAvailableTextModes();
            currentTextMode = textModeState.getCurrentMode();
            List<TextMode> modes = textModeState.getAvailableTextModes();
            if (modes.size() > 0) {
                Form form = te.getRootForm();
                sb.append("<div class='o_richtext_mce_modes'><div class='btn-group'>");
                for (TextMode mode : modes) {
                    sb.append("<a href='javascript:;' class='btn btn-default btn-xs").append(" active", currentTextMode == mode).append("'").append(" onclick=\"").append(FormJSHelper.getXHRFnCallFor(form, teC.getFormDispatchId(), 1, false, false, true, new NameValuePair("cmd", mode.name()))).append("\">").append(source.getTranslator().translate(mode.name())).append("</a>");
                }
                sb.append("</div></div>");
            }
        } else {
            currentTextMode = TextMode.formatted;
        }
        switch(currentTextMode) {
            case formatted:
                renderTinyMCE_4(sb, domID, teC, ubu, source.getTranslator());
                break;
            case multiLine:
                renderMultiLine(sb, domID, teC);
                break;
            case oneLine:
                renderOneLine(sb, domID, teC);
                break;
        }
        sb.append("</div>");
    }
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form) TextModeState(org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextElementImpl.TextModeState)

Example 75 with NameValuePair

use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project openolat by klemens.

the class RatingRenderer 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) {
    RatingComponent rating = (RatingComponent) source;
    sb.append("<div class='o_rating ");
    // Add custom css class
    if (rating.getCssClass() != null)
        sb.append(rating.getCssClass());
    sb.append("'>");
    // Add Title
    String title = rating.getTitle();
    if (title != null) {
        sb.append("<div class='o_rating_title'>");
        if (rating.isTranslateTitle()) {
            if (translator != null) {
                title = translator.translate(title);
            } else {
                title = "";
            }
        }
        sb.append(title);
        // o_rating_title
        sb.append("</div>");
    }
    // Add ratings and labels
    List<String> labels = rating.getRatingLabel();
    sb.append("<div class='o_rating_items");
    if (rating.isAllowUserInput()) {
        sb.append(" o_enabled");
    }
    sb.append("'>");
    for (int i = 0; i < labels.size(); i++) {
        // Add css class
        sb.append("<a class='o_icon o_icon-lg ");
        if (rating.getCurrentRating() >= i + 1) {
            sb.append("o_icon_rating_on");
        } else {
            sb.append("o_icon_rating_off");
        }
        sb.append("'");
        // Add action
        if (rating.isAllowUserInput() && rating.isEnabled()) {
            sb.append(" ");
            RatingFormItem rfi = rating.getFormItem();
            NameValuePair cmd = new NameValuePair(VelocityContainer.COMMAND_ID, Integer.toString(i + 1));
            if (rfi == null) {
                ubu.buildHrefAndOnclick(sb, true, cmd);
            } else {
                sb.append("href=\"javascript:;\" onclick=\"javascript:").append(FormJSHelper.getXHRFnCallFor(rfi.getRootForm(), rfi.getFormDispatchId(), 1, false, false, true, cmd)).append("\" ");
            }
        } else {
            // Disabled link
            sb.append(" href='javascript:;' onclick='return false;'");
        }
        // Add item label
        String label = rating.getRatingLabel(i);
        if (label != null) {
            if (rating.isTranslateRatingLabels()) {
                if (translator != null) {
                    label = translator.translate(label);
                } else {
                    label = "";
                }
            }
            sb.append(" title=\"").append(StringHelper.escapeHtml(label)).append("\"");
        }
        sb.append("></a>");
    }
    // Add text output
    if (rating.isShowRatingAsText()) {
        sb.append("<span class='o_legend'>");
        sb.append(Formatter.roundToString(rating.getCurrentRating(), 1));
        sb.append(" / ");
        sb.append(labels.size());
        sb.append("</span>");
    }
    // o_rating_items
    sb.append("</div>");
    // Add explanation
    String expl = rating.getExplanation();
    if (expl != null) {
        sb.append("<div class='o_rating_explanation'>");
        if (rating.isTranslateExplanation()) {
            if (translator != null) {
                expl = translator.translate(expl);
            } else {
                expl = "";
            }
        }
        sb.append(expl);
        // o_rating_explanation
        sb.append("</div>");
    }
    // o_rating
    sb.append("</div>");
    if (rating.getFormItem() != null) {
        RatingFormItem rfi = rating.getFormItem();
        FormJSHelper.appendFlexiFormDirtyForClick(sb, rfi.getRootForm(), rfi.getFormDispatchId());
    }
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair)

Aggregations

NameValuePair (org.olat.core.gui.components.form.flexible.impl.NameValuePair)80 Form (org.olat.core.gui.components.form.flexible.impl.Form)42 AssessmentRenderFunctions.contentAsString (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString)12 Component (org.olat.core.gui.components.Component)8 TestSessionController (uk.ac.ed.ph.jqtiplus.running.TestSessionController)6 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)6 FlexiTableFilter (org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)4 FlexiTableSort (org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)4 StringOutput (org.olat.core.gui.render.StringOutput)4 Translator (org.olat.core.gui.translator.Translator)4 VFSItem (org.olat.core.util.vfs.VFSItem)4 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)4 EffectiveItemSessionControl (uk.ac.ed.ph.jqtiplus.state.EffectiveItemSessionControl)3 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)3 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Matcher (java.util.regex.Matcher)2 FolderLicenseHandler (org.olat.core.commons.modules.bc.FolderLicenseHandler)2