Search in sources :

Example 6 with EmptyOnChangeAjaxFormUpdatingBehavior

use of com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior in project midpoint by Evolveum.

the class ResourceAttributeEditor method initLayout.

protected void initLayout(final NonEmptyModel<Boolean> readOnlyModel) {
    Label label = new Label(ID_LABEL, new ResourceModel("ResourceAttributeEditor.label.edit"));
    label.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    add(label);
    /*
		TEMPORARILY DISABLED

        QNameEditorPanel nonSchemaRefPanel = new QNameEditorPanel(ID_NON_SCHEMA_REF_PANEL, new PropertyModel<ItemPathType>(getModel(), "ref"),
                "SchemaHandlingStep.attribute.label.attributeName", "SchemaHandlingStep.attribute.tooltip.attributeLocalPart",
                "SchemaHandlingStep.attribute.label.attributeNamespace", "SchemaHandlingStep.attribute.tooltip.attributeNamespace", true, true) {
			@Override
			protected void onUpdate(AjaxRequestTarget target) {
				target.add(parentStep.getAttributeList());
			}
		};

        nonSchemaRefPanel.setOutputMarkupId(true);
        nonSchemaRefPanel.setOutputMarkupPlaceholderTag(true);
        nonSchemaRefPanel.add(new VisibleEnableBehaviour(){

            @Override
            public boolean isVisible() {
                return nonSchemaRefValueAllowed;
            }
        });
        add(nonSchemaRefPanel);
*/
    WebMarkupContainer schemaRefPanel = new WebMarkupContainer(ID_SCHEMA_REF_PANEL);
    schemaRefPanel.setOutputMarkupId(true);
    schemaRefPanel.setOutputMarkupPlaceholderTag(true);
    schemaRefPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !nonSchemaRefValueAllowed;
        }

        @Override
        public boolean isEnabled() {
            return !readOnlyModel.getObject();
        }
    });
    add(schemaRefPanel);
    Label refTooltip = new Label(ID_T_REF);
    refTooltip.add(new InfoTooltipBehavior());
    refTooltip.setOutputMarkupId(true);
    refTooltip.setOutputMarkupId(true);
    schemaRefPanel.add(refTooltip);
    DropDownChoice refSelect = new DropDownChoice<ItemPathType>(ID_REFERENCE_SELECT, new PropertyModel<ItemPathType>(getModel(), "ref"), new AbstractReadOnlyModel<List<ItemPathType>>() {

        @Override
        public List<ItemPathType> getObject() {
            return loadObjectReferences();
        }
    }, new IChoiceRenderer<ItemPathType>() {

        @Override
        public ItemPathType getObject(String id, IModel<? extends List<? extends ItemPathType>> choices) {
            return StringUtils.isNotBlank(id) ? choices.getObject().get(Integer.parseInt(id)) : null;
        }

        @Override
        public Object getDisplayValue(ItemPathType object) {
            return prepareReferenceDisplayValue(object);
        }

        @Override
        public String getIdValue(ItemPathType object, int index) {
            return Integer.toString(index);
        }
    }) {

        @Override
        protected boolean isSelected(ItemPathType object, int index, String selected) {
            if (getModelObject() == null || getModelObject().equals(new ItemPathType())) {
                return false;
            }
            QName referenceQName = ItemPathUtil.getOnlySegmentQNameRobust(getModelObject());
            QName optionQName = ItemPathUtil.getOnlySegmentQNameRobust(object);
            return ObjectUtils.equals(referenceQName, optionQName);
        }
    };
    refSelect.setNullValid(false);
    refSelect.setOutputMarkupId(true);
    refSelect.setOutputMarkupPlaceholderTag(true);
    refSelect.add(new EmptyOnChangeAjaxFormUpdatingBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(parentStep.getAttributeList());
            ((PageResourceWizard) getPageBase()).refreshIssues(target);
        }
    });
    refSelect.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    schemaRefPanel.add(refSelect);
    /*
		TEMPORARILY DISABLED

        CheckBox allowNonSchema = new CheckBox(ID_REFERENCE_ALLOW, new PropertyModel<Boolean>(this, "nonSchemaRefValueAllowed"));
        allowNonSchema.add(new AjaxFormComponentUpdatingBehavior("change") {

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                target.add(get(ID_NON_SCHEMA_REF_PANEL), get(ID_SCHEMA_REF_PANEL));
            }
        });
        add(allowNonSchema);
*/
    TextField displayName = new TextField<>(ID_DISPLAY_NAME, new PropertyModel<String>(getModel(), "displayName"));
    displayName.add(new EmptyOnChangeAjaxFormUpdatingBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(parentStep.getAttributeList());
        }
    });
    displayName.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    add(displayName);
    TextArea description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(getModel(), "description"));
    description.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    add(description);
    AjaxLink limitations = new AjaxLink(ID_BUTTON_LIMITATIONS) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            limitationsEditPerformed(target);
        }
    };
    add(limitations);
    CheckBox exclusiveStrong = new CheckBox(ID_EXCLUSIVE_STRONG, new PropertyModel<Boolean>(getModel(), "exclusiveStrong"));
    exclusiveStrong.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    add(exclusiveStrong);
    CheckBox tolerant = new CheckBox(ID_TOLERANT, new PropertyModel<Boolean>(getModel(), "tolerant"));
    tolerant.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    add(tolerant);
    MultiValueTextPanel tolerantVP = new MultiValueTextPanel<>(ID_TOLERANT_VP, new PropertyModel<List<String>>(getModel(), "tolerantValuePattern"), readOnlyModel, true);
    tolerantVP.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    add(tolerantVP);
    MultiValueTextPanel intolerantVP = new MultiValueTextPanel<>(ID_INTOLERANT_VP, new PropertyModel<List<String>>(getModel(), "intolerantValuePattern"), readOnlyModel, true);
    intolerantVP.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    add(intolerantVP);
    DropDownChoice fetchStrategy = new DropDownChoice<>(ID_FETCH_STRATEGY, new PropertyModel<AttributeFetchStrategyType>(getModel(), "fetchStrategy"), WebComponentUtil.createReadonlyModelFromEnum(AttributeFetchStrategyType.class), new EnumChoiceRenderer<AttributeFetchStrategyType>(this));
    fetchStrategy.setNullValid(true);
    fetchStrategy.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    add(fetchStrategy);
    AttributeEditorUtils.addMatchingRuleFields(this, readOnlyModel);
    TextField outboundLabel = new TextField<>(ID_OUTBOUND_LABEL, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            ResourceAttributeDefinitionType attributeDefinition = getModel().getObject();
            if (attributeDefinition == null) {
                return null;
            }
            return MappingTypeDto.createMappingLabel(attributeDefinition.getOutbound(), LOGGER, getPageBase().getPrismContext(), getString("MappingType.label.placeholder"), getString("MultiValueField.nameNotSpecified"));
        }
    });
    outboundLabel.setEnabled(false);
    outboundLabel.setOutputMarkupId(true);
    VisibleEnableBehaviour showIfEditingOrOutboundExists = AttributeEditorUtils.createShowIfEditingOrOutboundExists(getModel(), readOnlyModel);
    outboundLabel.add(showIfEditingOrOutboundExists);
    add(outboundLabel);
    AjaxSubmitLink outbound = new AjaxSubmitLink(ID_BUTTON_OUTBOUND) {

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

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(parentStep.getPageBase().getFeedbackPanel());
        }
    };
    outbound.setOutputMarkupId(true);
    outbound.add(showIfEditingOrOutboundExists);
    add(outbound);
    AjaxSubmitLink deleteOutbound = new AjaxSubmitLink(ID_DELETE_OUTBOUND) {

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

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(parentStep.getPageBase().getFeedbackPanel());
        }
    };
    deleteOutbound.setOutputMarkupId(true);
    deleteOutbound.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
    add(deleteOutbound);
    MultiValueTextEditPanel inbound = new MultiValueTextEditPanel<MappingType>(ID_INBOUND, new PropertyModel<List<MappingType>>(getModel(), "inbound"), null, false, true, readOnlyModel) {

        @Override
        protected IModel<String> createTextModel(final IModel<MappingType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    return MappingTypeDto.createMappingLabel(model.getObject(), LOGGER, getPageBase().getPrismContext(), getString("MappingType.label.placeholder"), getString("MultiValueField.nameNotSpecified"));
                }
            };
        }

        @Override
        protected MappingType createNewEmptyItem() {
            return WizardUtil.createEmptyMapping();
        }

        @Override
        protected void performAddValueHook(AjaxRequestTarget target, MappingType added) {
            target.add(parentStep.getAttributeList());
            target.add(parentStep.getAssociationList());
            ((PageResourceWizard) getPageBase()).refreshIssues(target);
        }

        @Override
        protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<MappingType> item) {
            target.add(parentStep.getAttributeList());
            target.add(parentStep.getAssociationList());
            ((PageResourceWizard) getPageBase()).refreshIssues(target);
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, MappingType object) {
            inboundEditPerformed(target, object);
        }
    };
    inbound.setOutputMarkupId(true);
    add(inbound);
    Label allowTooltip = new Label(ID_T_ALLOW);
    allowTooltip.add(new InfoTooltipBehavior());
    add(allowTooltip);
    Label limitationsTooltip = new Label(ID_T_LIMITATIONS);
    limitationsTooltip.add(new InfoTooltipBehavior());
    add(limitationsTooltip);
    Label exclusiveStrongTooltip = new Label(ID_T_EXCLUSIVE_STRONG);
    exclusiveStrongTooltip.add(new InfoTooltipBehavior());
    add(exclusiveStrongTooltip);
    Label tolerantTooltip = new Label(ID_T_TOLERANT);
    tolerantTooltip.add(new InfoTooltipBehavior());
    add(tolerantTooltip);
    Label tolerantVPTooltip = new Label(ID_T_TOLERANT_VP);
    tolerantVPTooltip.add(new InfoTooltipBehavior());
    add(tolerantVPTooltip);
    Label intolerantVPTooltip = new Label(ID_T_INTOLERANT_VP);
    intolerantVPTooltip.add(new InfoTooltipBehavior());
    add(intolerantVPTooltip);
    Label fetchTooltip = new Label(ID_T_FETCH);
    fetchTooltip.add(new InfoTooltipBehavior());
    add(fetchTooltip);
    Label matchingRuleTooltip = new Label(ID_T_MATCHING_RULE);
    matchingRuleTooltip.add(new InfoTooltipBehavior());
    add(matchingRuleTooltip);
    Label outboundTooltip = new Label(ID_T_OUTBOUND);
    outboundTooltip.add(new InfoTooltipBehavior());
    add(outboundTooltip);
    Label inboundTooltip = new Label(ID_T_INBOUND);
    inboundTooltip.add(new InfoTooltipBehavior());
    add(inboundTooltip);
    initModals(readOnlyModel);
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) MultiValueTextEditPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) List(java.util.List) ArrayList(java.util.ArrayList) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) MultiValueTextPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextPanel) QName(javax.xml.namespace.QName) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) NonEmptyModel(com.evolveum.midpoint.gui.api.model.NonEmptyModel) PageResourceWizard(com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard) PrismObject(com.evolveum.midpoint.prism.PrismObject) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 7 with EmptyOnChangeAjaxFormUpdatingBehavior

use of com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior in project midpoint by Evolveum.

the class LimitationsEditorDialog method initLimitationBody.

private void initLimitationBody(final WebMarkupContainer body, ListItem<PropertyLimitationsTypeDto> item) {
    CheckFormGroup schema = new CheckFormGroup(ID_LAYER_SCHEMA, new PropertyModel<Boolean>(item.getModelObject(), PropertyLimitationsTypeDto.F_SCHEMA), createStringResource("LimitationsEditorDialog.label.schema"), ID_LABEL_SIZE, ID_INPUT_SIZE);
    schema.getCheck().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(schema);
    CheckFormGroup model = new CheckFormGroup(ID_LAYER_MODEL, new PropertyModel<Boolean>(item.getModelObject(), PropertyLimitationsTypeDto.F_MODEL), createStringResource("LimitationsEditorDialog.label.model"), ID_LABEL_SIZE, ID_INPUT_SIZE);
    model.getCheck().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(model);
    CheckFormGroup presentation = new CheckFormGroup(ID_LAYER_PRESENTATION, new PropertyModel<Boolean>(item.getModelObject(), PropertyLimitationsTypeDto.F_PRESENTATION), createStringResource("LimitationsEditorDialog.label.presentation"), ID_LABEL_SIZE, ID_INPUT_SIZE);
    presentation.getCheck().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(presentation);
    DropDownChoicePanel add = new DropDownChoicePanel(ID_ACCESS_ADD, getAddPropertyAccessModel(item.getModel()), WebComponentUtil.createReadonlyModelFromEnum(PropertyAccess.class), false);
    FormComponent<PropertyAccess> addInput = add.getBaseFormComponent();
    addInput.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    addInput.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    DropDownChoicePanel read = new DropDownChoicePanel(ID_ACCESS_READ, getReadPropertyAccessModel(item.getModel()), WebComponentUtil.createReadonlyModelFromEnum(PropertyAccess.class), false);
    FormComponent<PropertyAccess> readInput = read.getBaseFormComponent();
    readInput.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    readInput.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    DropDownChoicePanel modify = new DropDownChoicePanel(ID_ACCESS_MODIFY, getModifyPropertyAccessModel(item.getModel()), WebComponentUtil.createReadonlyModelFromEnum(PropertyAccess.class), false);
    FormComponent<PropertyAccess> modifyInput = modify.getBaseFormComponent();
    modifyInput.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    modifyInput.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    body.add(add);
    body.add(read);
    body.add(modify);
    TextFormGroup minOccurs = new TextFormGroup(ID_MIN_OCCURS, new PropertyModel<String>(item.getModelObject(), PropertyLimitationsTypeDto.F_LIMITATION + ".minOccurs"), createStringResource("LimitationsEditorDialog.label.minOccurs"), "SchemaHandlingStep.limitations.tooltip.minOccurs", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false, false);
    minOccurs.getField().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(minOccurs);
    TextFormGroup maxOccurs = new TextFormGroup(ID_MAX_OCCURS, new PropertyModel<String>(item.getModelObject(), PropertyLimitationsTypeDto.F_LIMITATION + ".maxOccurs"), createStringResource("LimitationsEditorDialog.label.maxOccurs"), "SchemaHandlingStep.limitations.tooltip.maxOccurs", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false, false);
    maxOccurs.getField().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(maxOccurs);
    CheckFormGroup ignore = new CheckFormGroup(ID_IGNORE, new PropertyModel<Boolean>(item.getModelObject(), PropertyLimitationsTypeDto.F_LIMITATION + ".ignore"), createStringResource("LimitationsEditorDialog.label.ignore"), "SchemaHandlingStep.limitations.tooltip.ignore", true, ID_LABEL_SIZE, ID_INPUT_SIZE);
    ignore.getCheck().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(ignore);
    Label layersTooltip = new Label(ID_T_LAYERS);
    layersTooltip.add(new InfoTooltipBehavior(true) {

        @Override
        public String getModalContainer(Component component) {
            return body.getMarkupId();
        }
    });
    body.add(layersTooltip);
    Label propertyTooltip = new Label(ID_T_PROPERTY);
    propertyTooltip.add(new InfoTooltipBehavior(true) {

        @Override
        public String getModalContainer(Component component) {
            return body.getMarkupId();
        }
    });
    body.add(propertyTooltip);
}
Also used : DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) TextFormGroup(com.evolveum.midpoint.web.component.form.TextFormGroup) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) Label(org.apache.wicket.markup.html.basic.Label) CheckFormGroup(com.evolveum.midpoint.web.component.form.CheckFormGroup) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) FormComponent(org.apache.wicket.markup.html.form.FormComponent) Component(org.apache.wicket.Component)

Example 8 with EmptyOnChangeAjaxFormUpdatingBehavior

use of com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior in project midpoint by Evolveum.

the class CapabilityScriptPanel method initLayout.

protected void initLayout(final WebMarkupContainer capabilitiesTable, PageResourceWizard parentPage) {
    parentPage.addEditingEnabledBehavior(this);
    CheckBox enabled = new CheckBox(ID_ENABLED, new PropertyModel<Boolean>(getModel(), "capability.enabled"));
    enabled.add(new EmptyOnChangeAjaxFormUpdatingBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(capabilitiesTable);
        }
    });
    add(enabled);
    MultiValueTextPanel onConnector = new MultiValueTextPanel(ID_ON_CONNECTOR, prepareOnConnectorModel(), parentPage.getReadOnlyModel(), true);
    add(onConnector);
    MultiValueTextPanel onResource = new MultiValueTextPanel(ID_ON_RESOURCE, Model.of(prepareOnResourceModel()), parentPage.getReadOnlyModel(), true);
    add(onResource);
    Label enabledTooltip = new Label(ID_T_ENABLED);
    enabledTooltip.add(new InfoTooltipBehavior());
    add(enabledTooltip);
    Label onConnectorTooltip = new Label(ID_T_ON_CONNECTOR);
    onConnectorTooltip.add(new InfoTooltipBehavior());
    add(onConnectorTooltip);
    Label onResourceTooltip = new Label(ID_T_ON_RESOURCE);
    onResourceTooltip.add(new InfoTooltipBehavior());
    add(onResourceTooltip);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) CheckBox(org.apache.wicket.markup.html.form.CheckBox) Label(org.apache.wicket.markup.html.basic.Label) MultiValueTextPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextPanel)

Example 9 with EmptyOnChangeAjaxFormUpdatingBehavior

use of com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior in project midpoint by Evolveum.

the class CapabilityValuePanel method initLayout.

protected void initLayout(PageResourceWizard parentPage) {
    parentPage.addEditingEnabledBehavior(this);
    Label label = new Label(ID_LABEL, createStringResource(getCapabilityLabelKey()));
    add(label);
    CheckBox enabled = new CheckBox(ID_ENABLED, new PropertyModel<Boolean>(getModel(), "capability.enabled"));
    enabled.add(new EmptyOnChangeAjaxFormUpdatingBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(capabilityTable);
        }
    });
    add(enabled);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) CheckBox(org.apache.wicket.markup.html.form.CheckBox) Label(org.apache.wicket.markup.html.basic.Label)

Example 10 with EmptyOnChangeAjaxFormUpdatingBehavior

use of com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior in project midpoint by Evolveum.

the class SchemaHandlingStep method initObjectTypeEditor.

private void initObjectTypeEditor(WebMarkupContainer editor) {
    Label editorLabel = new Label(ID_EDITOR_NAME, new AbstractReadOnlyModel<Object>() {

        @Override
        public String getObject() {
            ResourceObjectTypeDefinitionTypeDto selected = schemaHandlingDtoModel.getObject().getSelectedObjectTypeDto();
            return selected != null ? selected.getObjectType().getDisplayName() : "";
        }
    });
    editorLabel.setOutputMarkupId(true);
    editor.add(editorLabel);
    DropDownChoice editorKind = new DropDownChoice<>(ID_EDITOR_KIND, new PropertyModel<ShadowKindType>(schemaHandlingDtoModel, getExpression(ResourceObjectTypeDefinitionType.F_KIND)), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>(this));
    editorKind.add(new UpdateNamesBehaviour());
    parentPage.addEditingEnabledBehavior(editorKind);
    editor.add(editorKind);
    TextField editorIntent = new TextField<>(ID_EDITOR_INTENT, new PropertyModel<String>(schemaHandlingDtoModel, getExpression(ResourceObjectTypeDefinitionType.F_INTENT)));
    editorIntent.add(new UpdateNamesBehaviour());
    parentPage.addEditingEnabledBehavior(editorIntent);
    editor.add(editorIntent);
    TextField editorDisplayName = new TextField<>(ID_EDITOR_DISPLAY_NAME, new PropertyModel<String>(schemaHandlingDtoModel, getExpression(ResourceObjectTypeDefinitionType.F_DISPLAY_NAME)));
    editorDisplayName.add(new UpdateNamesBehaviour());
    parentPage.addEditingEnabledBehavior(editorDisplayName);
    editor.add(editorDisplayName);
    TextArea editorDescription = new TextArea<>(ID_EDITOR_DESCRIPTION, new PropertyModel<String>(schemaHandlingDtoModel, getExpression(ResourceObjectTypeDefinitionType.F_DESCRIPTION)));
    parentPage.addEditingEnabledBehavior(editorDescription);
    editor.add(editorDescription);
    final CheckBox editorDefault = new CheckBox(ID_EDITOR_DEFAULT, new PropertyModel<Boolean>(schemaHandlingDtoModel, getExpression(ResourceObjectTypeDefinitionType.F_DEFAULT)));
    editorDefault.add(new EmptyOnChangeAjaxFormUpdatingBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            Boolean newValue = editorDefault.getModelObject();
            if (Boolean.TRUE.equals(newValue)) {
                SchemaHandlingDto dto = schemaHandlingDtoModel.getObject();
                ResourceObjectTypeDefinitionTypeDto selected = dto.getSelectedObjectTypeDto();
                ShadowKindType selectedKind = fillDefault(selected.getObjectType().getKind());
                for (ResourceObjectTypeDefinitionTypeDto currentObjectTypeDto : dto.getObjectTypeDtoList()) {
                    ShadowKindType currentKind = fillDefault(currentObjectTypeDto.getObjectType().getKind());
                    if (currentObjectTypeDto != selected && currentKind == selectedKind && Boolean.TRUE.equals(currentObjectTypeDto.getObjectType().isDefault())) {
                        currentObjectTypeDto.getObjectType().setDefault(false);
                    }
                }
            }
            parentPage.refreshIssues(target);
        }
    });
    parentPage.addEditingEnabledBehavior(editorDefault);
    editor.add(editorDefault);
    AjaxSubmitLink editorDependency = new AjaxSubmitLink(ID_EDITOR_BUTTON_DEPENDENCY) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            dependencyEditPerformed(target);
        }
    };
    addDisabledClassModifier(editorDependency);
    editor.add(editorDependency);
    AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
    autoCompleteSettings.setShowListOnEmptyInput(true);
    autoCompleteSettings.setMaxHeightInPx(200);
    AutoCompleteTextField<String> editorObjectClass = new AutoCompleteTextField<String>(ID_EDITOR_OBJECT_CLASS, new PropertyModel<String>(schemaHandlingDtoModel, SchemaHandlingDto.F_OBJECT_CLASS_NAME), autoCompleteSettings) {

        @Override
        protected Iterator<String> getChoices(String input) {
            return getObjectClassChoices(input);
        }
    };
    editorObjectClass.add(new UpdateNamesBehaviour());
    editorObjectClass.add(createObjectClassValidator(new AbstractReadOnlyModel<List<QName>>() {

        @Override
        public List<QName> getObject() {
            return schemaHandlingDtoModel.getObject().getObjectClassList();
        }
    }));
    parentPage.addEditingEnabledBehavior(editorObjectClass);
    editorObjectClass.setConvertEmptyInputStringToNull(true);
    editor.add(editorObjectClass);
    MultiValueTextEditPanel editorAttributes = new MultiValueTextEditPanel<ResourceAttributeDefinitionType>(ID_EDITOR_ATTRIBUTES, new PropertyModel<List<ResourceAttributeDefinitionType>>(schemaHandlingDtoModel, getExpression(ResourceObjectTypeDefinitionType.F_ATTRIBUTE)), new PropertyModel<ResourceAttributeDefinitionType>(schemaHandlingDtoModel, SchemaHandlingDto.F_SELECTED_ATTRIBUTE), false, true, parentPage.getReadOnlyModel()) {

        @Override
        protected IModel<String> createTextModel(final IModel<ResourceAttributeDefinitionType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    if (model == null || model.getObject() == null) {
                        return null;
                    }
                    ResourceAttributeDefinitionType attribute = model.getObject();
                    return formatItemInfo(attribute, attribute.getRef(), attribute.getDisplayName(), attribute.getInbound(), attribute.getOutbound());
                }
            };
        }

        @Override
        protected ResourceAttributeDefinitionType createNewEmptyItem() {
            return createEmptyAttributeObject();
        }

        @Override
        protected void performAddValueHook(AjaxRequestTarget target, ResourceAttributeDefinitionType added) {
            parentPage.refreshIssues(target);
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, ResourceAttributeDefinitionType object) {
            editAttributePerformed(target, object);
        }

        @Override
        protected boolean buttonsDisabled() {
            return !isAnySelected();
        }

        @Override
        protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<ResourceAttributeDefinitionType> item) {
            resetThirdRowContainer(target);
            parentPage.refreshIssues(target);
        }
    };
    editorAttributes.setOutputMarkupId(true);
    editor.add(editorAttributes);
    MultiValueTextEditPanel editorAssociations = new MultiValueTextEditPanel<ResourceObjectAssociationType>(ID_EDITOR_ASSOCIATIONS, new PropertyModel<List<ResourceObjectAssociationType>>(schemaHandlingDtoModel, getExpression(ResourceObjectTypeDefinitionType.F_ASSOCIATION)), new PropertyModel<ResourceObjectAssociationType>(schemaHandlingDtoModel, SchemaHandlingDto.F_SELECTED_ASSOCIATION), false, true, parentPage.getReadOnlyModel()) {

        @Override
        protected IModel<String> createTextModel(final IModel<ResourceObjectAssociationType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    ResourceObjectAssociationType association = model.getObject();
                    if (association == null) {
                        return null;
                    }
                    return formatItemInfo(association, association.getRef(), association.getDisplayName(), association.getInbound(), association.getOutbound());
                }
            };
        }

        @Override
        protected ResourceObjectAssociationType createNewEmptyItem() {
            return createEmptyAssociationObject();
        }

        @Override
        protected void performAddValueHook(AjaxRequestTarget target, ResourceObjectAssociationType added) {
            parentPage.refreshIssues(target);
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, ResourceObjectAssociationType object) {
            editAssociationPerformed(target, object);
        }

        @Override
        protected boolean buttonsDisabled() {
            return !isAnySelected();
        }

        @Override
        protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<ResourceObjectAssociationType> item) {
            resetThirdRowContainer(target);
            parentPage.refreshIssues(target);
        }
    };
    editorAssociations.setOutputMarkupId(true);
    editor.add(editorAssociations);
    //        DropDownChoice editorAssignmentPolicyRef = new DropDownChoice<>(ID_EDITOR_ASSIGNMENT_POLICY,
    //                new PropertyModel<AssignmentPolicyEnforcementType>(schemaHandlingDtoModel,
    //						getExpression(ResourceObjectTypeDefinitionType.F_ASSIGNMENT_POLICY_ENFORCEMENT)),
    //                WebComponentUtil.createReadonlyModelFromEnum(AssignmentPolicyEnforcementType.class),
    //                new EnumChoiceRenderer<AssignmentPolicyEnforcementType>(this));
    //		parentPage.addEditingEnabledBehavior(editorAssignmentPolicyRef);
    //        editor.add(editorAssignmentPolicyRef);
    AjaxSubmitLink editorIteration = new AjaxSubmitLink(ID_EDITOR_BUTTON_ITERATION) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            iterationEditPerformed(target);
        }
    };
    addDisabledClassModifier(editorIteration);
    editor.add(editorIteration);
    AjaxSubmitLink editorProtected = new AjaxSubmitLink(ID_EDITOR_BUTTON_PROTECTED) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            protectedEditPerformed(target);
        }
    };
    addDisabledClassModifier(editorProtected);
    editor.add(editorProtected);
    AjaxSubmitLink editorActivation = new AjaxSubmitLink(ID_EDITOR_BUTTON_ACTIVATION) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            activationEditPerformed(target);
        }
    };
    addDisabledClassModifier(editorActivation);
    editor.add(editorActivation);
    AjaxSubmitLink editorCredentials = new AjaxSubmitLink(ID_EDITOR_BUTTON_CREDENTIALS) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            credentialsEditPerformed(target);
        }
    };
    addDisabledClassModifier(editorCredentials);
    editor.add(editorCredentials);
    Label kindTooltip = new Label(ID_T_KIND);
    kindTooltip.add(new InfoTooltipBehavior());
    editor.add(kindTooltip);
    Label intentTooltip = new Label(ID_T_INTENT);
    intentTooltip.add(new InfoTooltipBehavior());
    editor.add(intentTooltip);
    Label defaultTooltip = new Label(ID_T_DEFAULT);
    defaultTooltip.add(new InfoTooltipBehavior());
    editor.add(defaultTooltip);
    Label dependencyTooltip = new Label(ID_T_DEPENDENCY);
    dependencyTooltip.add(new InfoTooltipBehavior());
    editor.add(dependencyTooltip);
    Label objectClassTooltip = new Label(ID_T_OBJECT_CLASS);
    objectClassTooltip.add(new InfoTooltipBehavior());
    editor.add(objectClassTooltip);
    Label attributesTooltip = new Label(ID_T_ATTRIBUTES);
    attributesTooltip.add(new InfoTooltipBehavior());
    editor.add(attributesTooltip);
    Label associationsTooltip = new Label(ID_T_ASSOCIATIONS);
    associationsTooltip.add(new InfoTooltipBehavior());
    editor.add(associationsTooltip);
    Label assignmentPolicyRefTooltip = new Label(ID_T_ASSIGNMENT_POLICY_REF);
    assignmentPolicyRefTooltip.add(new InfoTooltipBehavior());
    editor.add(assignmentPolicyRefTooltip);
    Label iterationTooltip = new Label(ID_T_ITERATION);
    iterationTooltip.add(new InfoTooltipBehavior());
    editor.add(iterationTooltip);
    Label protectedTooltip = new Label(ID_T_PROTECTED);
    protectedTooltip.add(new InfoTooltipBehavior());
    editor.add(protectedTooltip);
    Label activationTooltip = new Label(ID_T_ACTIVATION);
    activationTooltip.add(new InfoTooltipBehavior());
    editor.add(activationTooltip);
    Label credentialsTooltip = new Label(ID_T_CREDENTIALS);
    credentialsTooltip.add(new InfoTooltipBehavior());
    editor.add(credentialsTooltip);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) MultiValueTextEditPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) ResourceObjectTypeDefinitionTypeDto(com.evolveum.midpoint.web.component.wizard.resource.dto.ResourceObjectTypeDefinitionTypeDto) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) List(java.util.List) ArrayList(java.util.ArrayList) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) SchemaHandlingDto(com.evolveum.midpoint.web.component.wizard.resource.dto.SchemaHandlingDto) AutoCompleteSettings(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) NonEmptyLoadableModel(com.evolveum.midpoint.gui.api.model.NonEmptyLoadableModel) PropertyModel(org.apache.wicket.model.PropertyModel) PrismObject(com.evolveum.midpoint.prism.PrismObject) ListItem(org.apache.wicket.markup.html.list.ListItem)

Aggregations

EmptyOnChangeAjaxFormUpdatingBehavior (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior)11 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)9 Label (org.apache.wicket.markup.html.basic.Label)8 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)7 ArrayList (java.util.ArrayList)5 List (java.util.List)5 QName (javax.xml.namespace.QName)5 MultiValueTextEditPanel (com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel)4 CheckBox (org.apache.wicket.markup.html.form.CheckBox)4 ListItem (org.apache.wicket.markup.html.list.ListItem)4 MultiValueTextPanel (com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextPanel)3 QNameChoiceRenderer (com.evolveum.midpoint.web.component.input.QNameChoiceRenderer)3 PageResourceWizard (com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard)3 AjaxSubmitLink (org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink)3 NonEmptyModel (com.evolveum.midpoint.gui.api.model.NonEmptyModel)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)2 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)2