Search in sources :

Example 1 with AjaxSubmitLink

use of org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink in project midpoint by Evolveum.

the class SynchronizationStep method initObjectSyncEditor.

private void initObjectSyncEditor(WebMarkupContainer editor) {
    Label editorLabel = new Label(ID_EDITOR_LABEL, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (!isAnySelected()) {
                // shouldn't occur
                return null;
            }
            String name = syncDtoModel.getObject().getSelected().getName() != null ? syncDtoModel.getObject().getSelected().getName() : "";
            return getString("SynchronizationStep.label.editSyncObject", name);
        }
    });
    editorLabel.setOutputMarkupId(true);
    editor.add(editorLabel);
    TextField editorName = new TextField<>(ID_EDITOR_NAME, new PropertyModel<String>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".name"));
    editorName.add(new UpdateNamesBehaviour());
    parentPage.addEditingEnabledBehavior(editorName);
    editor.add(editorName);
    TextArea editorDescription = new TextArea<>(ID_EDITOR_DESCRIPTION, new PropertyModel<String>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".description"));
    parentPage.addEditingEnabledBehavior(editorDescription);
    editor.add(editorDescription);
    DropDownChoice editorKind = new DropDownChoice<>(ID_EDITOR_KIND, new PropertyModel<ShadowKindType>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".kind"), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>());
    editorKind.setNullValid(true);
    editorKind.add(new UpdateNamesBehaviour());
    parentPage.addEditingEnabledBehavior(editorKind);
    editor.add(editorKind);
    TextField editorIntent = new TextField<>(ID_EDITOR_INTENT, new PropertyModel<String>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".intent"));
    editorIntent.add(new UpdateNamesBehaviour());
    parentPage.addEditingEnabledBehavior(editorIntent);
    editor.add(editorIntent);
    MultiValueAutoCompleteTextPanel<QName> editorObjectClass = new MultiValueAutoCompleteTextPanel<QName>(ID_EDITOR_OBJECT_CLASS, new PropertyModel<List<QName>>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".objectClass"), true, parentPage.getReadOnlyModel()) {

        @Override
        protected IModel<String> createTextModel(final IModel<QName> model) {
            return new PropertyModel<>(model, "localPart");
        }

        @Override
        protected QName createNewEmptyItem() {
            return new QName("");
        }

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

        @Override
        protected List<QName> createObjectList() {
            return syncDtoModel.getObject().getObjectClassList();
        }

        @Override
        protected String createAutoCompleteObjectLabel(QName object) {
            return object.getLocalPart();
        }

        @Override
        protected IValidator<String> createAutoCompleteValidator() {
            return createObjectClassValidator(new AbstractReadOnlyModel<List<QName>>() {

                @Override
                public List<QName> getObject() {
                    return syncDtoModel.getObject().getObjectClassList();
                }
            });
        }
    };
    parentPage.addEditingEnabledBehavior(editorObjectClass);
    editor.add(editorObjectClass);
    // TODO: switch to ObjectTypeSelectPanel
    DropDownChoice editorFocus = new DropDownChoice<>(ID_EDITOR_FOCUS, new PropertyModel<QName>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".focusType"), new AbstractReadOnlyModel<List<QName>>() {

        @Override
        public List<QName> getObject() {
            return WebComponentUtil.createFocusTypeList();
        }
    }, new QNameChoiceRenderer());
    editorFocus.setNullValid(true);
    editorFocus.add(new UpdateNamesBehaviour());
    parentPage.addEditingEnabledBehavior(editorFocus);
    editor.add(editorFocus);
    CheckBox editorEnabled = new CheckBox(ID_EDITOR_ENABLED, new PropertyModel<Boolean>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".enabled"));
    parentPage.addEditingEnabledBehavior(editorEnabled);
    editor.add(editorEnabled);
    AjaxSubmitLink editorCondition = new AjaxSubmitLink(ID_EDITOR_BUTTON_CONDITION) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            conditionEditPerformed(target);
        }
    };
    addDisableClassModifier(editorCondition);
    editor.add(editorCondition);
    AjaxSubmitLink editorConfirmation = new AjaxSubmitLink(ID_EDITOR_BUTTON_CONFIRMATION) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            confirmationEditPerformed(target);
        }
    };
    addDisableClassModifier(editorConfirmation);
    editor.add(editorConfirmation);
    DropDownChoice editorObjectTemplate = new DropDownChoice<>(ID_EDITOR_OBJECT_TEMPLATE, new PropertyModel<ObjectReferenceType>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".objectTemplateRef"), new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

        @Override
        public List<ObjectReferenceType> getObject() {
            return WebModelServiceUtils.createObjectReferenceList(ObjectTemplateType.class, getPageBase(), syncDtoModel.getObject().getObjectTemplateMap());
        }
    }, new ObjectReferenceChoiceRenderer(syncDtoModel.getObject().getObjectTemplateMap()));
    editorObjectTemplate.setNullValid(true);
    parentPage.addEditingEnabledBehavior(editorObjectTemplate);
    editor.add(editorObjectTemplate);
    CheckBox editorReconcile = new CheckBox(ID_EDITOR_RECONCILE, new PropertyModel<Boolean>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".reconcile"));
    parentPage.addEditingEnabledBehavior(editorReconcile);
    editor.add(editorReconcile);
    TriStateComboPanel opportunistic = new TriStateComboPanel(ID_EDITOR_OPPORTUNISTIC, new PropertyModel<Boolean>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".opportunistic"));
    parentPage.addEditingEnabledBehavior(opportunistic);
    editor.add(opportunistic);
    MultiValueTextEditPanel editorCorrelation = new MultiValueTextEditPanel<ConditionalSearchFilterType>(ID_EDITOR_EDITOR_CORRELATION, new PropertyModel<List<ConditionalSearchFilterType>>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".correlation"), new PropertyModel<ConditionalSearchFilterType>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED_CORRELATION), false, true, parentPage.getReadOnlyModel()) {

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

                @Override
                public String getObject() {
                    StringBuilder sb = new StringBuilder();
                    ConditionalSearchFilterType searchFilter = model.getObject();
                    if (searchFilter != null && searchFilter.getDescription() != null) {
                        sb.append(searchFilter.getDescription());
                    }
                    if (sb.toString().isEmpty()) {
                        sb.append(getString("SynchronizationStep.label.notSpecified"));
                    }
                    return sb.toString();
                }
            };
        }

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

        @Override
        protected void editPerformed(AjaxRequestTarget target, ConditionalSearchFilterType object) {
            correlationEditPerformed(target, object);
        }

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

        @Override
        protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<ConditionalSearchFilterType> item) {
            parentPage.refreshIssues(target);
        }

        @Override
        protected boolean buttonsDisabled() {
            return !isAnySelected();
        }
    };
    editor.add(editorCorrelation);
    MultiValueTextEditPanel editorReaction = new MultiValueTextEditPanel<SynchronizationReactionType>(ID_EDITOR_REACTION, new PropertyModel<List<SynchronizationReactionType>>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".reaction"), new PropertyModel<SynchronizationReactionType>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED_REACTION), false, true, parentPage.getReadOnlyModel()) {

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

                @Override
                public String getObject() {
                    SynchronizationReactionType reaction = model.getObject();
                    if (reaction == null) {
                        return "";
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.append(reaction.getName() != null ? reaction.getName() + " " : "");
                    sb.append("(");
                    if (reaction.getSituation() != null) {
                        sb.append(reaction.getSituation());
                    }
                    if (Boolean.TRUE.equals(reaction.isSynchronize()) || !reaction.getAction().isEmpty()) {
                        sb.append(" -> ");
                        if (!reaction.getAction().isEmpty()) {
                            boolean first = true;
                            for (SynchronizationActionType action : reaction.getAction()) {
                                if (first) {
                                    first = false;
                                } else {
                                    sb.append(", ");
                                }
                                sb.append(StringUtils.substringAfter(action.getHandlerUri(), "#"));
                            }
                        } else {
                            // TODO i18n
                            sb.append("sync");
                        }
                    }
                    sb.append(")");
                    return sb.toString();
                }
            };
        }

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

        @Override
        protected void editPerformed(AjaxRequestTarget target, SynchronizationReactionType object) {
            reactionEditPerformed(target, object);
        }

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

        @Override
        protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<SynchronizationReactionType> item) {
            parentPage.refreshIssues(target);
        }

        @Override
        protected boolean buttonsDisabled() {
            return !isAnySelected();
        }
    };
    editorReaction.setOutputMarkupId(true);
    editor.add(editorReaction);
    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 objClassTooltip = new Label(ID_T_OBJ_CLASS);
    objClassTooltip.add(new InfoTooltipBehavior());
    editor.add(objClassTooltip);
    Label focusTooltip = new Label(ID_T_FOCUS);
    focusTooltip.add(new InfoTooltipBehavior());
    editor.add(focusTooltip);
    Label enabledTooltip = new Label(ID_T_ENABLED);
    enabledTooltip.add(new InfoTooltipBehavior());
    editor.add(enabledTooltip);
    Label conditionTooltip = new Label(ID_T_CONDITION);
    conditionTooltip.add(new InfoTooltipBehavior());
    editor.add(conditionTooltip);
    Label confirmationTooltip = new Label(ID_T_CONFIRMATION);
    confirmationTooltip.add(new InfoTooltipBehavior());
    editor.add(confirmationTooltip);
    Label objTemplateTooltip = new Label(ID_T_OBJ_TEMPLATE);
    objTemplateTooltip.add(new InfoTooltipBehavior());
    editor.add(objTemplateTooltip);
    Label reconcileTooltip = new Label(ID_T_RECONCILE);
    reconcileTooltip.add(new InfoTooltipBehavior());
    editor.add(reconcileTooltip);
    Label opportunisticTooltip = new Label(ID_T_OPPORTUNISTIC);
    opportunisticTooltip.add(new InfoTooltipBehavior());
    editor.add(opportunisticTooltip);
    Label correlationTooltip = new Label(ID_T_CORRELATION);
    correlationTooltip.add(new InfoTooltipBehavior());
    editor.add(correlationTooltip);
    Label reactionTooltip = new Label(ID_T_REACTION);
    reactionTooltip.add(new InfoTooltipBehavior());
    editor.add(reactionTooltip);
}
Also used : ObjectReferenceChoiceRenderer(com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer) TriStateComboPanel(com.evolveum.midpoint.web.component.input.TriStateComboPanel) 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) MultiValueAutoCompleteTextPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueAutoCompleteTextPanel) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) 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) NonEmptyWrapperModel(com.evolveum.midpoint.gui.api.model.NonEmptyWrapperModel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 2 with AjaxSubmitLink

use of org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink in project midpoint by Evolveum.

the class SynchronizationStep method initLayout.

private void initLayout() {
    final ListDataProvider<ObjectSynchronizationType> syncProvider = new ListDataProvider<>(this, new PropertyModel<List<ObjectSynchronizationType>>(syncDtoModel, ResourceSynchronizationDto.F_OBJECT_SYNCRONIZATION_LIST));
    //first row - object sync list
    WebMarkupContainer tableBody = new WebMarkupContainer(ID_TABLE_ROWS);
    tableBody.setOutputMarkupId(true);
    add(tableBody);
    //second row - ObjectSynchronizationType editor
    WebMarkupContainer objectSyncEditor = new WebMarkupContainer(ID_OBJECT_SYNC_EDITOR);
    objectSyncEditor.setOutputMarkupId(true);
    objectSyncEditor.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isAnySelected();
        }
    });
    add(objectSyncEditor);
    //third row - container for more specific editors
    WebMarkupContainer thirdRowContainer = new WebMarkupContainer(ID_THIRD_ROW_CONTAINER);
    thirdRowContainer.setOutputMarkupId(true);
    add(thirdRowContainer);
    DataView<ObjectSynchronizationType> syncDataView = new DataView<ObjectSynchronizationType>(ID_OBJECT_SYNC_ROW, syncProvider, UserProfileStorage.DEFAULT_PAGING_SIZE) {

        @Override
        protected void populateItem(Item<ObjectSynchronizationType> item) {
            final ObjectSynchronizationType syncObject = item.getModelObject();
            AjaxSubmitLink link = new AjaxSubmitLink(ID_OBJECT_SYNC_LINK) {

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    editSyncObjectPerformed(target, syncObject);
                }
            };
            item.add(link);
            Label label = new Label(ID_OBJECT_SYNC_LABEL, createObjectSyncTypeDisplayModel(syncObject));
            label.setOutputMarkupId(true);
            link.add(label);
            AjaxLink delete = new AjaxLink(ID_OBJECT_SYNC_DELETE) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteSyncObjectPerformed(target, syncObject);
                }
            };
            parentPage.addEditingVisibleBehavior(delete);
            link.add(delete);
            item.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    if (isSelected(syncObject)) {
                        return "success";
                    }
                    return null;
                }
            }));
        }
    };
    tableBody.add(syncDataView);
    NavigatorPanel navigator = new NavigatorPanel(ID_PAGING, syncDataView, true);
    navigator.setOutputMarkupId(true);
    navigator.setOutputMarkupPlaceholderTag(true);
    add(navigator);
    AjaxLink add = new AjaxLink(ID_OBJECT_SYNC_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addSyncObjectPerformed(target);
        }
    };
    parentPage.addEditingVisibleBehavior(add);
    add(add);
    initObjectSyncEditor(objectSyncEditor);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DataView(org.apache.wicket.markup.repeater.data.DataView) ListItem(org.apache.wicket.markup.html.list.ListItem) Item(org.apache.wicket.markup.repeater.Item) NavigatorPanel(com.evolveum.midpoint.web.component.data.paging.NavigatorPanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 3 with AjaxSubmitLink

use of org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink in project midpoint by Evolveum.

the class SchemaHandlingStep method initLayout.

private void initLayout() {
    final ListDataProvider<ResourceObjectTypeDefinitionTypeDto> objectTypeProvider = new ListDataProvider<>(this, new PropertyModel<List<ResourceObjectTypeDefinitionTypeDto>>(schemaHandlingDtoModel, SchemaHandlingDto.F_OBJECT_TYPE_DTO_LIST));
    // first row - object types table
    WebMarkupContainer objectTypesTable = new WebMarkupContainer(ID_ROWS);
    objectTypesTable.setOutputMarkupId(true);
    add(objectTypesTable);
    // second row - object type editor
    WebMarkupContainer objectTypeEditor = new WebMarkupContainer(ID_OBJECT_TYPE_EDITOR);
    objectTypeEditor.setOutputMarkupId(true);
    objectTypeEditor.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isAnySelected();
        }
    });
    add(objectTypeEditor);
    // third row container
    WebMarkupContainer thirdRowContainer = new WebMarkupContainer(ID_THIRD_ROW_CONTAINER);
    thirdRowContainer.setOutputMarkupId(true);
    add(thirdRowContainer);
    // ---------------------- details -----------------------
    // Object type table (list)
    DataView<ResourceObjectTypeDefinitionTypeDto> objectTypeDataView = new DataView<ResourceObjectTypeDefinitionTypeDto>(ID_ROW_OBJECT_TYPE, objectTypeProvider, UserProfileStorage.DEFAULT_PAGING_SIZE) {

        @Override
        protected void populateItem(final Item<ResourceObjectTypeDefinitionTypeDto> item) {
            final ResourceObjectTypeDefinitionTypeDto objectType = item.getModelObject();
            AjaxSubmitLink link = new AjaxSubmitLink(ID_LINK_OBJECT_TYPE) {

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

                @Override
                protected void onError(AjaxRequestTarget target, Form<?> form) {
                    target.add(parentPage.getFeedbackPanel());
                }
            };
            item.add(link);
            Label label = new Label(ID_NAME_OBJECT_TYPE, createObjectTypeDisplayModel(objectType));
            label.setOutputMarkupId(true);
            link.add(label);
            AjaxLink delete = new AjaxLink(ID_BUTTON_DELETE_OBJECT_TYPE) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteObjectTypePerformed(target, objectType);
                }
            };
            parentPage.addEditingVisibleBehavior(delete);
            link.add(delete);
            item.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    return isSelected(item.getModelObject()) ? "success" : null;
                }
            }));
        }
    };
    objectTypesTable.add(objectTypeDataView);
    NavigatorPanel navigator = new NavigatorPanel(ID_PAGING_OBJECT_TYPE, objectTypeDataView, true);
    navigator.setOutputMarkupPlaceholderTag(true);
    navigator.setOutputMarkupId(true);
    add(navigator);
    AjaxSubmitLink add = new AjaxSubmitLink(ID_BUTTON_ADD_OBJECT_TYPE) {

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

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(parentPage.getFeedbackPanel());
        }
    };
    parentPage.addEditingVisibleBehavior(add);
    add(add);
    initObjectTypeEditor(objectTypeEditor);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DataView(org.apache.wicket.markup.repeater.data.DataView) ListItem(org.apache.wicket.markup.html.list.ListItem) Item(org.apache.wicket.markup.repeater.Item) NavigatorPanel(com.evolveum.midpoint.web.component.data.paging.NavigatorPanel) ResourceObjectTypeDefinitionTypeDto(com.evolveum.midpoint.web.component.wizard.resource.dto.ResourceObjectTypeDefinitionTypeDto) List(java.util.List) ArrayList(java.util.ArrayList) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 4 with AjaxSubmitLink

use of org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink in project midpoint by Evolveum.

the class SynchronizationActionEditorDialog method initButtons.

private void initButtons(Form form) {
    AjaxLink cancel = new AjaxLink(ID_BUTTON_CANCEL) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            cancelPerformed(target);
        }
    };
    form.add(cancel);
    AjaxSubmitLink save = new AjaxSubmitLink(ID_BUTTON_SAVE) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            savePerformed(target);
        }
    };
    form.add(save);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Form(org.apache.wicket.markup.html.form.Form) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 5 with AjaxSubmitLink

use of org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink 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)

Aggregations

AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)16 AjaxSubmitLink (org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink)16 Label (org.apache.wicket.markup.html.basic.Label)13 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)10 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)9 List (java.util.List)8 Form (org.apache.wicket.markup.html.form.Form)8 ListItem (org.apache.wicket.markup.html.list.ListItem)8 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)8 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)7 ArrayList (java.util.ArrayList)6 MultiValueTextEditPanel (com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel)5 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)5 QName (javax.xml.namespace.QName)4 IModel (org.apache.wicket.model.IModel)4 Model (org.apache.wicket.model.Model)4 NonEmptyModel (com.evolveum.midpoint.gui.api.model.NonEmptyModel)3 EmptyOnChangeAjaxFormUpdatingBehavior (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior)3 PageResourceWizard (com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard)3 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)3