use of com.evolveum.midpoint.xml.ns._public.common.common_3.MultiplicityPolicyConstraintType in project midpoint by Evolveum.
the class RolePolicyPanel method initLayout.
@Override
protected void initLayout() {
minAssignmentModel = new LoadableModel<List<MultiplicityPolicyConstraintType>>(false) {
@Override
protected List<MultiplicityPolicyConstraintType> load() {
RoleType roleType = role.asObjectable();
if (roleType.getPolicyConstraints() == null) {
roleType.setPolicyConstraints(new PolicyConstraintsType());
}
return roleType.getPolicyConstraints().getMinAssignees();
}
};
maxAssignmentsModel = new LoadableModel<List<MultiplicityPolicyConstraintType>>(false) {
@Override
protected List<MultiplicityPolicyConstraintType> load() {
RoleType roleType = role.asObjectable();
if (roleType.getPolicyConstraints() == null) {
roleType.setPolicyConstraints(new PolicyConstraintsType());
}
return roleType.getPolicyConstraints().getMaxAssignees();
}
};
GenericMultiValueLabelEditPanel minAssignments = new GenericMultiValueLabelEditPanel<MultiplicityPolicyConstraintType>(ID_MIN_ASSIGNMENTS, minAssignmentModel, createStringResource("PageRoleEditor.label.minAssignments"), ID_LABEL_SIZE, ID_INPUT_SIZE, true) {
@Override
protected IModel<String> createTextModel(IModel<MultiplicityPolicyConstraintType> model) {
return createMultiplicityPolicyLabel(model);
}
@Override
protected void editValuePerformed(AjaxRequestTarget target, IModel<MultiplicityPolicyConstraintType> rowModel) {
MultiplicityPolicyPanel window = new MultiplicityPolicyPanel(getPageBase().getMainPopupBodyId(), rowModel.getObject()) {
@Override
protected void savePerformed(AjaxRequestTarget target) {
closeModalWindow(target);
target.add(getMinAssignmentsContainer());
}
};
showDialog(window, target);
}
@Override
protected MultiplicityPolicyConstraintType createNewEmptyItem() {
return new MultiplicityPolicyConstraintType();
}
};
minAssignments.setOutputMarkupId(true);
add(minAssignments);
GenericMultiValueLabelEditPanel maxAssignments = new GenericMultiValueLabelEditPanel<MultiplicityPolicyConstraintType>(ID_MAX_ASSIGNMENTS, maxAssignmentsModel, createStringResource("PageRoleEditor.label.maxAssignments"), ID_LABEL_SIZE, ID_INPUT_SIZE, true) {
@Override
protected IModel<String> createTextModel(IModel<MultiplicityPolicyConstraintType> model) {
return createMultiplicityPolicyLabel(model);
}
@Override
protected void editValuePerformed(AjaxRequestTarget target, IModel<MultiplicityPolicyConstraintType> rowModel) {
MultiplicityPolicyPanel window = new MultiplicityPolicyPanel(getPageBase().getMainPopupBodyId(), rowModel.getObject()) {
@Override
protected void savePerformed(AjaxRequestTarget target) {
closeModalWindow(target);
target.add(getMaxAssignmentsContainer());
}
};
showDialog(window, target);
}
@Override
protected MultiplicityPolicyConstraintType createNewEmptyItem() {
return new MultiplicityPolicyConstraintType();
}
};
maxAssignments.setOutputMarkupId(true);
add(maxAssignments);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.MultiplicityPolicyConstraintType in project midpoint by Evolveum.
the class RolePolicyPanel method createMultiplicityPolicyLabel.
private IModel<String> createMultiplicityPolicyLabel(final IModel<MultiplicityPolicyConstraintType> model) {
return new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
StringBuilder sb = new StringBuilder();
if (model == null || model.getObject() == null || model.getObject().getMultiplicity() == null || model.getObject().getMultiplicity().isEmpty()) {
return getString("PageRoleEditor.label.assignmentConstraint.placeholder");
}
MultiplicityPolicyConstraintType policy = model.getObject();
sb.append(policy.getMultiplicity());
if (policy.getEnforcement() != null) {
sb.append(" (");
sb.append(policy.getEnforcement());
sb.append(")");
}
return sb.toString();
}
};
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.MultiplicityPolicyConstraintType in project midpoint by Evolveum.
the class BaseAbstractRolePanel method createMultiplicityPolicyLabel.
private IModel<String> createMultiplicityPolicyLabel(final IModel<MultiplicityPolicyConstraintType> model) {
return new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
StringBuilder sb = new StringBuilder();
if (model == null || model.getObject() == null || model.getObject().getMultiplicity() == null || model.getObject().getMultiplicity().isEmpty()) {
return getString("PageRoleEditor.label.assignmentConstraint.placeholder");
}
MultiplicityPolicyConstraintType policy = model.getObject();
sb.append(policy.getMultiplicity());
if (policy.getEnforcement() != null) {
sb.append(" (");
sb.append(policy.getEnforcement());
sb.append(")");
}
return sb.toString();
}
};
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.MultiplicityPolicyConstraintType in project midpoint by Evolveum.
the class BaseAbstractRolePanel method initLayout.
@Override
protected void initLayout() {
minAssignmentModel = new LoadableModel<List<MultiplicityPolicyConstraintType>>(false) {
@Override
protected List<MultiplicityPolicyConstraintType> load() {
if (abstractRole.getPolicyConstraints() == null) {
abstractRole.setPolicyConstraints(new PolicyConstraintsType());
}
return abstractRole.getPolicyConstraints().getMinAssignees();
}
};
maxAssignmentsModel = new LoadableModel<List<MultiplicityPolicyConstraintType>>(false) {
@Override
protected List<MultiplicityPolicyConstraintType> load() {
if (abstractRole.getPolicyConstraints() == null) {
abstractRole.setPolicyConstraints(new PolicyConstraintsType());
}
return abstractRole.getPolicyConstraints().getMaxAssignees();
}
};
GenericMultiValueLabelEditPanel minAssignments = new GenericMultiValueLabelEditPanel<MultiplicityPolicyConstraintType>(ID_MIN_ASSIGNMENTS, minAssignmentModel, createStringResource("PageRoleEditor.label.minAssignments"), ID_LABEL_SIZE, ID_INPUT_SIZE, true) {
@Override
protected IModel<String> createTextModel(IModel<MultiplicityPolicyConstraintType> model) {
return createMultiplicityPolicyLabel(model);
}
@Override
protected void editValuePerformed(AjaxRequestTarget target, IModel<MultiplicityPolicyConstraintType> rowModel) {
MultiplicityPolicyPanel window = new MultiplicityPolicyPanel(getPageBase().getMainPopupBodyId(), rowModel.getObject()) {
@Override
protected void savePerformed(AjaxRequestTarget target) {
closeModalWindow(target);
target.add(getMinAssignmentsContainer());
}
};
showDialog(window, target);
}
@Override
protected MultiplicityPolicyConstraintType createNewEmptyItem() {
return new MultiplicityPolicyConstraintType();
}
};
minAssignments.setOutputMarkupId(true);
add(minAssignments);
GenericMultiValueLabelEditPanel maxAssignments = new GenericMultiValueLabelEditPanel<MultiplicityPolicyConstraintType>(ID_MAX_ASSIGNMENTS, maxAssignmentsModel, createStringResource("PageRoleEditor.label.maxAssignments"), ID_LABEL_SIZE, ID_INPUT_SIZE, true) {
@Override
protected IModel<String> createTextModel(IModel<MultiplicityPolicyConstraintType> model) {
return createMultiplicityPolicyLabel(model);
}
@Override
protected void editValuePerformed(AjaxRequestTarget target, IModel<MultiplicityPolicyConstraintType> rowModel) {
MultiplicityPolicyPanel window = new MultiplicityPolicyPanel(getPageBase().getMainPopupBodyId(), rowModel.getObject()) {
@Override
protected void savePerformed(AjaxRequestTarget target) {
closeModalWindow(target);
target.add(getMaxAssignmentsContainer());
}
};
showDialog(window, target);
}
@Override
protected MultiplicityPolicyConstraintType createNewEmptyItem() {
return new MultiplicityPolicyConstraintType();
}
};
maxAssignments.setOutputMarkupId(true);
add(maxAssignments);
}
Aggregations