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);
}
}
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);
}
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();
}
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>");
}
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);
}
Aggregations