Search in sources :

Example 11 with ObjectTypeGuiDescriptor

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

the class SceneItemValuePanel method initLayout.

private void initLayout() {
    final VisibleEnableBehaviour visibleIfReference = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            SceneItemValue object = getModelObject();
            return hasValidReferenceValue(object);
        }
    };
    final VisibleEnableBehaviour visibleIfNotReference = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            SceneItemValue object = getModelObject();
            return !hasValidReferenceValue(object);
        }
    };
    IModel<DisplayType> displayModel = (IModel) () -> {
        ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor();
        String cssClass = ObjectTypeGuiDescriptor.ERROR_ICON;
        String title = null;
        if (guiDescriptor != null) {
            cssClass = guiDescriptor.getBlackIcon();
            title = createStringResource(guiDescriptor.getLocalizationKey()).getObject();
        }
        return GuiDisplayTypeUtil.createDisplayType(cssClass, "", title);
    };
    final ImagePanel icon = new ImagePanel(ID_ICON, displayModel);
    icon.add(visibleIfReference);
    add(icon);
    final Label label = new Label(ID_LABEL, new LabelModel());
    label.add(visibleIfNotReference);
    add(label);
    final AjaxLinkPanel link = new AjaxLinkPanel(ID_LINK, new LabelModel()) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (!(getModelObject().getSourceValue() instanceof PrismReferenceValue)) {
                return;
            }
            PrismReferenceValue refValue = (PrismReferenceValue) getModelObject().getSourceValue();
            if (refValue == null) {
                return;
            }
            ObjectReferenceType ort = new ObjectReferenceType();
            ort.setupReferenceValue(refValue);
            WebComponentUtil.dispatchToObjectDetailsPage(ort, getPageBase(), false);
        }
    };
    link.add(visibleIfReference);
    add(link);
    final Label additionalText = new Label(ID_ADDITIONAL_TEXT, new IModel<String>() {

        @Override
        public String getObject() {
            return getModelObject() != null ? getModelObject().getAdditionalText() : null;
        }
    });
    add(additionalText);
}
Also used : SceneItemValue(com.evolveum.midpoint.model.api.visualizer.SceneItemValue) IModel(org.apache.wicket.model.IModel) DisplayType(com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType) AjaxLinkPanel(com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel) Label(org.apache.wicket.markup.html.basic.Label) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ObjectTypeGuiDescriptor(com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ImagePanel(com.evolveum.midpoint.web.component.data.column.ImagePanel)

Aggregations

ObjectTypeGuiDescriptor (com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor)11 TooltipBehavior (com.evolveum.midpoint.web.util.TooltipBehavior)4 QName (javax.xml.namespace.QName)4 IModel (org.apache.wicket.model.IModel)4 ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)3 IconColumn (com.evolveum.midpoint.web.component.data.column.IconColumn)2 DisplayType (com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType)2 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)2 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)2 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)2 Label (org.apache.wicket.markup.html.basic.Label)2 Item (org.apache.wicket.markup.repeater.Item)2 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)2 SceneItemValue (com.evolveum.midpoint.model.api.visualizer.SceneItemValue)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 DateLabelComponent (com.evolveum.midpoint.web.component.DateLabelComponent)1 AjaxLinkPanel (com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel)1 ImagePanel (com.evolveum.midpoint.web.component.data.column.ImagePanel)1