Search in sources :

Example 16 with DisplayType

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

the class LinkedReferencePanel method initLayout.

private void initLayout() {
    setOutputMarkupId(true);
    IModel<DisplayType> displayModel = new ReadOnlyModel<>(() -> {
        PrismReferenceValue ref = referenceModel.getObject();
        if (ref == null) {
            return null;
        }
        DisplayType displayType = GuiDisplayTypeUtil.getDisplayTypeForObject(ref.getObject(), null, getPageBase());
        if (displayType == null) {
            displayType = new DisplayType();
        }
        if (displayType.getIcon() == null) {
            displayType.setIcon(WebComponentUtil.createIconType(WebComponentUtil.createDefaultBlackIcon(ref.getTargetType())));
        }
        return displayType;
    });
    ImagePanel imagePanel = new ImagePanel(ID_ICON, displayModel);
    imagePanel.setOutputMarkupId(true);
    add(imagePanel);
    AjaxLink<PrismReferenceValue> nameLink = new AjaxLink<PrismReferenceValue>(ID_NAME, referenceModel) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            WebComponentUtil.dispatchToObjectDetailsPage(referenceModel.getObject(), LinkedReferencePanel.this, false);
        }
    };
    nameLink.add(new EnableBehaviour(() -> {
        PrismReferenceValue ref = referenceModel.getObject();
        if (ref == null) {
            return false;
        }
        return ref.getObject() != null;
    }));
    nameLink.setOutputMarkupId(true);
    add(nameLink);
    Label nameLinkText = new Label(ID_NAME_TEXT, new ReadOnlyModel<>(() -> {
        PrismReferenceValue ref = referenceModel.getObject();
        if (ref == null) {
            return "";
        }
        return WebComponentUtil.getReferencedObjectDisplayNameAndName(ref.asReferencable(), false, getPageBase());
    }));
    nameLinkText.setOutputMarkupId(true);
    nameLink.add(nameLinkText);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) DisplayType(com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) ImagePanel(com.evolveum.midpoint.web.component.data.column.ImagePanel) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour)

Example 17 with DisplayType

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

the class CountIconPanel method initLayout.

private void initLayout() {
    getModelObject().sort((d1, d2) -> {
        if (d1 == null || d1.getIcon() == null || d1.getIcon().getCssClass() == null || d2 == null || d2.getIcon() == null || d2.getIcon().getCssClass() == null) {
            return 0;
        }
        return d1.getIcon().getCssClass().compareTo(d2.getIcon().getCssClass());
    });
    ListView<DisplayType> iconsPanel = new ListView<DisplayType>(ID_ICONS, getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<DisplayType> item) {
            Label icon = new Label(ID_ICON);
            icon.add(AttributeModifier.replace("class", new PropertyModel<>(item.getModel(), "icon.cssClass")));
            if (item.getModelObject() != null && item.getModelObject().getTooltip() != null) {
                icon.add(AttributeModifier.replace("title", getPageBase().createStringResource(item.getModelObject().getTooltip().getOrig())));
            }
            icon.add(AttributeAppender.append("style", new ReadOnlyModel<>(() -> StringUtils.isNotBlank(getColor(item.getModelObject())) ? "color: " + getColor(item.getModelObject()) + ";" : "")));
            icon.setOutputMarkupId(true);
            icon.add(new VisibleBehaviour(() -> item.getModelObject() != null && item.getModelObject().getIcon() != null && StringUtils.isNotEmpty(item.getModelObject().getIcon().getCssClass())));
            item.add(icon);
            Integer count = icons.get(item.getModelObject());
            Label countPanel = new Label(ID_COUNT, Model.of(count));
            item.add(countPanel);
        }
    };
    add(iconsPanel);
}
Also used : ListView(org.apache.wicket.markup.html.list.ListView) DisplayType(com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 18 with DisplayType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType 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)

Example 19 with DisplayType

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

the class RelationSearchItem method createSpecialSearchPanel.

@Override
public SearchSpecialItemPanel createSpecialSearchPanel(String id) {
    return new SearchSpecialItemPanel(id, new PropertyModel<>(searchBoxConfiguration, SearchBoxConfigurationHelper.F_RELATION_ITEM)) {

        @Override
        protected WebMarkupContainer initSearchItemField(String id) {
            ReadOnlyModel<List<QName>> availableRelations = new ReadOnlyModel<>(() -> {
                List<QName> choices = new ArrayList();
                IModel<RelationSearchItemConfigurationType> relationItem = getModelValue();
                List<QName> relations = relationItem.getObject().getSupportedRelations();
                if (relations != null && relations.size() > 1) {
                    choices.add(PrismConstants.Q_ANY);
                }
                choices.addAll(relations);
                return choices;
            });
            DropDownChoicePanel inputPanel = new DropDownChoicePanel(id, new PropertyModel(getModelValue(), RelationSearchItemConfigurationType.F_DEFAULT_VALUE.getLocalPart()), availableRelations, new QNameIChoiceRenderer() {

                private static final long serialVersionUID = 1L;

                @Override
                public Object getDisplayValue(QName relation) {
                    RelationDefinitionType relationDef = WebComponentUtil.getRelationDefinition(relation);
                    if (relationDef != null) {
                        DisplayType display = relationDef.getDisplay();
                        if (display != null) {
                            PolyStringType label = display.getLabel();
                            if (PolyStringUtils.isNotEmpty(label)) {
                                return WebComponentUtil.getTranslatedPolyString(label);
                            }
                        }
                    }
                    if (QNameUtil.match(PrismConstants.Q_ANY, relation)) {
                        return new ResourceModel("RelationTypes.ANY", relation.getLocalPart()).getObject();
                    }
                    return super.getDisplayValue(relation);
                }
            }, false);
            inputPanel.getBaseFormComponent().add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
            inputPanel.getBaseFormComponent().add(AttributeAppender.append("style", "width: 100px; max-width: 400px !important;"));
            inputPanel.getBaseFormComponent().add(new EnableBehaviour(() -> availableRelations.getObject().size() > 1));
            inputPanel.setOutputMarkupId(true);
            return inputPanel;
        }

        @Override
        protected IModel<String> createLabelModel() {
            return Model.of(WebComponentUtil.getTranslatedPolyString(getReltaionConfig().getDisplay().getLabel()));
        }

        @Override
        protected IModel<String> createHelpModel() {
            return Model.of(WebComponentUtil.getTranslatedPolyString(getReltaionConfig().getDisplay().getHelp()));
        }
    };
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) QNameIChoiceRenderer(com.evolveum.midpoint.gui.impl.component.input.QNameIChoiceRenderer) DisplayType(com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) PropertyModel(org.apache.wicket.model.PropertyModel) RelationDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.RelationDefinitionType) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) ResourceModel(org.apache.wicket.model.ResourceModel) ArrayList(java.util.ArrayList) List(java.util.List) RelationSearchItemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.RelationSearchItemConfigurationType) SearchSpecialItemPanel(com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour)

Example 20 with DisplayType

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

the class UserInterfaceFeatureFinder method getLabel.

// private RA find(Predicate<F> filter) {
// List<VirtualContainersSpecificationType> foundVirtualContainers = virtualContainersAsserter.getVirtualContainers()
// .stream()
// .filter(filter)
// .collect(Collectors.toList());
// Assertions.assertThat(foundVirtualContainers).hasSize(1);
// return new VirtualContainerSpecificationAsserter<>(foundVirtualContainers.iterator().next(), virtualContainersAsserter, "from list of virtual containers " + virtualContainersAsserter.getVirtualContainers());
// }
private PolyString getLabel(F container) {
    DisplayType display = container.getDisplay();
    if (display == null) {
        return null;
    }
    PolyStringType label = display.getLabel();
    if (label == null) {
        return null;
    }
    return label.toPolyString();
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) DisplayType(com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType)

Aggregations

DisplayType (com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType)18 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)6 Label (org.apache.wicket.markup.html.basic.Label)5 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)4 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)4 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)4 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)4 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)3 TooltipBehavior (com.evolveum.midpoint.web.util.TooltipBehavior)3 IModel (org.apache.wicket.model.IModel)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 CompositedIconPanel (com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconPanel)2 StringLimitationResult (com.evolveum.midpoint.model.api.validator.StringLimitationResult)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 CompositedIconButtonDto (com.evolveum.midpoint.web.component.CompositedIconButtonDto)2 TablePanel (com.evolveum.midpoint.web.component.data.TablePanel)2 ImagePanel (com.evolveum.midpoint.web.component.data.column.ImagePanel)2 EnableBehaviour (com.evolveum.midpoint.web.component.util.EnableBehaviour)2 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)2