Search in sources :

Example 1 with DropDownFormGroup

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

the class ReconciliationPopupPanel method initLayout.

private void initLayout(IModel<List<ResourceItemDto>> resources, final Component component) {
    TextFormGroup name = new TextFormGroup(ID_NAME, new PropertyModel<String>(getModel(), ReconciliationReportDto.F_NAME), createStringResource("ObjectType.name"), ID_LABEL_SIZE, ID_INPUT_SIZE, true);
    add(name);
    TextFormGroup description = new TextFormGroup(ID_DESCRIPTION, new PropertyModel<String>(getModel(), ReconciliationReportDto.F_DESCRIPTION), createStringResource("ObjectType.description"), ID_LABEL_SIZE, ID_INPUT_SIZE, true);
    add(description);
    IModel choices = WebComponentUtil.createReadonlyModelFromEnum(ExportType.class);
    IChoiceRenderer renderer = new EnumChoiceRenderer();
    DropDownFormGroup exportType = new DropDownFormGroup(ID_EXPORT_TYPE, new PropertyModel<ExportType>(getModel(), ReconciliationReportDto.F_EXPORT_TYPE), choices, renderer, createStringResource("ReconciliationPopupPanel.exportFileType"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    add(exportType);
    DropDownFormGroup resourceDropDown = new DropDownFormGroup(ID_RESOURCE, createModel(resources.getObject()), resources, renderer, createStringResource("ReconciliationPopupPanel.resource"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    add(resourceDropDown);
}
Also used : TextFormGroup(com.evolveum.midpoint.web.component.form.TextFormGroup) IModel(org.apache.wicket.model.IModel) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) ExportType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExportType)

Example 2 with DropDownFormGroup

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

the class AuditPopupPanel method initLayout.

@SuppressWarnings("serial")
private void initLayout(final Component component) {
    TextFormGroup name = new TextFormGroup(ID_NAME, new PropertyModel<String>(getModel(), AuditReportDto.F_NAME), createStringResource("ObjectType.name"), ID_LABEL_SIZE, ID_INPUT_SIZE, true);
    add(name);
    TextFormGroup description = new TextFormGroup(ID_DESCRIPTION, new PropertyModel<String>(getModel(), AuditReportDto.F_DESCRIPTION), createStringResource("ObjectType.description"), ID_LABEL_SIZE, ID_INPUT_SIZE, true);
    add(description);
    IModel choices = WebComponentUtil.createReadonlyModelFromEnum(ExportType.class);
    IChoiceRenderer renderer = new EnumChoiceRenderer();
    DropDownFormGroup exportType = new DropDownFormGroup(ID_EXPORT_TYPE, new PropertyModel<ExportType>(getModel(), AuditReportDto.F_EXPORT_TYPE), choices, renderer, createStringResource("AuditPopulPanel.exportType.label"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    add(exportType);
    choices = WebComponentUtil.createReadonlyModelFromEnum(AuditEventType.class);
    DropDownFormGroup auditEventType = new DropDownFormGroup(ID_AUDITEVENTTYPE, new PropertyModel<AuditEventType>(getModel(), AuditReportDto.F_AUDITEVENTTYPE), choices, renderer, createStringResource("AuditPopupPanel.auditEventType"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    add(auditEventType);
    DateFormGroup dateFrom = new DateFormGroup(ID_DATE_FROM, new PropertyModel<XMLGregorianCalendar>(getModel(), AuditReportDto.F_FROM_GREG), createStringResource("AuditPopupPanel.dateFrom"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    add(dateFrom);
    DateFormGroup dateTo = new DateFormGroup(ID_DATE_TO, new PropertyModel<XMLGregorianCalendar>(getModel(), AuditReportDto.F_TO_GREG), createStringResource("AuditPopupPanel.dateTo"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    add(dateTo);
}
Also used : TextFormGroup(com.evolveum.midpoint.web.component.form.TextFormGroup) IModel(org.apache.wicket.model.IModel) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) AuditEventType(com.evolveum.midpoint.audit.api.AuditEventType) ExportType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExportType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DateFormGroup(com.evolveum.midpoint.web.component.form.DateFormGroup)

Example 3 with DropDownFormGroup

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

the class NotificationConfigPanel method initLayout.

@Override
protected void initLayout() {
    TextField<String> defaultFromField = WebComponentUtil.createAjaxTextField(ID_DEFAULT_FROM, new PropertyModel<String>(getModel(), "defaultFrom"));
    CheckBox debugCheck = WebComponentUtil.createAjaxCheckBox(ID_DEBUG, new PropertyModel<Boolean>(getModel(), "debug"));
    DropDownChoice mailServerConfigChooser = new DropDownChoice<>(ID_MAIL_SERVER, new PropertyModel<MailServerConfigurationTypeDto>(getModel(), NotificationConfigurationDto.F_SELECTED_SERVER), new AbstractReadOnlyModel<List<MailServerConfigurationTypeDto>>() {

        @Override
        public List<MailServerConfigurationTypeDto> getObject() {
            return getModel().getObject().getServers();
        }
    }, new ChoiceableChoiceRenderer<MailServerConfigurationTypeDto>());
    mailServerConfigChooser.setNullValid(true);
    mailServerConfigChooser.add(new AjaxFormSubmitBehavior("click") {

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            getForm().onFormSubmitted();
        }
    });
    mailServerConfigChooser.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            preparePasswordFieldPlaceholder();
            target.add(NotificationConfigPanel.this);
        }
    });
    add(mailServerConfigChooser);
    Label serverConfigTooltip = new Label(ID_MAIL_SERVER_TOOLTIP);
    serverConfigTooltip.add(new InfoTooltipBehavior());
    add(serverConfigTooltip);
    WebMarkupContainer serverConfigContainer = new WebMarkupContainer(ID_MAIL_SERVER_CONFIG_CONTAINER);
    serverConfigContainer.setOutputMarkupId(true);
    serverConfigContainer.setOutputMarkupPlaceholderTag(true);
    serverConfigContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (getModelObject() != null) {
                return getModelObject().getSelectedServer() != null;
            }
            return false;
        }
    });
    add(serverConfigContainer);
    TextField<String> hostField = WebComponentUtil.createAjaxTextField(ID_HOST, new PropertyModel<String>(getModel(), "selectedServer.host"));
    TextField<Integer> portField = WebComponentUtil.createAjaxTextField(ID_PORT, new PropertyModel<Integer>(getModel(), "selectedServer.port"));
    TextField<String> userNameField = WebComponentUtil.createAjaxTextField(ID_USERNAME, new PropertyModel<String>(getModel(), "selectedServer.username"));
    PasswordTextField passwordField = new PasswordTextField(ID_PASSWORD, new PropertyModel<String>(getModel(), "selectedServer.password"));
    passwordField.setRequired(false);
    passwordField.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    TextField<String> redirectToFileField = WebComponentUtil.createAjaxTextField(ID_REDIRECT_TO_FILE, new PropertyModel<String>(getModel(), "redirectToFile"));
    DropDownFormGroup transportSecurity = new DropDownFormGroup<>(ID_TRANSPORT_SECURITY, new PropertyModel<MailTransportSecurityType>(getModel(), "selectedServer.mailTransportSecurityType"), WebComponentUtil.createReadonlyModelFromEnum(MailTransportSecurityType.class), new EnumChoiceRenderer<MailTransportSecurityType>(this), createStringResource("SystemConfigPanel.mail.transportSecurity"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    // transportSecurity.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    serverConfigContainer.add(hostField);
    serverConfigContainer.add(portField);
    serverConfigContainer.add(userNameField);
    serverConfigContainer.add(passwordField);
    serverConfigContainer.add(transportSecurity);
    add(defaultFromField);
    add(debugCheck);
    add(redirectToFileField);
    AjaxSubmitLink buttonAddNewMailServerConfig = new AjaxSubmitLink(ID_BUTTON_ADD_NEW_MAIL_SERVER_CONFIG) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            MailServerConfigurationTypeDto newConfig = new MailServerConfigurationTypeDto();
            newConfig.setHost(getString("SystemConfigPanel.mail.config.placeholder"));
            if (getModelObject() != null) {
                getModelObject().getServers().add(newConfig);
                getModelObject().setSelectedServer(newConfig);
            }
            preparePasswordFieldPlaceholder();
            target.add(NotificationConfigPanel.this, getPageBase().getFeedbackPanel());
        }

        @Override
        protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    add(buttonAddNewMailServerConfig);
    AjaxSubmitLink removeMailServerConfig = new AjaxSubmitLink(ID_BUTTON_REMOVE_MAIL_SERVER_CONFIG) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            if (getModelObject() != null) {
                NotificationConfigurationDto notificationConfig = getModelObject();
                MailServerConfigurationTypeDto selected = notificationConfig.getSelectedServer();
                if (notificationConfig.getServers().contains(selected)) {
                    notificationConfig.getServers().remove(selected);
                    notificationConfig.setSelectedServer(null);
                } else {
                    warn(getString("SystemConfigPanel.mail.server.remove.warn"));
                }
                target.add(NotificationConfigPanel.this, getPageBase().getFeedbackPanel());
            }
        }

        @Override
        protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    removeMailServerConfig.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (getModelObject() != null && getModelObject().getSelectedServer() != null) {
                return null;
            } else {
                return " disabled";
            }
        }
    }));
    add(removeMailServerConfig);
}
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) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxFormSubmitBehavior(org.apache.wicket.ajax.form.AjaxFormSubmitBehavior) MailServerConfigurationTypeDto(com.evolveum.midpoint.web.page.admin.configuration.dto.MailServerConfigurationTypeDto) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) NotificationConfigurationDto(com.evolveum.midpoint.web.page.admin.configuration.dto.NotificationConfigurationDto) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) PasswordTextField(org.apache.wicket.markup.html.form.PasswordTextField) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) MailTransportSecurityType(com.evolveum.midpoint.xml.ns._public.common.common_3.MailTransportSecurityType) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) CheckBox(org.apache.wicket.markup.html.form.CheckBox)

Example 4 with DropDownFormGroup

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

the class RelationDropDownChoicePanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    ListModel supportedRelationsModel = new ListModel<>(supportedRelations);
    if (!allowNull && defaultRelation == null) {
        if (CollectionUtils.isNotEmpty(supportedRelations)) {
            List<QName> sortedRelations = WebComponentUtil.sortDropDownChoices(supportedRelationsModel, getRenderer());
            defaultRelation = sortedRelations.get(0);
        } else {
            defaultRelation = PrismConstants.Q_ANY;
        }
        defaultRelation = supportedRelations.size() > 0 ? supportedRelations.get(0) : PrismConstants.Q_ANY;
    }
    DropDownFormGroup<QName> input = new DropDownFormGroup<QName>(ID_INPUT, Model.of(defaultRelation), supportedRelationsModel, getRenderer(), getRelationLabelModel(), "relationDropDownChoicePanel.tooltip.relation", "col-md-4", getRelationLabelModel() == null || StringUtils.isEmpty(getRelationLabelModel().getObject()) ? "" : "col-md-8", !allowNull) {

        private static final long serialVersionUID = 1L;

        @Override
        protected String getNullValidDisplayValue() {
            return RelationDropDownChoicePanel.this.getNullValidDisplayValue();
        }
    };
    input.getInput().add(new EnableBehaviour(() -> isRelationDropDownEnabled()));
    input.getInput().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    input.getInput().add(new OnChangeAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            RelationDropDownChoicePanel.this.onValueChanged(target);
        }
    });
    add(input);
    setOutputMarkupId(true);
    setOutputMarkupPlaceholderTag(true);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) QName(javax.xml.namespace.QName) ListModel(org.apache.wicket.model.util.ListModel) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour)

Example 5 with DropDownFormGroup

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

the class NameStep method discoverConnectorsPerformed.

@SuppressWarnings("unchecked")
private void discoverConnectorsPerformed(AjaxRequestTarget target) {
    DropDownChoice<PrismObject<ConnectorHostType>> connectorHostChoice = ((DropDownFormGroup<PrismObject<ConnectorHostType>>) get(ID_CONNECTOR_HOST)).getInput();
    PrismObject<ConnectorHostType> connectorHostObject = connectorHostChoice.getModelObject();
    ConnectorHostType host = connectorHostObject != null ? connectorHostObject.asObjectable() : null;
    if (host != null) {
        discoverConnectors(host);
        allConnectorsModel.reset();
    }
    relevantConnectorsModel.reset();
    DropDownFormGroup<PrismObject<ConnectorType>> connectorDropDown = getConnectorDropDown();
    PrismObject<ConnectorType> selectedConnector = connectorDropDown.getInput().getModelObject();
    if (selectedConnector != null) {
        if (!isConnectorOnHost(selectedConnector, connectorHostObject)) {
            PrismObject<ConnectorType> compatibleConnector = null;
            for (PrismObject<ConnectorType> relevantConnector : relevantConnectorsModel.getObject()) {
                if (isConfigurationSchemaCompatible(relevantConnector)) {
                    compatibleConnector = relevantConnector;
                    break;
                }
            }
            selectedConnectorModel.setObject(compatibleConnector);
        }
    }
    target.add(connectorDropDown.getInput(), connectorDropDown.getAdditionalInfoComponent(), ((PageBase) getPage()).getFeedbackPanel());
}
Also used : ConnectorHostType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType) PrismObject(com.evolveum.midpoint.prism.PrismObject) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup)

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