use of org.olat.core.util.i18n.ui.SingleKeyTranslatorController in project openolat by klemens.
the class QItemTypesAdminController method doOpenTranslationTool.
private void doOpenTranslationTool(UserRequest ureq, QItemType row) {
String key2Translate = "item.type." + row.getType().toLowerCase();
String[] keys2Translate = { key2Translate };
singleKeyTrnsCtrl = new SingleKeyTranslatorController(ureq, getWindowControl(), keys2Translate, QuestionsController.class);
listenTo(singleKeyTrnsCtrl);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), "close", singleKeyTrnsCtrl.getInitialComponent(), true, translate("translation"));
listenTo(cmc);
cmc.activate();
}
use of org.olat.core.util.i18n.ui.SingleKeyTranslatorController in project openolat by klemens.
the class GenericSelectionPropertyHandlerController method validateFormLogic.
@Override
protected boolean validateFormLogic(UserRequest ureq) {
if (optionFieldNames.size() < 1) {
return false;
}
if (singleKeyTrsCtrl == null) {
singleKeyTrsCtrl = new SingleKeyTranslatorController(ureq, getWindowControl(), "", GenericSelectionPropertyHandler.class);
listenTo(singleKeyTrsCtrl);
}
for (int i = 0; i < optionFieldNames.size(); i++) {
TextElement te = (TextElement) hcFlc.getFormComponent(OPTFIELD_PREFIX + optionFieldNames.get(i));
String textValue = te.getValue();
if (StringHelper.containsNonWhitespace(textValue)) {
String translatedValue = I18nManager.getInstance().getLocalizedString(GenericSelectionPropertyHandler.class.getPackage().getName(), textValue, null, getLocale(), true, true);
if (translatedValue == null) {
txtError.setValue("Please translate all values");
txtError.setVisible(true);
return false;
}
}
}
txtError.setVisible(false);
return true;
}
use of org.olat.core.util.i18n.ui.SingleKeyTranslatorController in project openolat by klemens.
the class UsrPropCfgTableController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
UserPropertyHandler handler = (UserPropertyHandler) source.getUserObject();
if (source instanceof FormToggle) {
FormToggle toggle = (FormToggle) source;
if (toggle.isOn()) {
usrPropCfgMng.getUserPropertiesConfigObject().setHandlerAsActive(handler, true);
usrPropCfgMng.saveUserPropertiesConfig();
} else {
deactPropertyYesNoCtrl = activateYesNoDialog(ureq, translate("upc.deact_confirmationtitle"), translate("upc.deact_confirmationtext"), deactPropertyYesNoCtrl);
deactPropertyYesNoCtrl.setUserObject(handler);
}
} else if (source instanceof SingleSelection) {
SingleSelection groupSel = (SingleSelection) source;
handler.setGroup(groupSel.getSelectedKey());
usrPropCfgMng.saveUserPropertiesConfig();
} else if (source instanceof FormLink) {
String itemname = source.getName();
if (itemname.startsWith(FT_NAME_PREFIX_TRANSL)) {
// open the singlekeyTranslator-controller callout
String key2Translate1 = handler.i18nFormElementLabelKey();
String key2Translate2 = handler.i18nColumnDescriptorLabelKey();
String[] keys2Translate = { key2Translate1, key2Translate2 };
singleKeyTrnsCtrl = new SingleKeyTranslatorController(ureq, getWindowControl(), keys2Translate, UserPropertyHandler.class);
listenTo(singleKeyTrnsCtrl);
removeAsListenerAndDispose(translatorCallout);
translatorCallout = new CloseableCalloutWindowController(ureq, getWindowControl(), singleKeyTrnsCtrl.getInitialComponent(), (FormLink) source, "Translate:: " + key2Translate1, false, null);
listenTo(translatorCallout);
translatorCallout.activate();
} else if (itemname.startsWith(FT_NAME_PREFIX_HDNL)) {
handlerConfigCtrl = handlerConfigCtrlFactory.getConfigController(ureq, getWindowControl(), handler);
listenTo(handlerConfigCtrl);
if (handlerConfigCtrl.getInitialComponent() != null) {
handlerPopupCtr = new CloseableModalController(getWindowControl(), "Save", handlerConfigCtrl.getInitialComponent(), true, translate("upc.handlerconfigtitle"), false);
handlerPopupCtr.activate();
}
}
}
}
use of org.olat.core.util.i18n.ui.SingleKeyTranslatorController in project OpenOLAT by OpenOLAT.
the class GenericSelectionPropertyHandlerController method validateFormLogic.
@Override
protected boolean validateFormLogic(UserRequest ureq) {
if (optionFieldNames.size() < 1) {
return false;
}
if (singleKeyTrsCtrl == null) {
singleKeyTrsCtrl = new SingleKeyTranslatorController(ureq, getWindowControl(), "", GenericSelectionPropertyHandler.class);
listenTo(singleKeyTrsCtrl);
}
for (int i = 0; i < optionFieldNames.size(); i++) {
TextElement te = (TextElement) hcFlc.getFormComponent(OPTFIELD_PREFIX + optionFieldNames.get(i));
String textValue = te.getValue();
if (StringHelper.containsNonWhitespace(textValue)) {
String translatedValue = I18nManager.getInstance().getLocalizedString(GenericSelectionPropertyHandler.class.getPackage().getName(), textValue, null, getLocale(), true, true);
if (translatedValue == null) {
txtError.setValue("Please translate all values");
txtError.setVisible(true);
return false;
}
}
}
txtError.setVisible(false);
return true;
}
use of org.olat.core.util.i18n.ui.SingleKeyTranslatorController in project OpenOLAT by OpenOLAT.
the class UsrPropCfgTableController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
UserPropertyHandler handler = (UserPropertyHandler) source.getUserObject();
if (source instanceof FormToggle) {
FormToggle toggle = (FormToggle) source;
if (toggle.isOn()) {
usrPropCfgMng.getUserPropertiesConfigObject().setHandlerAsActive(handler, true);
usrPropCfgMng.saveUserPropertiesConfig();
} else {
deactPropertyYesNoCtrl = activateYesNoDialog(ureq, translate("upc.deact_confirmationtitle"), translate("upc.deact_confirmationtext"), deactPropertyYesNoCtrl);
deactPropertyYesNoCtrl.setUserObject(handler);
}
} else if (source instanceof SingleSelection) {
SingleSelection groupSel = (SingleSelection) source;
handler.setGroup(groupSel.getSelectedKey());
usrPropCfgMng.saveUserPropertiesConfig();
} else if (source instanceof FormLink) {
String itemname = source.getName();
if (itemname.startsWith(FT_NAME_PREFIX_TRANSL)) {
// open the singlekeyTranslator-controller callout
String key2Translate1 = handler.i18nFormElementLabelKey();
String key2Translate2 = handler.i18nColumnDescriptorLabelKey();
String[] keys2Translate = { key2Translate1, key2Translate2 };
singleKeyTrnsCtrl = new SingleKeyTranslatorController(ureq, getWindowControl(), keys2Translate, UserPropertyHandler.class);
listenTo(singleKeyTrnsCtrl);
removeAsListenerAndDispose(translatorCallout);
translatorCallout = new CloseableCalloutWindowController(ureq, getWindowControl(), singleKeyTrnsCtrl.getInitialComponent(), (FormLink) source, "Translate:: " + key2Translate1, false, null);
listenTo(translatorCallout);
translatorCallout.activate();
} else if (itemname.startsWith(FT_NAME_PREFIX_HDNL)) {
handlerConfigCtrl = handlerConfigCtrlFactory.getConfigController(ureq, getWindowControl(), handler);
listenTo(handlerConfigCtrl);
if (handlerConfigCtrl.getInitialComponent() != null) {
handlerPopupCtr = new CloseableModalController(getWindowControl(), "Save", handlerConfigCtrl.getInitialComponent(), true, translate("upc.handlerconfigtitle"), false);
handlerPopupCtr.activate();
}
}
}
}
Aggregations