Search in sources :

Example 11 with Translator

use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.

the class FormLayoutContainer method replace.

public void replace(FormItem toBeReplaced, FormItem with) {
    String formCompName = toBeReplaced.getName();
    int pos = formComponentsNames.indexOf(formCompName);
    formComponentsNames.add(pos, with.getName());
    formComponentsNames.remove(formCompName);
    /*
		 * remove the gui representation
		 */
    formLayoutContainer.remove(toBeReplaced.getComponent());
    formLayoutContainer.remove(toBeReplaced.getErrorC());
    formLayoutContainer.remove(toBeReplaced.getExampleC());
    formLayoutContainer.remove(toBeReplaced.getLabelC());
    // set the formtranslator, and parent
    Translator itemTranslator = with.getTranslator();
    if (with.getTranslator() != null && itemTranslator instanceof PackageTranslator) {
        // let the FormItem provide a more specialized translator
        PackageTranslator itemPt = (PackageTranslator) itemTranslator;
        itemTranslator = PackageTranslator.cascadeTranslators(itemPt, translator);
    } else {
        itemTranslator = translator;
    }
    with.setTranslator(itemTranslator);
    with.setRootForm(getRootForm());
    formComponents.put(formCompName, with);
    /*
		 * add the gui representation
		 */
    formLayoutContainer.put(formCompName, with.getComponent());
    formLayoutContainer.put(formCompName + FormItem.ERRORC, with.getErrorC());
    formLayoutContainer.put(formCompName + FormItem.EXAMPLEC, with.getExampleC());
    formLayoutContainer.put(formCompName + FormItem.LABELC, with.getLabelC());
    // Check for multipart data, add upload limit to form
    if (with instanceof FormMultipartItem) {
        getRootForm().setMultipartEnabled(true);
    }
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator) FormMultipartItem(org.olat.core.gui.components.form.flexible.FormMultipartItem)

Example 12 with Translator

use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.

the class FormLayoutContainer method register.

/**
 * register only, does not addsubcomponents, does not expose formItem in the velocity.
 * In 99% of the cases you should use an addXX method instead.
 * @param formComp
 */
public void register(FormItem formComp) {
    if (!hasRootForm) {
        throw new AssertionError("first ensure that the layout container knows about its rootform!!");
    }
    // set the formtranslator, and parent
    Translator itemTranslator = formComp.getTranslator();
    if (formComp.getTranslator() != null && itemTranslator instanceof PackageTranslator) {
        // let the FormItem provide a more specialized translator
        PackageTranslator itemPt = (PackageTranslator) itemTranslator;
        itemTranslator = PackageTranslator.cascadeTranslators(itemPt, translator);
    } else {
        itemTranslator = translator;
    }
    formComp.setTranslator(itemTranslator);
    formComp.setRootForm(getRootForm());
    String formCompName = formComp.getName();
    // book keeping of FormComponent order
    listeningOnlyFormComponents.put(formCompName, formComp);
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator)

Example 13 with Translator

use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.

the class FileElementImpl method doConfirmDelete.

private void doConfirmDelete(UserRequest ureq) {
    Translator fileTranslator = Util.createPackageTranslator(FileElementImpl.class, ureq.getLocale(), getTranslator());
    String title = fileTranslator.translate("confirm.delete.file.title");
    String text = fileTranslator.translate("confirm.delete.file");
    dialogCtr = DialogBoxUIFactory.createOkCancelDialog(ureq, wControl, title, text);
    dialogCtr.addControllerListener(this);
    dialogCtr.activate();
}
Also used : Translator(org.olat.core.gui.translator.Translator)

Example 14 with Translator

use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.

the class JSDateChooserRenderer 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) {
    JSDateChooserComponent jsdcc = (JSDateChooserComponent) source;
    TextElementComponent teC = jsdcc.getTextElementComponent();
    String receiverId = teC.getFormDispatchId();
    String exDate = jsdcc.getExampleDateString();
    int maxlength = exDate.length() + 4;
    String triggerId = "trigger_" + jsdcc.getFormDispatchId();
    Translator sourceTranslator = jsdcc.getElementTranslator();
    Translator dateTranslator = Util.createPackageTranslator(JSDateChooserRenderer.class, translator.getLocale());
    // add pop js for date chooser, if componente is enabled
    sb.append("<div class='o_date form-inline'>");
    if (source.isEnabled()) {
        String format = jsdcc.getDateChooserDateFormat();
        TextElementImpl te = teC.getTextElementImpl();
        sb.append("<div class='form-group'><div class='input-group o_date_picker'>");
        renderTextElement(sb, teC, maxlength);
        // date chooser button
        sb.append("<span class='input-group-addon'>").append("<i class='o_icon o_icon_calendar' id=\"").append(triggerId).append("\" title=\"").append(StringEscapeUtils.escapeHtml(sourceTranslator.translate("calendar.choose"))).append("\"").append(" onclick=\"jQuery('#").append(receiverId).append("').datepicker('show');\"").append("></i></span>").append(// input-group
        "</div></div>");
        // date chooser javascript
        sb.append("<script>\n /* <![CDATA[ */ \n").append("jQuery(function(){ jQuery('#").append(receiverId).append("').datepicker({\n").append("  dateFormat:'").append(format).append("',\n").append("  firstDay:1,\n").append("  monthNames:[").append("'").append(dateTranslator.translate("month.long.jan")).append("',").append("'").append(dateTranslator.translate("month.long.feb")).append("',").append("'").append(dateTranslator.translate("month.long.mar")).append("',").append("'").append(dateTranslator.translate("month.long.apr")).append("',").append("'").append(dateTranslator.translate("month.long.mai")).append("',").append("'").append(dateTranslator.translate("month.long.jun")).append("',").append("'").append(dateTranslator.translate("month.long.jul")).append("',").append("'").append(dateTranslator.translate("month.long.aug")).append("',").append("'").append(dateTranslator.translate("month.long.sep")).append("',").append("'").append(dateTranslator.translate("month.long.oct")).append("',").append("'").append(dateTranslator.translate("month.long.nov")).append("',").append("'").append(dateTranslator.translate("month.long.dec")).append("'").append("],\n").append("  dayNamesMin:[").append("'").append(dateTranslator.translate("day.short.so")).append("',").append("'").append(dateTranslator.translate("day.short.mo")).append("',").append("'").append(dateTranslator.translate("day.short.di")).append("',").append("'").append(dateTranslator.translate("day.short.mi")).append("',").append("'").append(dateTranslator.translate("day.short.do")).append("',").append("'").append(dateTranslator.translate("day.short.fr")).append("',").append("'").append(dateTranslator.translate("day.short.sa")).append("'").append("],\n").append("  showOtherMonths:true,\n");
        if (jsdcc.getFormItem().getDefaultValue() != null) {
            String id = ((JSDateChooser) jsdcc.getFormItem().getDefaultValue()).getTextElementComponent().getFormDispatchId();
            sb.append("  beforeShow:function(el, inst) {\n").append("    var defDate = jQuery('#").append(id).append("').datepicker('getDate');\n").append("    jQuery('#").append(receiverId).append("').datepicker('option', 'defaultDate', defDate);").append("  },\n");
        }
        sb.append("  onSelect:function(){\n").append("    setFlexiFormDirty('").append(te.getRootForm().getDispatchFieldId()).append("');\n").append("    jQuery(this).change();\n").append("  }\n").append("})});").append("\n/* ]]> */ \n</script>");
        // input fields for hour and minute
        if (jsdcc.isDateChooserTimeEnabled()) {
            int hour, minute;
            Date currentDate = jsdcc.getDate();
            if (currentDate == null) {
                hour = minute = 0;
            } else {
                Calendar cal = Calendar.getInstance();
                cal.setTime(currentDate);
                hour = cal.get(Calendar.HOUR_OF_DAY);
                minute = cal.get(Calendar.MINUTE);
            }
            sb.append("<div class='form-group o_date_ms'>");
            renderMS(sb, "o_dch_" + receiverId, hour);
            sb.append(" : ");
            renderMS(sb, "o_dcm_" + receiverId, minute);
            sb.append("</div>");
        }
    } else {
        renderTextElementReadonly(sb, jsdcc, maxlength);
    }
    sb.append("</div>");
}
Also used : Translator(org.olat.core.gui.translator.Translator) Calendar(java.util.Calendar) Date(java.util.Date)

Example 15 with Translator

use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.

the class TextAreaElementImpl method setTranslator.

@Override
public void setTranslator(Translator translator) {
    // wrap package translator with fallback form translator
    // hint: do not take this.getClass() but the real class! for package translator creation
    Translator elmTranslator = Util.createPackageTranslator(TextAreaElementImpl.class, translator.getLocale(), translator);
    super.setTranslator(elmTranslator);
}
Also used : Translator(org.olat.core.gui.translator.Translator)

Aggregations

Translator (org.olat.core.gui.translator.Translator)586 Identity (org.olat.core.id.Identity)62 Date (java.util.Date)54 Controller (org.olat.core.gui.control.Controller)54 RepositoryEntry (org.olat.repository.RepositoryEntry)54 Locale (java.util.Locale)52 PackageTranslator (org.olat.core.gui.translator.PackageTranslator)46 ArrayList (java.util.ArrayList)40 TabbableController (org.olat.core.gui.control.generic.tabbable.TabbableController)40 NodeEditController (org.olat.course.editor.NodeEditController)40 TitleItem (org.olat.core.commons.services.notifications.model.TitleItem)36 Roles (org.olat.core.id.Roles)36 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)36 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)32 Publisher (org.olat.core.commons.services.notifications.Publisher)30 SubscriptionInfo (org.olat.core.commons.services.notifications.SubscriptionInfo)30 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)30 MailBundle (org.olat.core.util.mail.MailBundle)28 ICourse (org.olat.course.ICourse)26 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)26