Search in sources :

Example 1 with PropertyLimitationsTypeDto

use of com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto in project midpoint by Evolveum.

the class LimitationsEditorDialog method loadLimitationsModel.

private List<PropertyLimitationsTypeDto> loadLimitationsModel(IModel<List<PropertyLimitationsType>> limList) {
    List<PropertyLimitationsTypeDto> limitations = new ArrayList<>();
    List<PropertyLimitationsType> limitationTypeList = limList.getObject();
    for (PropertyLimitationsType limitation : limitationTypeList) {
        limitations.add(new PropertyLimitationsTypeDto(limitation));
    }
    return limitations;
}
Also used : PropertyLimitationsTypeDto(com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto) ArrayList(java.util.ArrayList) PropertyLimitationsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyLimitationsType)

Example 2 with PropertyLimitationsTypeDto

use of com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto in project midpoint by Evolveum.

the class LimitationsEditorDialog method initLayout.

public void initLayout(WebMarkupContainer content) {
    Form<?> form = new MidpointForm<>(ID_MAIN_FORM);
    form.setOutputMarkupId(true);
    content.add(form);
    ListView<PropertyLimitationsTypeDto> repeater = new ListView<PropertyLimitationsTypeDto>(ID_REPEATER, model) {

        @Override
        protected void populateItem(final ListItem<PropertyLimitationsTypeDto> item) {
            WebMarkupContainer linkContainer = new WebMarkupContainer(ID_LIMITATIONS_LINK);
            linkContainer.setOutputMarkupId(true);
            linkContainer.add(new AttributeModifier("href", createCollapseItemId(item, true)));
            item.add(linkContainer);
            Label linkLabel = new Label(ID_LIMITATIONS_LABEL, createLimitationsLabelModel(item));
            linkContainer.add(linkLabel);
            AjaxLink<Void> delete = new AjaxLink<Void>(ID_LIMITATION_DELETE) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteLimitationPerformed(target, item);
                }
            };
            delete.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
            linkContainer.add(delete);
            WebMarkupContainer limitationBody = new WebMarkupContainer(ID_BODY);
            limitationBody.setOutputMarkupId(true);
            limitationBody.setMarkupId(createCollapseItemId(item, false).getObject());
            if (changeState != ChangeState.SKIP) {
                limitationBody.add(new AttributeModifier("class", (IModel<String>) () -> {
                    if (changeState == ChangeState.FIRST && item.getIndex() == 0) {
                        return "panel-collapse collapse in";
                    } else if (changeState == ChangeState.LAST && item.getIndex() == (getModelObject().size() - 1)) {
                        return "panel-collapse collapse in";
                    } else {
                        return "panel-collapse collapse";
                    }
                }));
            }
            limitationBody.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
            item.add(limitationBody);
            initLimitationBody(limitationBody, item);
        }
    };
    repeater.setOutputMarkupId(true);
    form.add(repeater);
    initButtons(form);
}
Also used : IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) PropertyLimitationsTypeDto(com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 3 with PropertyLimitationsTypeDto

use of com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto in project midpoint by Evolveum.

the class LimitationsEditorDialog method savePerformed.

protected void savePerformed(AjaxRequestTarget target) {
    List<PropertyLimitationsTypeDto> list = model.getObject();
    List<PropertyLimitationsType> outputList = new ArrayList<>();
    for (PropertyLimitationsTypeDto dto : list) {
        outputList.add(dto.prepareDtoForSave());
    }
    inputModel.getObject().clear();
    inputModel.getObject().addAll(outputList);
    close(target);
}
Also used : PropertyLimitationsTypeDto(com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto) ArrayList(java.util.ArrayList) PropertyLimitationsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyLimitationsType)

Example 4 with PropertyLimitationsTypeDto

use of com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto in project midpoint by Evolveum.

the class LimitationsEditorDialog method addLimitationsPerformed.

private void addLimitationsPerformed(AjaxRequestTarget target) {
    changeState = ChangeState.LAST;
    model.getObject().add(new PropertyLimitationsTypeDto(new PropertyLimitationsType()));
    target.add(getContent());
}
Also used : PropertyLimitationsTypeDto(com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto) PropertyLimitationsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyLimitationsType)

Example 5 with PropertyLimitationsTypeDto

use of com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto in project midpoint by Evolveum.

the class LimitationsEditorDialog method createLimitationsLabelModel.

private IModel<String> createLimitationsLabelModel(final ListItem<PropertyLimitationsTypeDto> item) {
    return (IModel<String>) () -> {
        StringBuilder sb = new StringBuilder();
        PropertyLimitationsTypeDto dto = item.getModelObject();
        sb.append("#").append(item.getIndex() + 1).append(" - ");
        List<LayerType> layers = new ArrayList<>();
        if (dto.isModel()) {
            layers.add(LayerType.MODEL);
        }
        if (dto.isPresentation()) {
            layers.add(LayerType.PRESENTATION);
        }
        if (dto.isSchema()) {
            layers.add(LayerType.SCHEMA);
        }
        sb.append(StringUtils.join(layers, ", "));
        sb.append(":");
        if (dto.getLimitationObject().getAccess() != null) {
            List<String> accesses = new ArrayList<>();
            PropertyAccessType access = dto.getLimitationObject().getAccess();
            if (BooleanUtils.isTrue(access.isRead())) {
                accesses.add(getString("LimitationsEditorDialog.label.read"));
            }
            if (BooleanUtils.isTrue(access.isAdd())) {
                accesses.add(getString("LimitationsEditorDialog.label.add"));
            }
            if (BooleanUtils.isTrue(access.isModify())) {
                accesses.add(getString("LimitationsEditorDialog.label.modify"));
            }
            sb.append(StringUtils.join(accesses, ", "));
        }
        return sb.toString();
    };
}
Also used : IModel(org.apache.wicket.model.IModel) PropertyLimitationsTypeDto(com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto) LayerType(com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType) ArrayList(java.util.ArrayList) PropertyAccessType(com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyAccessType)

Aggregations

PropertyLimitationsTypeDto (com.evolveum.midpoint.web.component.wizard.resource.dto.PropertyLimitationsTypeDto)5 PropertyLimitationsType (com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyLimitationsType)3 ArrayList (java.util.ArrayList)3 IModel (org.apache.wicket.model.IModel)2 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)1 LayerType (com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType)1 PropertyAccessType (com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyAccessType)1 AttributeModifier (org.apache.wicket.AttributeModifier)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)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