Search in sources :

Example 1 with SingleLocalizableMessageType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SingleLocalizableMessageType in project midpoint by Evolveum.

the class InformationPanel method initLayout.

private void initLayout() {
    Label titleLabel = new Label(ID_TITLE, new LocalizableMessageModel(new IModel<LocalizableMessageType>() {

        @Override
        public LocalizableMessageType getObject() {
            InformationType info = getModelObject();
            if (info == null || info.getTitle() == null && info.getLocalizableTitle() == null) {
                return new SingleLocalizableMessageType().fallbackMessage("ApprovalStageDefinitionType.additionalInformation");
            }
            return getLocalizableMessageOrDefault(info.getLocalizableTitle(), info.getTitle());
        }
    }, this));
    titleLabel.add(new VisibleBehaviour(() -> getModelObject() != null));
    add(titleLabel);
    ListView<InformationPartType> list = new ListView<InformationPartType>(ID_PARTS, new PropertyModel<>(getModel(), InformationType.F_PART.getLocalPart())) {

        @Override
        protected void populateItem(ListItem<InformationPartType> item) {
            InformationPartType part = item.getModelObject();
            Label label = new Label(ID_PART, part != null ? WebComponentUtil.resolveLocalizableMessage(getLocalizableMessageOrDefault(part.getLocalizableText(), part.getText()), InformationPanel.this) : "");
            if (Boolean.TRUE.equals(part.isHasMarkup())) {
                label.setEscapeModelStrings(false);
            }
            item.add(label);
        }
    };
    add(list);
}
Also used : IModel(org.apache.wicket.model.IModel) ListView(org.apache.wicket.markup.html.list.ListView) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) LocalizableMessageModel(com.evolveum.midpoint.web.component.util.LocalizableMessageModel) ListItem(org.apache.wicket.markup.html.list.ListItem) InformationType(com.evolveum.midpoint.xml.ns._public.common.common_3.InformationType) InformationPartType(com.evolveum.midpoint.xml.ns._public.common.common_3.InformationPartType) SingleLocalizableMessageType(com.evolveum.midpoint.xml.ns._public.common.common_3.SingleLocalizableMessageType)

Example 2 with SingleLocalizableMessageType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SingleLocalizableMessageType in project midpoint by Evolveum.

the class LocalizationUtil method createLocalizableMessageType.

@NotNull
private static SingleLocalizableMessageType createLocalizableMessageType(@NotNull SingleLocalizableMessage message, Function<LocalizableMessage, String> resolveKeys) {
    SingleLocalizableMessageType rv = new SingleLocalizableMessageType();
    rv.setKey(message.getKey());
    if (message.getArgs() != null) {
        for (Object argument : message.getArgs()) {
            LocalizableMessageArgumentType messageArgument;
            if (argument instanceof LocalizableMessage) {
                messageArgument = new LocalizableMessageArgumentType().localizable(createLocalizableMessageType(((LocalizableMessage) argument), resolveKeys));
            } else {
                messageArgument = new LocalizableMessageArgumentType().value(argument != null ? argument.toString() : null);
            }
            rv.getArgument().add(messageArgument);
        }
    }
    if (message.getFallbackLocalizableMessage() != null) {
        rv.setFallbackLocalizableMessage(createLocalizableMessageType(message.getFallbackLocalizableMessage(), resolveKeys));
    }
    if (StringUtils.isBlank(message.getFallbackMessage()) && resolveKeys != null) {
        rv.setFallbackMessage(resolveKeys.apply(message));
    } else {
        rv.setFallbackMessage(message.getFallbackMessage());
    }
    return rv;
}
Also used : LocalizableMessageArgumentType(com.evolveum.midpoint.xml.ns._public.common.common_3.LocalizableMessageArgumentType) SingleLocalizableMessageType(com.evolveum.midpoint.xml.ns._public.common.common_3.SingleLocalizableMessageType) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

SingleLocalizableMessageType (com.evolveum.midpoint.xml.ns._public.common.common_3.SingleLocalizableMessageType)2 LocalizableMessageModel (com.evolveum.midpoint.web.component.util.LocalizableMessageModel)1 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)1 InformationPartType (com.evolveum.midpoint.xml.ns._public.common.common_3.InformationPartType)1 InformationType (com.evolveum.midpoint.xml.ns._public.common.common_3.InformationType)1 LocalizableMessageArgumentType (com.evolveum.midpoint.xml.ns._public.common.common_3.LocalizableMessageArgumentType)1 Label (org.apache.wicket.markup.html.basic.Label)1 ListItem (org.apache.wicket.markup.html.list.ListItem)1 ListView (org.apache.wicket.markup.html.list.ListView)1 IModel (org.apache.wicket.model.IModel)1 NotNull (org.jetbrains.annotations.NotNull)1