Search in sources :

Example 1 with LayerIcon

use of com.evolveum.midpoint.gui.impl.component.icon.LayerIcon in project midpoint by Evolveum.

the class CompositedIconPanel method initLayout.

private void initLayout() {
    WebMarkupContainer layeredIcon = new WebMarkupContainer(ID_LAYERED_ICON);
    layeredIcon.add(AttributeAppender.append("title", (IModel<String>) () -> {
        if (getModelObject() != null && org.apache.commons.lang3.StringUtils.isNotBlank(getModelObject().getTitle())) {
            return getModelObject().getTitle();
        }
        return null;
    }));
    add(layeredIcon);
    WebComponent basicIcon = new WebComponent(ID_BASIC_ICON);
    basicIcon.add(AttributeAppender.append("class", (IModel<String>) () -> {
        if (getModelObject() != null && getModelObject().hasBasicIcon()) {
            return getModelObject().getBasicIcon();
        }
        return null;
    }));
    basicIcon.add(AttributeAppender.append("style", (IModel<String>) () -> {
        if (getModelObject() != null && getModelObject().hasBasicIcon() && getModelObject().hasBasicIconHtmlColor()) {
            return "color:" + getModelObject().getBasicIconHtmlColor();
        }
        return null;
    }));
    layeredIcon.add(basicIcon);
    ListView<LayerIcon> validationItems = new ListView<LayerIcon>(ID_LAYER_ICONS, new PropertyModel(getModel(), CompositedIcon.F_LAYER_ICONS)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<LayerIcon> item) {
            if (item.getModelObject() == null) {
                return;
            }
            if (StringUtils.isNotEmpty(item.getModelObject().getIconType().getCssClass())) {
                WebComponent icon = new WebComponent(ID_LAYER_ICON);
                icon.add(AttributeAppender.append("class", item.getModelObject().getIconType().getCssClass()));
                if (StringUtils.isNotEmpty(item.getModelObject().getIconType().getColor())) {
                    icon.add(AttributeAppender.append("style", "color: " + item.getModelObject().getIconType().getColor()));
                }
                item.add(icon);
            }
        }
    };
    layeredIcon.add(validationItems);
    add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject() != null;
        }
    });
}
Also used : WebComponent(org.apache.wicket.markup.html.WebComponent) IModel(org.apache.wicket.model.IModel) ListView(org.apache.wicket.markup.html.list.ListView) PropertyModel(org.apache.wicket.model.PropertyModel) ListItem(org.apache.wicket.markup.html.list.ListItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) LayerIcon(com.evolveum.midpoint.gui.impl.component.icon.LayerIcon) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 2 with LayerIcon

use of com.evolveum.midpoint.gui.impl.component.icon.LayerIcon in project midpoint by Evolveum.

the class AjaxCompositedIconButton method onComponentTagBody.

@Override
public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
    StringBuilder sb = new StringBuilder();
    CompositedIcon icon = this.icon;
    if (icon == null) {
        icon = buttonModel.getObject().getCompositedIcon();
    }
    if (icon.hasBasicIcon()) {
        sb.append("<i class=\"").append(icon.getBasicIcon()).append("\"");
        if (icon.hasBasicIconHtmlColor()) {
            sb.append(" style=\"color: " + icon.getBasicIconHtmlColor() + ";\"");
        }
        sb.append("></i> ");
        if (titleAsLabel) {
            sb.append("<span class=\"operationalButtonLabel\">").append(title.getObject()).append("</span>");
        }
    }
    if (icon.hasLayerIcons()) {
        for (LayerIcon entry : icon.getLayerIcons()) {
            if (entry == null) {
                continue;
            }
            if (StringUtils.isNotEmpty(entry.getIconType().getCssClass())) {
                sb.append("<i class=\"").append(entry.getIconType().getCssClass()).append("\"");
                if (StringUtils.isNotEmpty(entry.getIconType().getColor())) {
                    sb.append(" style=\"color: ").append(entry.getIconType().getColor()).append(";\"");
                }
                sb.append(">").append(entry.hasLabel() ? entry.getLabelModel().getObject() : "").append("</i> ");
            }
        }
    }
    replaceComponentTagBody(markupStream, openTag, sb.toString());
}
Also used : CompositedIcon(com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon) LayerIcon(com.evolveum.midpoint.gui.impl.component.icon.LayerIcon)

Example 3 with LayerIcon

use of com.evolveum.midpoint.gui.impl.component.icon.LayerIcon in project midpoint by Evolveum.

the class AjaxCompositedIconSubmitButton method onComponentTagBody.

@Override
public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
    StringBuilder sb = new StringBuilder();
    CompositedIcon icon = this.icon;
    if (icon.hasBasicIcon()) {
        sb.append("<i class=\"").append(icon.getBasicIcon() != null ? icon.getBasicIcon().trim() : "").append("\"");
        if (icon.hasBasicIconHtmlColor()) {
            sb.append(" style=\"color: " + icon.getBasicIconHtmlColor() + ";\"");
        }
        sb.append("></i> ");
        if (titleAsLabel) {
            sb.append("<span class=\"operationalButtonLabel\">").append(title.getObject()).append("</span>");
        }
    }
    if (icon.hasLayerIcons()) {
        for (LayerIcon entry : icon.getLayerIcons()) {
            if (entry == null) {
                continue;
            }
            if (StringUtils.isNotEmpty(entry.getIconType().getCssClass())) {
                sb.append("<i class=\"").append(entry.getIconType().getCssClass()).append("\"");
                if (StringUtils.isNotEmpty(entry.getIconType().getColor())) {
                    sb.append(" style=\"color: ").append(entry.getIconType().getColor()).append(";\"");
                }
                sb.append(">").append(entry.hasLabel() ? entry.getLabelModel().getObject() : "").append("</i> ");
            }
        }
    }
    replaceComponentTagBody(markupStream, openTag, sb.toString());
}
Also used : CompositedIcon(com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon) LayerIcon(com.evolveum.midpoint.gui.impl.component.icon.LayerIcon)

Aggregations

LayerIcon (com.evolveum.midpoint.gui.impl.component.icon.LayerIcon)3 CompositedIcon (com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 WebComponent (org.apache.wicket.markup.html.WebComponent)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)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 PropertyModel (org.apache.wicket.model.PropertyModel)1