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;
}
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);
}
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);
}
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());
}
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();
};
}
Aggregations