use of com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto in project midpoint by Evolveum.
the class ObjectPolicyConfigurationEditor method removePerformed.
private void removePerformed(AjaxRequestTarget target, ListItem<ObjectPolicyConfigurationTypeDto> item) {
List<ObjectPolicyConfigurationTypeDto> list = getModelObject();
Iterator<ObjectPolicyConfigurationTypeDto> iterator = list.iterator();
while (iterator.hasNext()) {
ObjectPolicyConfigurationTypeDto object = iterator.next();
if (object.equals(item.getModelObject())) {
iterator.remove();
break;
}
}
if (list.size() == 0) {
list.add(new ObjectPolicyConfigurationTypeDto());
}
target.add(this);
}
use of com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto in project midpoint by Evolveum.
the class ObjectPolicyConfigurationEditor method editPerformed.
private void editPerformed(AjaxRequestTarget target, ListItem<ObjectPolicyConfigurationTypeDto> item) {
ObjectPolicyPanel objectPolicyPanel = new ObjectPolicyPanel(getPageBase().getMainPopupBodyId(), item.getModelObject()) {
private static final long serialVersionUID = 1L;
@Override
protected void savePerformed(AjaxRequestTarget target) {
ObjectPolicyConfigurationTypeDto oldConfig = getModel().getObject().getConfig();
ObjectPolicyConfigurationTypeDto newConfig = getModel().getObject().preparePolicyConfig();
ObjectPolicyConfigurationEditor.this.replace(oldConfig, newConfig);
ObjectPolicyConfigurationEditor.this.getPageBase().hideMainPopup(target);
target.add(ObjectPolicyConfigurationEditor.this);
}
};
objectPolicyPanel.setOutputMarkupId(true);
getPageBase().showMainPopup(objectPolicyPanel, target);
// ObjectPolicyPanel window = (ObjectPolicyPanel) get(ID_TEMPLATE_CONFIG_MODAL);
// window.updateModel(target, (ObjectPolicyConfigurationTypeDto)item.getModelObject());
// window.show(target);
}
use of com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto in project midpoint by Evolveum.
the class ObjectPolicyConfigurationEditor method createNameModel.
private IModel<String> createNameModel(final IModel<ObjectPolicyConfigurationTypeDto> model) {
return new LoadableModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String load() {
StringBuilder sb = new StringBuilder();
ObjectPolicyConfigurationTypeDto config = model.getObject();
if (config != null) {
ObjectReferenceType ref = config.getTemplateRef();
if (ref != null) {
sb.append(WebComponentUtil.getOrigStringFromPoly(ref.getTargetName())).append(": ");
}
if (config.getType() != null) {
sb.append(config.getType().getLocalPart());
}
if (config.getSubtype() != null) {
sb.append("(").append(config.getSubtype()).append(")");
}
}
return sb.toString();
}
};
}
use of com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto in project midpoint by Evolveum.
the class ObjectPolicyConfigurationEditor method replace.
// private void initDialog(){
// ModalWindow editor = new ObjectPolicyPanel(ID_TEMPLATE_CONFIG_MODAL, null){
//
// @Override
// protected void savePerformed(AjaxRequestTarget target){
// ObjectPolicyConfigurationTypeDto oldConfig = getModel().getObject().getConfig();
// ObjectPolicyConfigurationTypeDto newConfig = getModel().getObject().preparePolicyConfig();
//
// ObjectPolicyConfigurationEditor.this.replace(oldConfig, newConfig);
//
// target.add(ObjectPolicyConfigurationEditor.this);
// close(target);
// }
// };
// add(editor);
// }
private void replace(ObjectPolicyConfigurationTypeDto old, ObjectPolicyConfigurationTypeDto newC) {
boolean added = false;
List<ObjectPolicyConfigurationTypeDto> list = getModelObject();
for (ObjectPolicyConfigurationTypeDto o : list) {
if (old.equals(o)) {
o.setConstraints(newC.getConstraints());
o.setTemplateRef(newC.getTemplateRef());
o.setType(newC.getType());
o.setSubtype(newC.getSubtype());
added = true;
}
}
if (!added) {
list.add(newC);
}
}
use of com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto in project midpoint by Evolveum.
the class ObjectPolicyConfigurationEditor method initLayout.
protected void initLayout() {
final Label label = new Label(ID_LABEL, createStringResource("objectPolicyConfigurationEditor.label"));
add(label);
ListView<ObjectPolicyConfigurationTypeDto> repeater = new ListView<ObjectPolicyConfigurationTypeDto>(ID_REPEATER, getModel()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<ObjectPolicyConfigurationTypeDto> item) {
WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
textWrapper.add(AttributeAppender.prepend("class", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
if (item.getIndex() > 0) {
return OFFSET_CLASS + " " + CLASS_MULTI_VALUE;
}
return null;
}
}));
item.add(textWrapper);
TextField<String> name = new TextField<>(ID_NAME, createNameModel(item.getModel()));
name.setOutputMarkupId(true);
name.add(new AjaxFormComponentUpdatingBehavior("blur") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
name.setEnabled(false);
name.add(AttributeAppender.replace("placeholder", createStringResource("objectPolicyConfigurationEditor.name.placeholder")));
textWrapper.add(name);
FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(name));
textWrapper.add(feedback);
AjaxLink<String> edit = new AjaxLink<String>(ID_BUTTON_EDIT) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
editPerformed(target, item);
}
};
textWrapper.add(edit);
WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
if (item.getIndex() > 0) {
return CLASS_MULTI_VALUE;
}
return null;
}
}));
item.add(buttonGroup);
initButtons(buttonGroup, item);
}
};
// initDialog();
repeater.setOutputMarkupId(true);
add(repeater);
}
Aggregations