Search in sources :

Example 1 with ObjectPolicyConfigurationTypeDto

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);
}
Also used : ObjectPolicyConfigurationTypeDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto)

Example 2 with ObjectPolicyConfigurationTypeDto

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);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectPolicyPanel(com.evolveum.midpoint.web.page.admin.configuration.component.ObjectPolicyPanel) ObjectPolicyConfigurationTypeDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto)

Example 3 with ObjectPolicyConfigurationTypeDto

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();
        }
    };
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ObjectPolicyConfigurationTypeDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto)

Example 4 with ObjectPolicyConfigurationTypeDto

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);
    }
}
Also used : ObjectPolicyConfigurationTypeDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto)

Example 5 with ObjectPolicyConfigurationTypeDto

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);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) ObjectPolicyConfigurationTypeDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto)

Aggregations

ObjectPolicyConfigurationTypeDto (com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto)6 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 ObjectPolicyPanel (com.evolveum.midpoint.web.page.admin.configuration.component.ObjectPolicyPanel)1 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)1 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)1 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)1 ComponentFeedbackMessageFilter (org.apache.wicket.feedback.ComponentFeedbackMessageFilter)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1 TextField (org.apache.wicket.markup.html.form.TextField)1 ListItem (org.apache.wicket.markup.html.list.ListItem)1 ListView (org.apache.wicket.markup.html.list.ListView)1 FeedbackPanel (org.apache.wicket.markup.html.panel.FeedbackPanel)1 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)1