Search in sources :

Example 1 with ObjectTemplateConfigTypeReferenceDto

use of com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectTemplateConfigTypeReferenceDto in project midpoint by Evolveum.

the class ObjectPolicyPanel method createObjectTemplateList.

protected IModel<List<ObjectTemplateConfigTypeReferenceDto>> createObjectTemplateList() {
    return new AbstractReadOnlyModel<List<ObjectTemplateConfigTypeReferenceDto>>() {

        @Override
        public List<ObjectTemplateConfigTypeReferenceDto> getObject() {
            List<PrismObject<ObjectTemplateType>> templateList = null;
            List<ObjectTemplateConfigTypeReferenceDto> list = new ArrayList<>();
            OperationResult result = new OperationResult(OPERATION_LOAD_ALL_OBJECT_TEMPLATES);
            Task task = getPageBase().createSimpleTask(OPERATION_LOAD_ALL_OBJECT_TEMPLATES);
            try {
                templateList = getPageBase().getModelService().searchObjects(ObjectTemplateType.class, new ObjectQuery(), null, task, result);
                result.recomputeStatus();
            } catch (Exception e) {
                result.recordFatalError("Could not get list of object templates", e);
                LoggingUtils.logUnexpectedException(LOGGER, "Could not get list of object templates", e);
            // TODO - show this error in GUI
            }
            if (templateList != null) {
                ObjectTemplateType template;
                for (PrismObject<ObjectTemplateType> obj : templateList) {
                    template = obj.asObjectable();
                    list.add(new ObjectTemplateConfigTypeReferenceDto(template.getOid(), WebComponentUtil.getName(template)));
                }
            }
            return list;
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectTemplateConfigTypeReferenceDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectTemplateConfigTypeReferenceDto) Task(com.evolveum.midpoint.task.api.Task) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 2 with ObjectTemplateConfigTypeReferenceDto

use of com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectTemplateConfigTypeReferenceDto in project midpoint by Evolveum.

the class ObjectPolicyPanel method initLayout.

//	public void updateModel(AjaxRequestTarget target, ObjectPolicyConfigurationTypeDto config) {
//		model.setObject(new ObjectPolicyDialogDto(config, getPageBase()));
//		target.add(getContent());
//	}
public void initLayout() {
    Form form = new Form(ID_FORM);
    form.setOutputMarkupId(true);
    add(form);
    DropDownFormGroup type = new DropDownFormGroup<>(ID_TYPE, new PropertyModel<QName>(model, ObjectPolicyDialogDto.F_TYPE), createTypeChoiceList(), new QNameChoiceRenderer(), createStringResource("ObjectPolicyDialog.type"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(type);
    type.getInput().setNullValid(false);
    type.getInput().setRequired(true);
    TextField<String> fieldSubtype = new TextField<>(ID_SUBTYPE, new PropertyModel<String>(model, ObjectPolicyDialogDto.F_SUBTYPE));
    form.add(fieldSubtype);
    form.add(fieldSubtype);
    DropDownFormGroup template = new DropDownFormGroup<>(ID_OBJECT_TEMPLATE, new PropertyModel<ObjectTemplateConfigTypeReferenceDto>(model, ObjectPolicyDialogDto.F_TEMPLATE_REF), createObjectTemplateList(), new ChoiceableChoiceRenderer<ObjectTemplateConfigTypeReferenceDto>(), createStringResource("ObjectPolicyDialog.template"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(template);
    template.getInput().setNullValid(false);
    template.getInput().setRequired(true);
    ListView repeater = new ListView<PropertyConstraintTypeDto>(ID_REPEATER, new PropertyModel<List<PropertyConstraintTypeDto>>(model, ObjectPolicyDialogDto.F_PROPERTY_LIST)) {

        @Override
        protected void populateItem(final ListItem item) {
            WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
            textWrapper.add(AttributeAppender.prepend("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    if (item.getIndex() > 0) {
                        return OFFSET_CLASS + " " + CLASS_MULTI_VALUE;
                    }
                    return null;
                }
            }));
            item.add(textWrapper);
            TextField property = new TextField<>(ID_PROPERTY, new PropertyModel<String>(item.getModel(), PropertyConstraintTypeDto.F_PROPERTY_PATH));
            property.add(new AjaxFormComponentUpdatingBehavior("blur") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
            property.add(AttributeAppender.replace("placeholder", createStringResource("ObjectPolicyDialog.property.placeholder")));
            textWrapper.add(property);
            CheckBox oidBound = new CheckBox(ID_OID_BOUND, new PropertyModel<Boolean>(item.getModel(), PropertyConstraintTypeDto.F_OID_BOUND));
            oidBound.add(AttributeModifier.replace("title", createStringResource("ObjectPolicyDialog.label.oidBound.help")));
            textWrapper.add(oidBound);
            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    if (item.getIndex() > 0) {
                        return CLASS_MULTI_VALUE;
                    }
                    return null;
                }
            }));
            item.add(buttonGroup);
            initButtons(buttonGroup, item);
        }
    };
    form.add(repeater);
    AjaxSubmitButton cancel = new AjaxSubmitButton(ID_BUTTON_CANCEL, createStringResource("ObjectPolicyDialog.button.cancel")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            cancelPerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            cancelPerformed(target);
        }
    };
    form.add(cancel);
    AjaxSubmitButton save = new AjaxSubmitButton(ID_BUTTON_SAVE, createStringResource("ObjectPolicyDialog.button.save")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            savePerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(form);
        }
    };
    form.add(save);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Form(org.apache.wicket.markup.html.form.Form) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ArrayList(java.util.ArrayList) List(java.util.List) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) QName(javax.xml.namespace.QName) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectTemplateConfigTypeReferenceDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectTemplateConfigTypeReferenceDto) CheckBox(org.apache.wicket.markup.html.form.CheckBox) ListItem(org.apache.wicket.markup.html.list.ListItem)

Aggregations

ObjectTemplateConfigTypeReferenceDto (com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectTemplateConfigTypeReferenceDto)2 ArrayList (java.util.ArrayList)2 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)1 DropDownFormGroup (com.evolveum.midpoint.web.component.form.DropDownFormGroup)1 QNameChoiceRenderer (com.evolveum.midpoint.web.component.input.QNameChoiceRenderer)1 ObjectTemplateType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType)1 List (java.util.List)1 QName (javax.xml.namespace.QName)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 CheckBox (org.apache.wicket.markup.html.form.CheckBox)1 Form (org.apache.wicket.markup.html.form.Form)1 TextField (org.apache.wicket.markup.html.form.TextField)1 ListItem (org.apache.wicket.markup.html.list.ListItem)1