Search in sources :

Example 6 with SingleKeyTranslatorController

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();
}
Also used : SingleKeyTranslatorController(org.olat.core.util.i18n.ui.SingleKeyTranslatorController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) QuestionsController(org.olat.modules.qpool.ui.QuestionsController)

Example 7 with SingleKeyTranslatorController

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;
}
Also used : StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) SingleKeyTranslatorController(org.olat.core.util.i18n.ui.SingleKeyTranslatorController)

Example 8 with SingleKeyTranslatorController

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();
            }
        }
    }
}
Also used : SingleKeyTranslatorController(org.olat.core.util.i18n.ui.SingleKeyTranslatorController) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController) FormToggle(org.olat.core.gui.components.form.flexible.elements.FormToggle) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 9 with SingleKeyTranslatorController

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;
}
Also used : StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) SingleKeyTranslatorController(org.olat.core.util.i18n.ui.SingleKeyTranslatorController)

Example 10 with SingleKeyTranslatorController

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();
            }
        }
    }
}
Also used : SingleKeyTranslatorController(org.olat.core.util.i18n.ui.SingleKeyTranslatorController) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) CloseableCalloutWindowController(org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController) FormToggle(org.olat.core.gui.components.form.flexible.elements.FormToggle) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Aggregations

SingleKeyTranslatorController (org.olat.core.util.i18n.ui.SingleKeyTranslatorController)12 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)4 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)4 QuestionsController (org.olat.modules.qpool.ui.QuestionsController)4 ArrayList (java.util.ArrayList)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 FormToggle (org.olat.core.gui.components.form.flexible.elements.FormToggle)2 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)2 CloseableCalloutWindowController (org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController)2 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)2