Search in sources :

Example 6 with PageResourceWizard

use of com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard 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);
    WebMarkupContainer schemaRefPanel = new WebMarkupContainer(ID_SCHEMA_REF_PANEL);
    schemaRefPanel.setOutputMarkupId(true);
    schemaRefPanel.setOutputMarkupPlaceholderTag(true);
    schemaRefPanel.add(new VisibleEnableBehaviour() {

        @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);
    IChoiceRenderer<ItemPathType> choiceRenderer = 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);
        }
    };
    DropDownChoice<?> refSelect = new DropDownChoice<ItemPathType>(ID_REFERENCE_SELECT, new PropertyModel<>(getModel(), "ref"), (IModel<List<ItemPathType>>) () -> loadObjectReferences(), choiceRenderer) {

        @Override
        protected boolean isSelected(ItemPathType object, int index, String selected) {
            if (getModelObject() == null || getModelObject().equals(new ItemPathType())) {
                return false;
            }
            QName referenceQName = ItemPathTypeUtil.asSingleName(getModelObject());
            QName optionQName = ItemPathTypeUtil.asSingleName(object);
            return Objects.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);
    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<Void> limitations = new AjaxLink<Void>(ID_BUTTON_LIMITATIONS) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            limitationsEditPerformed(target);
        }
    };
    add(limitations);
    CheckBox exclusiveStrong = new CheckBox(ID_EXCLUSIVE_STRONG, new PropertyModel<>(getModel(), "exclusiveStrong"));
    exclusiveStrong.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    add(exclusiveStrong);
    CheckBox tolerant = new CheckBox(ID_TOLERANT, new PropertyModel<>(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<>(getModel(), "fetchStrategy"), WebComponentUtil.createReadonlyModelFromEnum(AttributeFetchStrategyType.class), new EnumChoiceRenderer<>(this));
    fetchStrategy.setNullValid(true);
    fetchStrategy.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    add(fetchStrategy);
    AttributeEditorUtils.addMatchingRuleFields(this, readOnlyModel);
    TextField<String> outboundLabel = new TextField<>(ID_OUTBOUND_LABEL, (IModel<String>) () -> {
        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) {
            outboundEditPerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            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) {
            deleteOutboundPerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            target.add(parentStep.getPageBase().getFeedbackPanel());
        }
    };
    deleteOutbound.setOutputMarkupId(true);
    deleteOutbound.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
    add(deleteOutbound);
    MultiValueTextEditPanel<?> inbound = new MultiValueTextEditPanel<MappingType>(ID_INBOUND, new PropertyModel<>(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) ResourceModel(org.apache.wicket.model.ResourceModel) ArrayList(java.util.ArrayList) List(java.util.List) 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) IModel(org.apache.wicket.model.IModel) 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) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) ResourceModel(org.apache.wicket.model.ResourceModel) PageResourceWizard(com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 7 with PageResourceWizard

use of com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard in project midpoint by Evolveum.

the class Wizard method initLayout.

protected void initLayout() {
    Form form = new MidpointForm(ID_FORM);
    add(form);
    IModel<List<WizardStepDto>> stepsModel = new LoadableModel<List<WizardStepDto>>() {

        @Override
        protected List<WizardStepDto> load() {
            return loadSteps();
        }
    };
    WizardSteps steps = new WizardSteps(ID_STEPS, stepsModel) {

        @Override
        public IWizardStep getActiveStep() {
            if (Wizard.this.getModel() != null && Wizard.this.getModel().getObject() != null) {
                return Wizard.this.getModel().getObject().getActiveStep();
            }
            return null;
        }

        @Override
        public void changeStepPerformed(AjaxRequestTarget target, WizardStepDto dto) {
            changeStep(target, dto);
        }
    };
    steps.setOutputMarkupId(true);
    steps.setVisible(hasMoreThanOneStep());
    form.add(steps);
    WebMarkupContainer header = new WebMarkupContainer(ID_HEADER);
    form.add(header);
    WebMarkupContainer view = new WebMarkupContainer(ID_VIEW);
    form.add(view);
    WizardIssuesPanel issuesPanel = new WizardIssuesPanel(ID_ISSUES, issuesModel);
    issuesPanel.setOutputMarkupId(true);
    form.add(issuesPanel);
    WizardButtonBar buttons = new WizardButtonBar(ID_BUTTONS, this);
    buttons.setOutputMarkupId(true);
    form.add(buttons);
    WebMarkupContainer autoSaveNote = new WebMarkupContainer(ID_AUTO_SAVE_NOTE);
    autoSaveNote.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            PageResourceWizard wizardPage = (PageResourceWizard) getPageBase();
            return !wizardPage.isConfigurationOnly() && !wizardPage.isReadOnly();
        }
    });
    form.add(autoSaveNote);
    WebMarkupContainer readOnlyNote = new WebMarkupContainer(ID_READ_ONLY_NOTE);
    readOnlyNote.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            PageResourceWizard wizardPage = (PageResourceWizard) getPageBase();
            return wizardPage.isReadOnly();
        }
    });
    form.add(readOnlyNote);
    readOnlyNote.add(new AjaxFallbackLink<String>(ID_READ_ONLY_SWITCH) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(Optional<AjaxRequestTarget> optionalTarget) {
            PageResourceWizard wizardPage = (PageResourceWizard) getPageBase();
            // e.g. to switch configuration models to read-write
            wizardPage.resetModels();
            wizardPage.setReadOnly(false);
            optionalTarget.get().add(wizardPage);
        }
    });
    IWizardModel wizard = getWizardModel();
    wizard.addListener(this);
    wizard.reset();
}
Also used : Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) PageResourceWizard(com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 8 with PageResourceWizard

use of com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard in project midpoint by Evolveum.

the class WizardSteps method initLayout.

protected void initLayout() {
    ListView<WizardStepDto> linkContainer = new ListView<WizardStepDto>(ID_LINK_REPEATER, getModel()) {

        @Override
        protected void populateItem(ListItem<WizardStepDto> item) {
            final WizardStepDto dto = item.getModelObject();
            item.setRenderBodyOnly(true);
            AjaxSubmitLink button = new AjaxSubmitLink(ID_LINK) {

                @Override
                protected void onSubmit(AjaxRequestTarget target) {
                    changeStepPerformed(target, dto);
                }

                @Override
                protected void onError(AjaxRequestTarget target) {
                    target.add(getPageBase().getFeedbackPanel());
                }
            };
            item.add(button);
            button.add(new VisibleEnableBehaviour() {

                @Override
                public boolean isEnabled() {
                    final boolean enabled = ((PageResourceWizard) getPageBase()).isCurrentStepComplete();
                    return enabled;
                }

                @Override
                public boolean isVisible() {
                    return dto.isVisible();
                }
            });
            button.add(AttributeModifier.replace("class", (IModel<String>) () -> dto.getWizardStep() == getActiveStep() ? "current" : null));
            button.add(AttributeModifier.replace("style", (IModel<String>) () -> ((PageResourceWizard) getPageBase()).isCurrentStepComplete() ? null : "color: #FFF;"));
            Label label = new Label(ID_LABEL, createLabelModel(dto.getName()));
            button.add(label);
        }
    };
    add(linkContainer);
    AjaxLink<Void> help = new AjaxLink<Void>(ID_BUTTON_HELP) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showHelpPerformed(target);
            updateModal();
        }
    };
    add(help);
    initModals();
}
Also used : IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) PageResourceWizard(com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard) ListItem(org.apache.wicket.markup.html.list.ListItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Aggregations

PageResourceWizard (com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard)8 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)6 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)6 List (java.util.List)5 Label (org.apache.wicket.markup.html.basic.Label)5 ArrayList (java.util.ArrayList)4 AjaxSubmitLink (org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink)4 ListItem (org.apache.wicket.markup.html.list.ListItem)4 MultiValueTextEditPanel (com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel)3 EmptyOnChangeAjaxFormUpdatingBehavior (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior)3 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)3 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)3 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)3 NonEmptyModel (com.evolveum.midpoint.gui.api.model.NonEmptyModel)2 MultiValueTextPanel (com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextPanel)2 IModel (org.apache.wicket.model.IModel)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 AceEditor (com.evolveum.midpoint.web.component.AceEditor)1 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)1 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)1