Search in sources :

Example 11 with DropDownFormGroup

use of com.evolveum.midpoint.web.component.form.DropDownFormGroup in project midpoint by Evolveum.

the class SynchronizationActionEditorDialog method initLayout.

private void initLayout(WebMarkupContainer content) {
    Form form = new MidpointForm(ID_MAIN_FORM);
    form.setOutputMarkupId(true);
    content.add(form);
    TextFormGroup name = new TextFormGroup(ID_NAME, new PropertyModel<>(model, SynchronizationActionTypeDto.F_ACTION_OBJECT + ".name"), createStringResource("SynchronizationActionEditorDialog.label.name"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(name);
    TextAreaFormGroup description = new TextAreaFormGroup(ID_DESCRIPTION, new PropertyModel<>(model, SynchronizationActionTypeDto.F_ACTION_OBJECT + ".description"), createStringResource("SynchronizationActionEditorDialog.label.description"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(description);
    DropDownFormGroup<SynchronizationActionTypeDto.HandlerUriActions> handlerUri = new DropDownFormGroup<SynchronizationActionTypeDto.HandlerUriActions>(ID_HANDLER_URI, new PropertyModel<>(model, SynchronizationActionTypeDto.F_HANDLER_URI), WebComponentUtil.createReadonlyModelFromEnum(SynchronizationActionTypeDto.HandlerUriActions.class), new EnumChoiceRenderer<>(this), createStringResource("SynchronizationActionEditorDialog.label.handlerUri"), createStringResource("SynchronizationStep.action.tooltip.handlerUri", WebComponentUtil.getMidpointCustomSystemName((PageResourceWizard) getPage(), "midpoint.default.system.name")), ID_LABEL_SIZE, ID_INPUT_SIZE, false, false) {

        @Override
        protected DropDownChoice createDropDown(String id, IModel<List<SynchronizationActionTypeDto.HandlerUriActions>> choices, IChoiceRenderer<SynchronizationActionTypeDto.HandlerUriActions> renderer, boolean required) {
            DropDownChoice choice = new DropDownChoice<>(id, getModel(), choices, renderer);
            choice.setNullValid(true);
            return choice;
        }
    };
    form.add(handlerUri);
    DropDownFormGroup<BeforeAfterType> order = new DropDownFormGroup<BeforeAfterType>(ID_ORDER, new PropertyModel<>(model, SynchronizationActionTypeDto.F_ACTION_OBJECT + ".order"), WebComponentUtil.createReadonlyModelFromEnum(BeforeAfterType.class), new EnumChoiceRenderer<>(this), createStringResource("SynchronizationActionEditorDialog.label.order"), createStringResource("SynchronizationStep.action.tooltip.order", WebComponentUtil.getMidpointCustomSystemName((PageResourceWizard) getPage(), "midpoint.default.system.name")), ID_LABEL_SIZE, ID_INPUT_SIZE, false, false) {

        @Override
        protected DropDownChoice createDropDown(String id, IModel<List<BeforeAfterType>> choices, IChoiceRenderer<BeforeAfterType> renderer, boolean required) {
            DropDownChoice choice = new DropDownChoice<>(id, getModel(), choices, renderer);
            choice.setNullValid(true);
            return choice;
        }
    };
    form.add(order);
    initButtons(form);
}
Also used : IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) SynchronizationActionTypeDto(com.evolveum.midpoint.web.component.wizard.resource.dto.SynchronizationActionTypeDto) TextFormGroup(com.evolveum.midpoint.web.component.form.TextFormGroup) IModel(org.apache.wicket.model.IModel) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) BeforeAfterType(com.evolveum.midpoint.xml.ns._public.common.common_3.BeforeAfterType) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) TextAreaFormGroup(com.evolveum.midpoint.web.component.form.TextAreaFormGroup) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice)

Example 12 with DropDownFormGroup

use of com.evolveum.midpoint.web.component.form.DropDownFormGroup in project midpoint by Evolveum.

the class NameStep method createConnectorDropDown.

private DropDownFormGroup<PrismObject<ConnectorType>> createConnectorDropDown() {
    return new DropDownFormGroup<PrismObject<ConnectorType>>(ID_CONNECTOR, selectedConnectorModel, relevantConnectorsModel, new IChoiceRenderer<PrismObject<ConnectorType>>() {

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

        @Override
        public Object getDisplayValue(PrismObject<ConnectorType> object) {
            return WebComponentUtil.getName(object);
        }

        @Override
        public String getIdValue(PrismObject<ConnectorType> object, int index) {
            if (index < 0) {
                // noinspection unchecked
                List<PrismObject<ConnectorType>> connectors = (List<PrismObject<ConnectorType>>) getConnectorDropDown().getInput().getChoices();
                for (PrismObject<ConnectorType> connector : connectors) {
                    if (connector.getOid().equals(selectedConnectorModel.getObject().getOid())) {
                        return Integer.toString(connectors.indexOf(connector));
                    }
                }
            }
            return Integer.toString(index);
        }
    }, createStringResource("NameStep.connectorType"), "col-md-3", "col-md-6", true) {

        @Override
        protected DropDownChoice<PrismObject<ConnectorType>> createDropDown(String id, IModel<List<PrismObject<ConnectorType>>> choices, IChoiceRenderer<PrismObject<ConnectorType>> renderer, boolean required) {
            DropDownChoice<PrismObject<ConnectorType>> choice = super.createDropDown(id, choices, renderer, required);
            choice.add(new AjaxFormComponentUpdatingBehavior("change") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    target.add(getConnectorDropDown().getAdditionalInfoComponent());
                }
            });
            choice.setOutputMarkupId(true);
            return choice;
        }

        @Override
        protected Component createAdditionalInfoComponent(String id) {
            Label l = new Label(id, schemaChangeWarningModel);
            l.add(new AttributeAppender("class", "text-danger"));
            l.setOutputMarkupId(true);
            return l;
        }
    };
}
Also used : IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) IModel(org.apache.wicket.model.IModel) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) Label(org.apache.wicket.markup.html.basic.Label) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismObject(com.evolveum.midpoint.prism.PrismObject) List(java.util.List) ArrayList(java.util.ArrayList) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 13 with DropDownFormGroup

use of com.evolveum.midpoint.web.component.form.DropDownFormGroup in project midpoint by Evolveum.

the class NameStep method createHostDropDown.

@NotNull
private DropDownFormGroup<PrismObject<ConnectorHostType>> createHostDropDown() {
    return new DropDownFormGroup<PrismObject<ConnectorHostType>>(ID_CONNECTOR_HOST, selectedHostModel, allHostsModel, new IChoiceRenderer<PrismObject<ConnectorHostType>>() {

        @Override
        public PrismObject<ConnectorHostType> getObject(String id, IModel<? extends List<? extends PrismObject<ConnectorHostType>>> choices) {
            if (StringUtils.isBlank(id)) {
                return null;
            }
            return choices.getObject().get(Integer.parseInt(id));
        }

        @Override
        public Object getDisplayValue(PrismObject<ConnectorHostType> object) {
            if (object == null) {
                return NameStep.this.getString("NameStep.hostNotUsed");
            }
            return ConnectorHostTypeComparator.getUserFriendlyName(object);
        }

        @Override
        public String getIdValue(PrismObject<ConnectorHostType> object, int index) {
            return Integer.toString(index);
        }
    }, createStringResource("NameStep.connectorHost"), "col-md-3", "col-md-6", false) {

        @Override
        protected DropDownChoice<PrismObject<ConnectorHostType>> createDropDown(String id, IModel<List<PrismObject<ConnectorHostType>>> choices, IChoiceRenderer<PrismObject<ConnectorHostType>> renderer, boolean required) {
            DropDownChoice<PrismObject<ConnectorHostType>> choice = super.createDropDown(id, choices, renderer, required);
            choice.add(new AjaxFormComponentUpdatingBehavior("change") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    discoverConnectorsPerformed(target);
                }
            });
            return choice;
        }
    };
}
Also used : ConnectorHostType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType) IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) IModel(org.apache.wicket.model.IModel) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismObject(com.evolveum.midpoint.prism.PrismObject) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

DropDownFormGroup (com.evolveum.midpoint.web.component.form.DropDownFormGroup)13 IModel (org.apache.wicket.model.IModel)8 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)7 TextFormGroup (com.evolveum.midpoint.web.component.form.TextFormGroup)6 IChoiceRenderer (org.apache.wicket.markup.html.form.IChoiceRenderer)5 ExportType (com.evolveum.midpoint.xml.ns._public.common.common_3.ExportType)4 List (java.util.List)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 TextAreaFormGroup (com.evolveum.midpoint.web.component.form.TextAreaFormGroup)3 ArrayList (java.util.ArrayList)3 QName (javax.xml.namespace.QName)3 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)3 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)3 Label (org.apache.wicket.markup.html.basic.Label)3 Form (org.apache.wicket.markup.html.form.Form)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)2 DateFormGroup (com.evolveum.midpoint.web.component.form.DateFormGroup)2 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)2 EmptyOnChangeAjaxFormUpdatingBehavior (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior)2