Search in sources :

Example 1 with LocalizationService

use of com.evolveum.midpoint.common.LocalizationService in project midpoint by Evolveum.

the class WebModelServiceUtils method translateMessage.

public static String translateMessage(OperationResult result, ModelServiceLocator page) {
    LocalizationService service = page.getLocalizationService();
    Locale locale = page.getLocale();
    return service.translate(result.getUserFriendlyMessage(), locale);
}
Also used : LocalizationService(com.evolveum.midpoint.common.LocalizationService)

Example 2 with LocalizationService

use of com.evolveum.midpoint.common.LocalizationService in project midpoint by Evolveum.

the class OperationResultPanel method createMessage.

private Label createMessage() {
    Label message = new Label(ID_MESSAGE_LABEL, (IModel<String>) () -> {
        OpResult result = OperationResultPanel.this.getModel().getObject();
        PageBase page = getPageBase();
        String msg = null;
        if (result.getUserFriendlyMessage() != null) {
            // TODO: unify with WebModelServiceUtil.translateMessage()
            LocalizationService service = page.getLocalizationService();
            Locale locale = page.getSession().getLocale();
            msg = service.translate(result.getUserFriendlyMessage(), locale);
        }
        if (StringUtils.isNotBlank(msg)) {
            return msg;
        }
        msg = result.getMessage();
        if (StringUtils.isNotBlank(msg)) {
            return msg;
        }
        String resourceKey = OPERATION_RESOURCE_KEY_PREFIX + result.getOperation();
        return page.getString(resourceKey, null, result.getOperation());
    });
    message.setOutputMarkupId(true);
    return message;
}
Also used : Locale(java.util.Locale) LocalizationService(com.evolveum.midpoint.common.LocalizationService) Label(org.apache.wicket.markup.html.basic.Label) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Aggregations

LocalizationService (com.evolveum.midpoint.common.LocalizationService)2 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)1 Locale (java.util.Locale)1 Label (org.apache.wicket.markup.html.basic.Label)1