Search in sources :

Example 1 with SummaryTag

use of com.evolveum.midpoint.web.component.util.SummaryTag in project midpoint by Evolveum.

the class AbstractSummaryPanel method getArchetypeSummaryTag.

private SummaryTag<C> getArchetypeSummaryTag() {
    // String archetypeIconCssClass = getArchetypeIconCssClass();
    // String archetypeIconColor = getArchetypePolicyAdditionalCssClass();
    // String archetypeLabel = getArchetypeLabel();
    // if (StringUtils.isNotEmpty(archetypeLabel)) {
    SummaryTag<C> archetypeSummaryTag = new SummaryTag<C>(ID_SUMMARY_TAG, getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void initialize(C object) {
            setIconCssClass(getArchetypeIconCssClass());
            setLabel(createStringResource(getArchetypeLabel()).getString());
            setColor(getArchetypePolicyAdditionalCssClass());
        }
    };
    archetypeSummaryTag.add(new VisibleBehaviour(() -> StringUtils.isNotEmpty(getArchetypeLabel())));
    return archetypeSummaryTag;
// }
// return null;
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) SummaryTag(com.evolveum.midpoint.web.component.util.SummaryTag)

Example 2 with SummaryTag

use of com.evolveum.midpoint.web.component.util.SummaryTag in project midpoint by Evolveum.

the class AbstractSummaryPanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    box = new WebMarkupContainer(ID_BOX);
    add(box);
    IModel<String> archetypePolicyAdditionalCssClassModel = () -> {
        String archetypePolicyAdditionalCssClass = getArchetypePolicyAdditionalCssClass();
        if (archetypePolicyAdditionalCssClass == null) {
            return "";
        }
        return "border-color: " + archetypePolicyAdditionalCssClass + ";";
    };
    box.add(new AttributeModifier("class", BOX_CSS_CLASS + " " + getBoxAdditionalCssClass()));
    box.add(AttributeModifier.append("style", archetypePolicyAdditionalCssClassModel));
    if (getDisplayNameModel() != null) {
        box.add(new Label(ID_DISPLAY_NAME, getDisplayNameModel()));
    } else if (getDisplayNamePropertyName() != null) {
        box.add(new Label(ID_DISPLAY_NAME, createLabelModel(getDisplayNamePropertyName(), SummaryPanelSpecificationType.F_DISPLAY_NAME)));
    } else {
        box.add(new Label(ID_DISPLAY_NAME, " "));
    }
    WebMarkupContainer identifierPanel = new WebMarkupContainer(ID_IDENTIFIER_PANEL);
    identifierPanel.add(new Label(ID_IDENTIFIER, createLabelModel(getIdentifierPropertyName(), SummaryPanelSpecificationType.F_IDENTIFIER)));
    identifierPanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isIdentifierVisible();
        }
    });
    box.add(identifierPanel);
    AjaxButton navigateToObject = new AjaxButton(ID_NAVIGATE_TO_OBJECT_BUTTON) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            ObjectReferenceType ort = getReferencedObjectToNavigate();
            WebComponentUtil.dispatchToObjectDetailsPage(ort, AbstractSummaryPanel.this, false);
        }
    };
    navigateToObject.add(AttributeAppender.append("title", getReferenceObjectTitleModel()));
    navigateToObject.add(new VisibleBehaviour(() -> {
        ObjectReferenceType ort = getReferencedObjectToNavigate();
        Class refType = !isReferencedObjectNull() ? WebComponentUtil.qnameToClass(AbstractSummaryPanel.this.getPageBase().getPrismContext(), ort.getType()) : null;
        return ort != null && refType != null && WebComponentUtil.getObjectDetailsPage(refType) != null;
    }));
    navigateToObject.setOutputMarkupId(true);
    box.add(navigateToObject);
    if (getTitleModel() != null) {
        box.add(new Label(ID_TITLE, getTitleModel()));
    } else if (getTitlePropertyName() != null) {
        box.add(new Label(ID_TITLE, createLabelModel(getTitlePropertyName(), SummaryPanelSpecificationType.F_TITLE_1)));
    } else {
        box.add(new Label(ID_TITLE, " "));
    }
    if (getTitle2Model() != null) {
        box.add(new Label(ID_TITLE2, getTitle2Model()));
    } else if (getTitle2PropertyName() != null) {
        box.add(new Label(ID_TITLE, createLabelModel(getTitle2PropertyName(), SummaryPanelSpecificationType.F_TITLE_2)));
    } else {
        Label label = new Label(ID_TITLE2, " ");
        label.setVisible(false);
        box.add(label);
    }
    if (getTitle3Model() != null) {
        box.add(new Label(ID_TITLE3, getTitle3Model()));
    } else if (getTitle3PropertyName() != null) {
        box.add(new Label(ID_TITLE, createLabelModel(getTitle3PropertyName(), SummaryPanelSpecificationType.F_TITLE_3)));
    } else {
        Label label = new Label(ID_TITLE3, " ");
        label.setVisible(false);
        box.add(label);
    }
    final IModel<String> parentOrgModel = getParentOrgModel();
    Label parentOrgLabel = new Label(ID_ORGANIZATION, parentOrgModel);
    parentOrgLabel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return parentOrgModel.getObject() != null;
        }
    });
    box.add(parentOrgLabel);
    iconBox = new WebMarkupContainer(ID_ICON_BOX);
    box.add(iconBox);
    String iconAdditionalCssClass = getIconBoxAdditionalCssClass();
    if (StringUtils.isNotEmpty(iconAdditionalCssClass)) {
        iconBox.add(new AttributeModifier("class", ICON_BOX_CSS_CLASS + " " + iconAdditionalCssClass));
    }
    iconBox.add(AttributeModifier.append("style", createArchetypeBackgroundModel()));
    Label icon = new Label(ID_ICON, "");
    icon.add(AttributeModifier.append("class", getIconCssClass()));
    // String archetypeIconCssClass = getArchetypeIconCssClass();
    // if (StringUtils.isNotEmpty(archetypeIconCssClass)) {
    // icon.add(AttributeModifier.append("class", archetypeIconCssClass));
    // icon.add(AttributeModifier.append("style", ARCHETYPE_ICON_FONT_SIZE));
    // } else {
    // icon.add(AttributeModifier.append("class", getDefaultIconCssClass()));
    // }
    icon.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getPhotoModel().getObject() == null;
        }
    });
    iconBox.add(icon);
    NonCachingImage img = new NonCachingImage(ID_PHOTO, getPhotoModel());
    img.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getPhotoModel().getObject() != null;
        }
    });
    iconBox.add(img);
    tagBox = new RepeatingView(ID_TAG_BOX);
    List<SummaryTag<C>> summaryTags = getSummaryTagComponentList();
    // if (getArchetypeSummaryTag() != null) {
    summaryTags.add(getArchetypeSummaryTag());
    // }
    summaryTags.forEach(summaryTag -> {
        WebMarkupContainer summaryTagPanel = new WebMarkupContainer(tagBox.newChildId());
        summaryTagPanel.setOutputMarkupId(true);
        summaryTagPanel.add(summaryTag);
        tagBox.add(summaryTagPanel);
    });
    if (getTagBoxCssClass() != null) {
        tagBox.add(new AttributeModifier("class", getTagBoxCssClass()));
    }
    tagBox.add(new VisibleBehaviour(() -> CollectionUtils.isNotEmpty(summaryTags)));
    box.add(tagBox);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) NonCachingImage(org.apache.wicket.markup.html.image.NonCachingImage) Label(org.apache.wicket.markup.html.basic.Label) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SummaryTag(com.evolveum.midpoint.web.component.util.SummaryTag) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 3 with SummaryTag

use of com.evolveum.midpoint.web.component.util.SummaryTag in project midpoint by Evolveum.

the class ResourceSummaryPanel method getSummaryTagComponentList.

@Override
protected List<SummaryTag<ResourceType>> getSummaryTagComponentList() {
    AvailabilityStatusType availability = ResourceTypeUtil.getLastAvailabilityStatus(getModelObject());
    AdministrativeAvailabilityStatusType administrativeAvailability = ResourceTypeUtil.getAdministrativeAvailabilityStatus(getModelObject());
    List<SummaryTag<ResourceType>> summaryTagList = new ArrayList<>();
    SummaryTag<ResourceType> summaryTag = new SummaryTag<ResourceType>(ID_SUMMARY_TAG, getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void initialize(ResourceType object) {
            if (AdministrativeAvailabilityStatusType.MAINTENANCE == administrativeAvailability) {
                setIconCssClass(GuiStyleConstants.CLASS_ICON_RESOURCE_MAINTENANCE);
                setLabel(ResourceSummaryPanel.this.getString(administrativeAvailability));
                return;
            }
            if (availability == null) {
                setIconCssClass(GuiStyleConstants.CLASS_ICON_RESOURCE_UNKNOWN);
                setLabel(getString("ResourceSummaryPanel.UNKNOWN"));
                return;
            } else {
                setLabel(ResourceSummaryPanel.this.getString(availability));
                switch(availability) {
                    case UP:
                        setIconCssClass(GuiStyleConstants.CLASS_ICON_ACTIVATION_ACTIVE);
                        break;
                    case DOWN:
                        setIconCssClass(GuiStyleConstants.CLASS_ICON_ACTIVATION_INACTIVE);
                        break;
                    case BROKEN:
                        setIconCssClass(GuiStyleConstants.CLASS_ICON_RESOURCE_BROKEN);
                        break;
                }
            }
        }
    };
    summaryTagList.add(summaryTag);
    return summaryTagList;
}
Also used : SummaryTag(com.evolveum.midpoint.web.component.util.SummaryTag) ArrayList(java.util.ArrayList) AdministrativeAvailabilityStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.AdministrativeAvailabilityStatusType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) AdministrativeAvailabilityStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.AdministrativeAvailabilityStatusType) AvailabilityStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.AvailabilityStatusType)

Example 4 with SummaryTag

use of com.evolveum.midpoint.web.component.util.SummaryTag in project midpoint by Evolveum.

the class CaseSummaryPanel method getSummaryTagComponentList.

@Override
protected List<SummaryTag<CaseType>> getSummaryTagComponentList() {
    List<SummaryTag<CaseType>> summaryTagList = new ArrayList<>();
    SummaryTag<CaseType> tagOutcome = new SummaryTag<CaseType>(ID_SUMMARY_TAG, getModel()) {

        @Override
        protected void initialize(CaseType taskType) {
            String icon, name;
            if (getModelObject().getOutcome() == null) {
                // shouldn't occur!
                return;
            }
            if (ApprovalUtils.approvalBooleanValueFromUri(getModelObject().getOutcome())) {
                icon = ApprovalOutcomeIcon.APPROVED.getIcon();
                name = "approved";
            } else {
                icon = ApprovalOutcomeIcon.REJECTED.getIcon();
                name = "rejected";
            }
            setIconCssClass(icon);
            setLabel(createStringResource("TaskSummaryPanel." + name).getString());
        }
    };
    tagOutcome.add(new VisibleBehaviour(() -> CaseSummaryPanel.this.getModelObject().getOutcome() != null));
    summaryTagList.add(tagOutcome);
    return summaryTagList;
}
Also used : CaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) SummaryTag(com.evolveum.midpoint.web.component.util.SummaryTag) ArrayList(java.util.ArrayList)

Example 5 with SummaryTag

use of com.evolveum.midpoint.web.component.util.SummaryTag in project midpoint by Evolveum.

the class FocusSummaryPanel method getSummaryTagComponentList.

@Override
protected List<SummaryTag<O>> getSummaryTagComponentList() {
    List<SummaryTag<O>> summaryTagList = new ArrayList<>();
    SummaryTag<O> tagActivation = new SummaryTag<>(ID_SUMMARY_TAG, getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void initialize(O object) {
            ActivationType activation = null;
            // O object = object.asObjectable();
            if (object instanceof FocusType) {
                activation = ((FocusType) object).getActivation();
            }
            if (activation == null) {
                setIconCssClass(GuiStyleConstants.CLASS_ICON_ACTIVATION_ACTIVE);
                setLabel(getString("ActivationStatusType.ENABLED"));
            } else if (activation.getEffectiveStatus() == ActivationStatusType.DISABLED) {
                setIconCssClass(GuiStyleConstants.CLASS_ICON_ACTIVATION_INACTIVE);
                setLabel(getString("ActivationStatusType.DISABLED"));
                setCssClass(GuiStyleConstants.CLASS_ICON_STYLE_DISABLED);
            } else if (activation.getEffectiveStatus() == ActivationStatusType.ARCHIVED) {
                setIconCssClass(GuiStyleConstants.CLASS_ICON_ACTIVATION_INACTIVE);
                setLabel(getString("ActivationStatusType.ARCHIVED"));
                setCssClass(GuiStyleConstants.CLASS_ICON_STYLE_ARCHIVED);
            } else {
                setIconCssClass(GuiStyleConstants.CLASS_ICON_ACTIVATION_ACTIVE);
                setLabel(getString("ActivationStatusType.ENABLED"));
            }
        }
    };
    tagActivation.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isActivationVisible();
        }
    });
    summaryTagList.add(tagActivation);
    return summaryTagList;
}
Also used : SummaryTag(com.evolveum.midpoint.web.component.util.SummaryTag) ArrayList(java.util.ArrayList) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Aggregations

SummaryTag (com.evolveum.midpoint.web.component.util.SummaryTag)7 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)4 ArrayList (java.util.ArrayList)4 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 AdministrativeAvailabilityStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.AdministrativeAvailabilityStatusType)1 AvailabilityStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.AvailabilityStatusType)1 CaseType (com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType)1 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)1 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)1 QName (javax.xml.namespace.QName)1 AttributeModifier (org.apache.wicket.AttributeModifier)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1 NonCachingImage (org.apache.wicket.markup.html.image.NonCachingImage)1 RepeatingView (org.apache.wicket.markup.repeater.RepeatingView)1