Search in sources :

Example 96 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class ResourceCredentialsEditor method initLayout.

protected void initLayout(final PageResourceWizard parentPage) {
    DropDownChoice fetchStrategy = new DropDownChoice<>(ID_FETCH_STRATEGY, new PropertyModel<AttributeFetchStrategyType>(getModel(), "password.fetchStrategy"), WebComponentUtil.createReadonlyModelFromEnum(AttributeFetchStrategyType.class), new EnumChoiceRenderer<AttributeFetchStrategyType>(this));
    parentPage.addEditingEnabledBehavior(fetchStrategy);
    add(fetchStrategy);
    VisibleEnableBehaviour showIfEditingOrOutboundExists = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            ResourceCredentialsDefinitionType credentials = getModel().getObject();
            if (credentials == null || credentials.getPassword() == null) {
                return !parentPage.isReadOnly();
            }
            return !parentPage.isReadOnly() || credentials.getPassword().getOutbound() != null;
        }
    };
    TextField outboundLabel = new TextField<>(ID_OUTBOUND_LABEL, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            ResourceCredentialsDefinitionType credentials = getModel().getObject();
            if (credentials == null || credentials.getPassword() == null) {
                return null;
            }
            // TODO: support multiple password mappings
            MappingType outbound = null;
            List<MappingType> outbounds = credentials.getPassword().getOutbound();
            if (!outbounds.isEmpty()) {
                outbound = outbounds.get(0);
            }
            return MappingTypeDto.createMappingLabel(outbound, LOGGER, getPageBase().getPrismContext(), getString("MappingType.label.placeholder"), getString("MultiValueField.nameNotSpecified"));
        }
    });
    outboundLabel.setEnabled(false);
    outboundLabel.setOutputMarkupId(true);
    outboundLabel.add(showIfEditingOrOutboundExists);
    add(outboundLabel);
    AjaxSubmitLink outbound = new AjaxSubmitLink(ID_OUTBOUND_BUTTON) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            outboundEditPerformed(target);
        }
    };
    outbound.setOutputMarkupId(true);
    outbound.add(showIfEditingOrOutboundExists);
    add(outbound);
    MultiValueTextEditPanel inbound = new MultiValueTextEditPanel<MappingType>(ID_INBOUND, new PropertyModel<List<MappingType>>(getModel(), "password.inbound"), null, false, true, parentPage.getReadOnlyModel()) {

        @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 editPerformed(AjaxRequestTarget target, MappingType object) {
            inboundEditPerformed(target, object);
        }
    };
    inbound.setOutputMarkupId(true);
    add(inbound);
    DropDownChoice passwordPolicy = new DropDownChoice<>(ID_PASS_POLICY, new PropertyModel<ObjectReferenceType>(getModel(), "password.passwordPolicyRef"), new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

        @Override
        public List<ObjectReferenceType> getObject() {
            return WebModelServiceUtils.createObjectReferenceList(ValuePolicyType.class, getPageBase(), passPolicyMap);
        }
    }, new ObjectReferenceChoiceRenderer(passPolicyMap));
    parentPage.addEditingEnabledBehavior(passwordPolicy);
    add(passwordPolicy);
    Label fetchTooltip = new Label(ID_T_FETCH);
    fetchTooltip.add(new InfoTooltipBehavior());
    add(fetchTooltip);
    Label outTooltip = new Label(ID_T_OUT);
    outTooltip.add(new InfoTooltipBehavior());
    add(outTooltip);
    Label inTooltip = new Label(ID_T_IN);
    inTooltip.add(new InfoTooltipBehavior());
    add(inTooltip);
    Label passPolicyTooltip = new Label(ID_T_PASS_POLICY);
    passPolicyTooltip.add(new InfoTooltipBehavior());
    add(passPolicyTooltip);
    initModals(parentPage.getReadOnlyModel());
}
Also used : ObjectReferenceChoiceRenderer(com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer) Form(org.apache.wicket.markup.html.form.Form) 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) TextField(org.apache.wicket.markup.html.form.TextField) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) IModel(org.apache.wicket.model.IModel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) NonEmptyModel(com.evolveum.midpoint.gui.api.model.NonEmptyModel) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel)

Example 97 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class ResourceCredentialsEditor method initModals.

private void initModals(NonEmptyModel<Boolean> readOnlyModel) {
    ModalWindow inboundEditor = new MappingEditorDialog(ID_MODAL_INBOUND, null, readOnlyModel) {

        @Override
        public void updateComponents(AjaxRequestTarget target) {
            target.add(ResourceCredentialsEditor.this.get(ID_INBOUND));
        }
    };
    add(inboundEditor);
    ModalWindow outboundEditor = new MappingEditorDialog(ID_MODAL_OUTBOUND, null, readOnlyModel) {

        @Override
        public void updateComponents(AjaxRequestTarget target) {
            target.add(ResourceCredentialsEditor.this.get(ID_OUTBOUND_LABEL), ResourceCredentialsEditor.this.get(ID_OUTBOUND_BUTTON));
        }
    };
    add(outboundEditor);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) MappingEditorDialog(com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.modal.MappingEditorDialog) ModalWindow(org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow)

Example 98 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class ResourceDependencyEditor method initLayout.

protected void initLayout(final PageResourceWizard parentPage) {
    WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
    container.setOutputMarkupId(true);
    add(container);
    ListView repeater = new ListView<ResourceObjectTypeDependencyType>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<ResourceObjectTypeDependencyType> item) {
            WebMarkupContainer linkContainer = new WebMarkupContainer(ID_DEPENDENCY_LINK);
            linkContainer.setOutputMarkupId(true);
            linkContainer.add(new AttributeModifier("href", createCollapseItemId(item, true)));
            item.add(linkContainer);
            Label linkLabel = new Label(ID_DEPENDENCY_LINK_NAME, createDependencyLabelModel(item));
            linkContainer.add(linkLabel);
            AjaxLink delete = new AjaxLink(ID_DELETE_BUTTON) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteDependencyPerformed(target, item);
                }
            };
            parentPage.addEditingVisibleBehavior(delete);
            linkContainer.add(delete);
            WebMarkupContainer dependencyBody = new WebMarkupContainer(ID_DEPENDENCY_BODY);
            dependencyBody.setOutputMarkupId(true);
            dependencyBody.setMarkupId(createCollapseItemId(item, false).getObject());
            if (changeState != ChangeState.SKIP) {
                dependencyBody.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

                    @Override
                    public String getObject() {
                        if (changeState == ChangeState.FIRST && item.getIndex() == 0) {
                            return "panel-collapse collapse in";
                        } else if (changeState == ChangeState.LAST && item.getIndex() == (getModelObject().size() - 1)) {
                            return "panel-collapse collapse in";
                        } else {
                            return "panel-collapse collapse";
                        }
                    }
                }));
            }
            item.add(dependencyBody);
            TextField order = new TextField<>(ID_ORDER, new PropertyModel<Integer>(item.getModelObject(), "order"));
            order.add(prepareAjaxOnComponentTagUpdateBehavior());
            parentPage.addEditingEnabledBehavior(order);
            dependencyBody.add(order);
            DropDownChoice strictness = new DropDownChoice<>(ID_STRICTNESS, new PropertyModel<ResourceObjectTypeDependencyStrictnessType>(item.getModelObject(), "strictness"), WebComponentUtil.createReadonlyModelFromEnum(ResourceObjectTypeDependencyStrictnessType.class), new EnumChoiceRenderer<ResourceObjectTypeDependencyStrictnessType>(this));
            strictness.add(prepareAjaxOnComponentTagUpdateBehavior());
            parentPage.addEditingEnabledBehavior(strictness);
            dependencyBody.add(strictness);
            DropDownChoice kind = new DropDownChoice<>(ID_KIND, new PropertyModel<ShadowKindType>(item.getModelObject(), "kind"), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>(this));
            kind.add(prepareAjaxOnComponentTagUpdateBehavior());
            parentPage.addEditingEnabledBehavior(kind);
            dependencyBody.add(kind);
            TextField intent = new TextField<>(ID_INTENT, new PropertyModel<String>(item.getModelObject(), "intent"));
            intent.add(prepareAjaxOnComponentTagUpdateBehavior());
            parentPage.addEditingEnabledBehavior(intent);
            dependencyBody.add(intent);
            DropDownChoice resource = new DropDownChoice<>(ID_REF, new PropertyModel<ObjectReferenceType>(item.getModelObject(), "resourceRef"), new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

                @Override
                public List<ObjectReferenceType> getObject() {
                    return WebModelServiceUtils.createObjectReferenceList(ResourceType.class, getPageBase(), resourceMap);
                }
            }, new ObjectReferenceChoiceRenderer(resourceMap));
            resource.add(prepareAjaxOnComponentTagUpdateBehavior());
            parentPage.addEditingEnabledBehavior(resource);
            dependencyBody.add(resource);
            Label orderTooltip = new Label(ID_T_ORDER);
            orderTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(orderTooltip);
            Label strictnessTooltip = new Label(ID_T_STRICTNESS);
            strictnessTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(strictnessTooltip);
            Label kindTooltip = new Label(ID_T_KIND);
            kindTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(kindTooltip);
            Label intentTooltip = new Label(ID_T_INTENT);
            intentTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(intentTooltip);
            Label resourceRefTooltip = new Label(ID_T_RESOURCE_REF);
            resourceRefTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(resourceRefTooltip);
        }
    };
    repeater.setOutputMarkupId(true);
    container.add(repeater);
    AjaxLink add = new AjaxLink(ID_ADD_BUTTON) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addDependencyPerformed(target);
        }
    };
    parentPage.addEditingVisibleBehavior(add);
    add(add);
}
Also used : ObjectReferenceChoiceRenderer(com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) 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) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 99 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class ResourceIterationEditor method prepareIterationSubsectionBody.

private void prepareIterationSubsectionBody(String containerValue, String descriptionId, String variableId, String returnMultiplicityId, String expressionType, final String expression, final String languageId, final String policyId, final String prefix, final String languageContainerId, final String policyContainerId, PageResourceWizard parentPage) {
    TextArea description = new TextArea<>(descriptionId, new PropertyModel<String>(model, IterationSpecificationTypeDto.F_ITERATION + "." + containerValue + ".description"));
    parentPage.addEditingEnabledBehavior(description);
    add(description);
    MultiValueTextEditPanel variableList = new MultiValueTextEditPanel<ExpressionVariableDefinitionType>(variableId, new PropertyModel<List<ExpressionVariableDefinitionType>>(model, IterationSpecificationTypeDto.F_ITERATION + "." + containerValue + ".variable"), null, false, true, parentPage.getReadOnlyModel()) {

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

                @Override
                public String getObject() {
                    ExpressionVariableDefinitionType variable = model.getObject();
                    if (variable != null && variable.getName() != null) {
                        return variable.getName().getLocalPart();
                    } else {
                        return null;
                    }
                }
            };
        }

        @Override
        protected ExpressionVariableDefinitionType createNewEmptyItem() {
            return new ExpressionVariableDefinitionType();
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, ExpressionVariableDefinitionType object) {
            expressionVariableEditPerformed(target, object);
        }
    };
    add(variableList);
    DropDownChoice returnMultiplicity = new DropDownChoice<>(returnMultiplicityId, new PropertyModel<ExpressionReturnMultiplicityType>(model, IterationSpecificationTypeDto.F_ITERATION + "." + containerValue + ".returnMultiplicity"), WebComponentUtil.createReadonlyModelFromEnum(ExpressionReturnMultiplicityType.class), new EnumChoiceRenderer<ExpressionReturnMultiplicityType>(this));
    parentPage.addEditingEnabledBehavior(returnMultiplicity);
    add(returnMultiplicity);
}
Also used : IModel(org.apache.wicket.model.IModel) TextArea(org.apache.wicket.markup.html.form.TextArea) MultiValueTextEditPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) IModel(org.apache.wicket.model.IModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) List(java.util.List)

Example 100 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class CertDecisionHelper method createTargetNameColumn.

<T extends CertCaseOrWorkItemDto> IColumn<T, String> createTargetNameColumn(final PageBase page, final String headerKey) {
    IColumn column;
    column = new LinkColumn<CertCaseOrWorkItemDto>(page.createStringResource(headerKey), SearchingUtils.TARGET_NAME, CertCaseOrWorkItemDto.F_TARGET_NAME) {

        @Override
        public void onClick(AjaxRequestTarget target, IModel<CertCaseOrWorkItemDto> rowModel) {
            CertCaseOrWorkItemDto dto = rowModel.getObject();
            dispatchToObjectDetailsPage(dto.getCertCase().getTargetRef(), page, false);
        }
    };
    return column;
}
Also used : CertCaseOrWorkItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCaseOrWorkItemDto) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)

Aggregations

AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)379 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)116 Label (org.apache.wicket.markup.html.basic.Label)103 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)102 ArrayList (java.util.ArrayList)88 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)80 Form (org.apache.wicket.markup.html.form.Form)75 IModel (org.apache.wicket.model.IModel)71 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)69 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)65 List (java.util.List)53 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)48 Model (org.apache.wicket.model.Model)43 PropertyModel (org.apache.wicket.model.PropertyModel)42 ListItem (org.apache.wicket.markup.html.list.ListItem)41 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)37 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)34 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)32 TextField (org.apache.wicket.markup.html.form.TextField)30 ListView (org.apache.wicket.markup.html.list.ListView)30