Search in sources :

Example 1 with ChipsWithDropdown

use of pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown in project unity by unity-idm.

the class EditOAuthClientSubView method buildHeaderSection.

private FormLayoutWithFixedCaptionWidth buildHeaderSection() {
    FormLayoutWithFixedCaptionWidth header = new FormLayoutWithFixedCaptionWidth();
    header.setMargin(true);
    TextField name = new TextField();
    name.setCaption(msg.getMessage("EditOAuthClientSubView.name"));
    binder.forField(name).withValidator((v, c) -> {
        if (v != null && !v.isEmpty() && v.length() < 2) {
            return ValidationResult.error(msg.getMessage("toShortValue"));
        }
        return ValidationResult.ok();
    }).bind("name");
    header.addComponent(name);
    ComboBox<String> type = new ComboBox<>();
    type.setCaption(msg.getMessage("EditOAuthClientSubView.type"));
    type.setItems(Stream.of(ClientType.values()).map(f -> f.toString()).collect(Collectors.toList()));
    type.setEmptySelectionAllowed(false);
    binder.forField(type).bind("type");
    header.addComponent(type);
    TextFieldWithGenerator id = new TextFieldWithGenerator();
    id.setCaption(msg.getMessage("EditOAuthClientSubView.id"));
    id.setReadOnly(editMode);
    id.setWidth(30, Unit.EM);
    binder.forField(id).asRequired(msg.getMessage("fieldRequired")).withValidator((v, c) -> {
        if (v != null && allClientsIds.contains(v)) {
            return ValidationResult.error(msg.getMessage("EditOAuthClientSubView.invalidClientId"));
        }
        return ValidationResult.ok();
    }).bind("id");
    header.addComponent(id);
    CustomField<String> secret;
    if (!editMode) {
        secret = new TextFieldWithGenerator();
        secret.setCaption(msg.getMessage("EditOAuthClientSubView.secret"));
        secret.setWidth(30, Unit.EM);
        binder.forField(secret).withValidator((v, c) -> {
            if ((v == null || v.isEmpty()) && ClientType.CONFIDENTIAL.toString().equals(type.getValue())) {
                return ValidationResult.error(msg.getMessage("fieldRequired"));
            }
            return ValidationResult.ok();
        }).bind("secret");
        header.addComponent(secret);
    } else {
        TextFieldWithChangeConfirmation<TextFieldWithGenerator> secretWithChangeConfirmation = new TextFieldWithChangeConfirmation<>(msg, new TextFieldWithGenerator());
        secretWithChangeConfirmation.setCaption(msg.getMessage("EditOAuthClientSubView.secret"));
        secretWithChangeConfirmation.setWidth(30, Unit.EM);
        binder.forField(secretWithChangeConfirmation).withValidator((v, c) -> {
            if (secretWithChangeConfirmation.isEditMode()) {
                return ValidationResult.error(msg.getMessage("fieldRequired"));
            }
            return ValidationResult.ok();
        }).bind("secret");
        header.addComponent(secretWithChangeConfirmation);
        secret = secretWithChangeConfirmation;
    }
    type.addValueChangeListener(e -> {
        secret.setEnabled(ClientType.CONFIDENTIAL.toString().equals(e.getValue()));
        if (!secret.isEnabled())
            secret.setValue("");
    });
    ChipsWithDropdown<String> allowedFlows = new ChipsWithDropdown<>();
    allowedFlows.setCaption(msg.getMessage("EditOAuthClientSubView.allowedFlows"));
    allowedFlows.setItems(Stream.of(GrantFlow.values()).map(f -> f.toString()).collect(Collectors.toList()));
    binder.forField(allowedFlows).withValidator((v, c) -> {
        if (v == null || v.isEmpty()) {
            return ValidationResult.error(msg.getMessage("fieldRequired"));
        }
        return ValidationResult.ok();
    }).bind("flows");
    header.addComponent(allowedFlows);
    ChipsWithTextfield redirectURIs = new ChipsWithTextfield(msg);
    redirectURIs.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    redirectURIs.setCaption(msg.getMessage("EditOAuthClientSubView.authorizedRedirectURIs"));
    binder.forField(redirectURIs).withValidator((v, c) -> {
        if (v == null || v.size() == 0) {
            return ValidationResult.error(msg.getMessage("fieldRequired"));
        }
        return ValidationResult.ok();
    }).bind("redirectURIs");
    header.addComponent(redirectURIs);
    Set<String> definedScopes = scopesSupplier.get();
    ChipsWithDropdown<String> allowedScopes = new ChipsWithDropdown<>();
    allowedScopes.setCaption(msg.getMessage("EditOAuthClientSubView.allowedScopes"));
    allowedScopes.setItems(definedScopes);
    allowedScopes.setSkipRemoveInvalidSelections(true);
    binder.forField(allowedScopes).withValidator((v, c) -> {
        if (v != null && !v.isEmpty() && !definedScopes.containsAll(v)) {
            return ValidationResult.error(msg.getMessage("EditOAuthClientSubView.invalidAllowedScopes"));
        }
        return ValidationResult.ok();
    }).bind("scopes");
    CheckBox allowAllScopes = new CheckBox(msg.getMessage("EditOAuthClientSubView.allowAllScopes"));
    binder.forField(allowAllScopes).bind("allowAnyScopes");
    allowAllScopes.addValueChangeListener(v -> allowedScopes.setEnabled(!v.getValue()));
    header.addComponent(allowAllScopes);
    header.addComponent(allowedScopes);
    return header;
}
Also used : CustomField(com.vaadin.ui.CustomField) FieldSizeConstans(pl.edu.icm.unity.webui.common.FieldSizeConstans) Arrays(java.util.Arrays) CustomComponent(com.vaadin.ui.CustomComponent) TextField(com.vaadin.ui.TextField) VerticalLayout(com.vaadin.ui.VerticalLayout) Alignment(com.vaadin.ui.Alignment) ComboBox(com.vaadin.ui.ComboBox) ValidationResult(com.vaadin.data.ValidationResult) ImageField(pl.edu.icm.unity.webui.common.file.ImageField) Supplier(java.util.function.Supplier) UnityServerConfiguration(pl.edu.icm.unity.engine.api.config.UnityServerConfiguration) UnitySubView(pl.edu.icm.unity.webui.common.webElements.UnitySubView) CheckBox(com.vaadin.ui.CheckBox) MessageSource(pl.edu.icm.unity.MessageSource) NotificationPopup(pl.edu.icm.unity.webui.common.NotificationPopup) ChipsWithTextfield(pl.edu.icm.unity.webui.common.chips.ChipsWithTextfield) CollapsibleLayout(pl.edu.icm.unity.webui.common.CollapsibleLayout) Set(java.util.Set) UUID(java.util.UUID) ConfirmDialog(pl.edu.icm.unity.webui.common.ConfirmDialog) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) StandardButtonsHelper(pl.edu.icm.unity.webui.common.StandardButtonsHelper) Collectors(java.util.stream.Collectors) Binder(com.vaadin.data.Binder) Images(pl.edu.icm.unity.webui.common.Images) TextFieldWithChangeConfirmation(pl.edu.icm.unity.webui.common.TextFieldWithChangeConfirmation) Consumer(java.util.function.Consumer) ClientType(com.nimbusds.oauth2.sdk.client.ClientType) List(java.util.List) Button(com.vaadin.ui.Button) Stream(java.util.stream.Stream) HorizontalLayout(com.vaadin.ui.HorizontalLayout) URIAccessService(pl.edu.icm.unity.engine.api.files.URIAccessService) CopyToClipboardButton(io.imunity.webelements.clipboard.CopyToClipboardButton) Styles(pl.edu.icm.unity.webui.common.Styles) FormValidationException(pl.edu.icm.unity.webui.common.FormValidationException) GrantFlow(pl.edu.icm.unity.oauth.as.OAuthSystemAttributesProvider.GrantFlow) ChipsWithDropdown(pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown) Component(com.vaadin.ui.Component) ComboBox(com.vaadin.ui.ComboBox) ChipsWithDropdown(pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) CheckBox(com.vaadin.ui.CheckBox) ChipsWithTextfield(pl.edu.icm.unity.webui.common.chips.ChipsWithTextfield) TextFieldWithChangeConfirmation(pl.edu.icm.unity.webui.common.TextFieldWithChangeConfirmation) TextField(com.vaadin.ui.TextField)

Example 2 with ChipsWithDropdown

use of pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown in project unity by unity-idm.

the class PolicyAgreementConfigurationEditor method init.

private void init() {
    binder = new Binder<>(PolicyAgreementConfigurationVaadinBean.class);
    buttons = new ArrayList<>();
    main = new FormLayout();
    Label emptyPolicyToAccept = new Label();
    emptyPolicyToAccept.setCaption(msg.getMessage("PolicyAgreementConfigEditor.documentsToAccept"));
    emptyPolicyToAccept.setVisible(policyDocuments.isEmpty());
    emptyPolicyToAccept.setValue(msg.getMessage("PolicyAgreementConfigEditor.noPolicyDocuments"));
    policyToAccept = new ChipsWithDropdown<>(p -> p.name, true);
    policyToAccept.setCaption(msg.getMessage("PolicyAgreementConfigEditor.documentsToAccept"));
    policyToAccept.setItems(policyDocuments.stream().collect(Collectors.toList()));
    policyToAccept.setVisible(!policyDocuments.isEmpty());
    EnumComboBox<PolicyAgreementPresentationType> presentationType = new EnumComboBox<PolicyAgreementPresentationType>(msg, "PolicyAgreementPresentationType.", PolicyAgreementPresentationType.class, PolicyAgreementPresentationType.INFORMATIVE_ONLY);
    presentationType.setCaption(msg.getMessage("PolicyAgreementConfigEditor.presentationType"));
    presentationType.setWidth(FieldSizeConstans.MEDIUM_FIELD_WIDTH, FieldSizeConstans.MEDIUM_FIELD_WIDTH_UNIT);
    I18nTextField text = new I18nTextField(msg);
    text.setWidth(100, Unit.PERCENTAGE);
    text.addBlurListener(e -> buttons.forEach(b -> b.setEnabled(false)));
    text.addFocusListener(e -> buttons.forEach(b -> b.setEnabled(true)));
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    HorizontalLayout buttonsWrapper = new HorizontalLayout();
    buttonsWrapper.setMargin(false);
    Label vars = new Label(msg.getMessage("PolicyAgreementConfigEditor.variables"));
    buttonsWrapper.addComponent(vars);
    buttonsWrapper.addComponent(buttonsLayout);
    buttonsWrapper.setComponentAlignment(vars, Alignment.BOTTOM_LEFT);
    buttonsWrapper.setComponentAlignment(buttonsLayout, Alignment.BOTTOM_LEFT);
    buttonsWrapper.setVisible(false);
    policyToAccept.addValueChangeListener(e -> {
        buttonsLayout.removeAllComponents();
        e.getValue().forEach(d -> {
            Button b = new Button();
            b.setCaption(d.name);
            b.addStyleName(Styles.varPickerButton.toString());
            b.addClickListener(eb -> {
                b.setEnabled(false);
                text.insertOnLastFocused(prepareToInsert(d.name, d.displayedName));
            });
            b.addFocusListener(eb -> {
                b.setEnabled(true);
            });
            b.setEnabled(false);
            buttonsLayout.addComponent(b);
            buttonsLayout.setComponentAlignment(b, Alignment.BOTTOM_LEFT);
            buttons.add(b);
        });
        buttonsWrapper.setVisible(buttonsLayout.getComponentCount() != 0);
    });
    main.addComponent(emptyPolicyToAccept);
    main.addComponent(policyToAccept);
    main.addComponent(presentationType);
    VerticalLayout buttonsAndTextWrapper = new VerticalLayout();
    buttonsAndTextWrapper.setSpacing(true);
    buttonsAndTextWrapper.setMargin(false);
    buttonsAndTextWrapper.addStyleName(Styles.smallSpacing.toString());
    buttonsAndTextWrapper.addComponent(buttonsWrapper);
    buttonsAndTextWrapper.addComponent(text);
    buttonsAndTextWrapper.setCaption(msg.getMessage("PolicyAgreementConfigEditor.text"));
    main.addComponent(buttonsAndTextWrapper);
    binder = new Binder<>(PolicyAgreementConfigurationVaadinBean.class);
    binder.forField(policyToAccept).withValidator((v, c) -> validatePolicyToAccept(v)).bind("documentsToAccept");
    binder.forField(presentationType).bind("presentationType");
    binder.forField(text).withValidator((v, c) -> validateText(v)).bind("text");
    binder.setBean(new PolicyAgreementConfigurationVaadinBean());
    binder.addValueChangeListener(e -> fireEvent(new ValueChangeEvent<>(this, getValue(), true)));
}
Also used : FormLayout(com.vaadin.ui.FormLayout) FieldSizeConstans(pl.edu.icm.unity.webui.common.FieldSizeConstans) VerticalLayout(com.vaadin.ui.VerticalLayout) Alignment(com.vaadin.ui.Alignment) ValidationResult(com.vaadin.data.ValidationResult) ArrayList(java.util.ArrayList) PolicyAgreementConfigTextParser(pl.edu.icm.unity.engine.api.policyAgreement.PolicyAgreementConfigTextParser) Label(com.vaadin.ui.Label) MessageSource(pl.edu.icm.unity.MessageSource) ListOfDnDCollapsableElements(pl.edu.icm.unity.webui.common.ListOfDnDCollapsableElements) Collection(java.util.Collection) Set(java.util.Set) I18nString(pl.edu.icm.unity.types.I18nString) EnumComboBox(pl.edu.icm.unity.webui.common.EnumComboBox) Collectors(java.util.stream.Collectors) Binder(com.vaadin.data.Binder) List(java.util.List) Button(com.vaadin.ui.Button) Editor(pl.edu.icm.unity.webui.common.ListOfDnDCollapsableElements.Editor) PolicyAgreementConfiguration(pl.edu.icm.unity.types.policyAgreement.PolicyAgreementConfiguration) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) HorizontalLayout(com.vaadin.ui.HorizontalLayout) FormLayout(com.vaadin.ui.FormLayout) Styles(pl.edu.icm.unity.webui.common.Styles) FormValidationException(pl.edu.icm.unity.webui.common.FormValidationException) PolicyAgreementPresentationType(pl.edu.icm.unity.types.policyAgreement.PolicyAgreementPresentationType) PolicyDocumentWithRevision(pl.edu.icm.unity.engine.api.policyDocument.PolicyDocumentWithRevision) ChipsWithDropdown(pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown) Component(com.vaadin.ui.Component) PolicyAgreementPresentationType(pl.edu.icm.unity.types.policyAgreement.PolicyAgreementPresentationType) Label(com.vaadin.ui.Label) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) EnumComboBox(pl.edu.icm.unity.webui.common.EnumComboBox) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout)

Example 3 with ChipsWithDropdown

use of pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown in project unity by unity-idm.

the class EditIndividualTrustedSPSubView method buildHeaderSection.

private FormLayout buildHeaderSection() {
    FormLayoutWithFixedCaptionWidth header = new FormLayoutWithFixedCaptionWidth();
    header.setMargin(true);
    TextField name = new TextField(msg.getMessage("EditIndividualTrustedSPSubView.name"));
    name.focus();
    configBinder.forField(name).asRequired(msg.getMessage("fieldRequired")).withValidator(new NoSpaceValidator(msg)).withValidator((s, c) -> {
        if (usedNames.contains(s)) {
            return ValidationResult.error(msg.getMessage("EditIndividualTrustedSPSubView.nameExists"));
        } else {
            return ValidationResult.ok();
        }
    }).bind("name");
    header.addComponent(name);
    I18nTextField displayedName = new I18nTextField(msg, msg.getMessage("EditIndividualTrustedSPSubView.displayedName"));
    configBinder.forField(displayedName).bind("displayedName");
    header.addComponent(displayedName);
    ImageField logo = new ImageField(msg, uriAccessService, serverConfig.getFileSizeLimit());
    logo.setCaption(msg.getMessage("EditIndividualTrustedSPSubView.logo"));
    logo.configureBinding(configBinder, "logo");
    header.addComponent(logo);
    CheckBox x500Name = new CheckBox(msg.getMessage("EditIndividualTrustedSPSubView.X500NameUse"));
    configBinder.forField(x500Name).bind("x500Name");
    header.addComponent(x500Name);
    TextField id = new TextField(msg.getMessage("EditIndividualTrustedSPSubView.id"));
    id.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    configBinder.forField(id).asRequired(msg.getMessage("fieldRequired")).withValidator((s, c) -> {
        if (x500Name.getValue()) {
            try {
                new X500Name(s);
                return ValidationResult.ok();
            } catch (Exception e) {
                return ValidationResult.error(msg.getMessage("EditIndividualTrustedSPSubView.invalidX500Name"));
            }
        } else {
            return ValidationResult.ok();
        }
    }).bind("id");
    header.addComponent(id);
    ChipsWithDropdown<String> certificatesCombo = new ChipsWithDropdown<>();
    certificatesCombo.setCaption(msg.getMessage("EditIndividualTrustedSPSubView.certificates"));
    certificatesCombo.setItems(certificates.stream().collect(Collectors.toList()));
    configBinder.forField(certificatesCombo).bind("certificates");
    header.addComponent(certificatesCombo);
    CheckBox encryptAssertions = new CheckBox(msg.getMessage("EditIndividualTrustedSPSubView.encryptAssertions"));
    configBinder.forField(encryptAssertions).bind("encryptAssertions");
    header.addComponent(encryptAssertions);
    ChipsWithTextfield authorizedURIs = new ChipsWithTextfield(msg);
    authorizedURIs.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    authorizedURIs.setCaption(msg.getMessage("EditIndividualTrustedSPSubView.authorizedURIs"));
    configBinder.forField(authorizedURIs).withValidator((v, c) -> {
        if (v == null || v.isEmpty()) {
            return ValidationResult.error(msg.getMessage("fieldRequired"));
        }
        return ValidationResult.ok();
    }).bind("authorizedRedirectsUri");
    header.addComponent(authorizedURIs);
    return header;
}
Also used : FieldSizeConstans(pl.edu.icm.unity.webui.common.FieldSizeConstans) Arrays(java.util.Arrays) CustomComponent(com.vaadin.ui.CustomComponent) TextField(com.vaadin.ui.TextField) VerticalLayout(com.vaadin.ui.VerticalLayout) ValidationResult(com.vaadin.data.ValidationResult) ImageField(pl.edu.icm.unity.webui.common.file.ImageField) NoSpaceValidator(pl.edu.icm.unity.webui.common.validators.NoSpaceValidator) UnityServerConfiguration(pl.edu.icm.unity.engine.api.config.UnityServerConfiguration) X500Name(org.bouncycastle.asn1.x500.X500Name) UnitySubView(pl.edu.icm.unity.webui.common.webElements.UnitySubView) CheckBox(com.vaadin.ui.CheckBox) MessageSource(pl.edu.icm.unity.MessageSource) NotificationPopup(pl.edu.icm.unity.webui.common.NotificationPopup) ChipsWithTextfield(pl.edu.icm.unity.webui.common.chips.ChipsWithTextfield) CollapsibleLayout(pl.edu.icm.unity.webui.common.CollapsibleLayout) Set(java.util.Set) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) StandardButtonsHelper(pl.edu.icm.unity.webui.common.StandardButtonsHelper) Collectors(java.util.stream.Collectors) Binder(com.vaadin.data.Binder) Consumer(java.util.function.Consumer) List(java.util.List) SubViewSwitcher(pl.edu.icm.unity.webui.common.webElements.SubViewSwitcher) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) URIAccessService(pl.edu.icm.unity.engine.api.files.URIAccessService) FormLayout(com.vaadin.ui.FormLayout) FormValidationException(pl.edu.icm.unity.webui.common.FormValidationException) ChipsWithDropdown(pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) ChipsWithDropdown(pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown) X500Name(org.bouncycastle.asn1.x500.X500Name) FormValidationException(pl.edu.icm.unity.webui.common.FormValidationException) ImageField(pl.edu.icm.unity.webui.common.file.ImageField) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) CheckBox(com.vaadin.ui.CheckBox) ChipsWithTextfield(pl.edu.icm.unity.webui.common.chips.ChipsWithTextfield) TextField(com.vaadin.ui.TextField) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) NoSpaceValidator(pl.edu.icm.unity.webui.common.validators.NoSpaceValidator)

Example 4 with ChipsWithDropdown

use of pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown in project unity by unity-idm.

the class AttributePolicyConfigurationEditor method init.

private void init() {
    binder = new Binder<>(AttributePolicyBean.class);
    main = new VerticalLayout();
    FormLayoutWithFixedCaptionWidth header = new FormLayoutWithFixedCaptionWidth();
    header.setMargin(false);
    main.addComponent(header);
    name = new TextField(msg.getMessage("AttributePolicyConfigurationEditor.name"));
    header.addComponent(name);
    binder.forField(name).bind("name");
    ChipsWithDropdown<String> targetIdps = new ChipsWithDropdown<>(p -> getDisplayeName(p), true);
    targetIdps.setItems(idPs.keySet());
    targetIdps.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
    targetIdps.setCaption(msg.getMessage("AttributePolicyConfigurationEditor.targetIdps"));
    binder.forField(targetIdps).bind("targetIdps");
    header.addComponent(targetIdps);
    ChipsWithDropdown<String> targetFederations = new ChipsWithDropdown<>(p -> getGroupDisplayeName(p), true);
    targetFederations.setItems(IdPsGroups.keySet());
    targetFederations.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
    targetFederations.setCaption(msg.getMessage("AttributePolicyConfigurationEditor.targetFederations"));
    binder.forField(targetFederations).bind("targetFederations");
    header.addComponent(targetFederations);
    AttributesGrid attributes = new AttributesGrid(msg);
    binder.forField(attributes).bind("attributes");
    main.addComponent(attributes);
    binder.addValueChangeListener(e -> fireEvent(new ValueChangeEvent<>(this, getValue(), true)));
}
Also used : FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField) ChipsWithDropdown(pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown)

Example 5 with ChipsWithDropdown

use of pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown in project unity by unity-idm.

the class EditIndividualTrustedIdpSubView method buildHeaderSection.

private FormLayout buildHeaderSection() {
    FormLayoutWithFixedCaptionWidth header = new FormLayoutWithFixedCaptionWidth();
    header.setMargin(true);
    TextField name = new TextField(msg.getMessage("EditIndividualTrustedIdpSubView.name"));
    name.focus();
    configBinder.forField(name).asRequired(msg.getMessage("fieldRequired")).withValidator(new NoSpaceValidator(msg)).withValidator((s, c) -> {
        if (usedNames.contains(s)) {
            return ValidationResult.error(msg.getMessage("EditIndividualTrustedIdpSubView.nameExists"));
        } else {
            return ValidationResult.ok();
        }
    }).bind("name");
    header.addComponent(name);
    I18nTextField displayedName = new I18nTextField(msg, msg.getMessage("EditIndividualTrustedIdpSubView.displayedName"));
    configBinder.forField(displayedName).asRequired(msg.getMessage("fieldRequired")).bind("displayedName");
    header.addComponent(displayedName);
    ImageField logo = new ImageField(msg, uriAccessService, serverConfig.getFileSizeLimit());
    logo.setCaption(msg.getMessage("EditIndividualTrustedIdpSubView.logo"));
    logo.configureBinding(configBinder, "logo");
    header.addComponent(logo);
    TextField id = new TextField(msg.getMessage("EditIndividualTrustedIdpSubView.id"));
    id.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    configBinder.forField(id).asRequired(msg.getMessage("fieldRequired")).bind("id");
    header.addComponent(id);
    TextField address = new TextField(msg.getMessage("EditIndividualTrustedIdpSubView.address"));
    address.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    configBinder.forField(address).bind("address");
    header.addComponent(address);
    ChipsWithFreeText requestedNameFormats = new ChipsWithFreeText(msg);
    requestedNameFormats.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
    requestedNameFormats.setCaption(msg.getMessage("EditIndividualTrustedIdpSubView.requestedNameFormats"));
    requestedNameFormats.setItems(SAMLAuthenticatorEditor.STANDART_NAME_FORMATS);
    header.addComponent(requestedNameFormats);
    configBinder.forField(requestedNameFormats).bind("requestedNameFormats");
    CheckBox signRequest = new CheckBox(msg.getMessage("EditIndividualTrustedIdpSubView.signRequest"));
    ComboBox<Binding> binding = new ComboBox<>(msg.getMessage("EditIndividualTrustedIdpSubView.binding"));
    binding.setItems(Binding.values());
    binding.setEmptySelectionAllowed(false);
    binding.addValueChangeListener(e -> {
        boolean v = e.getValue().equals(Binding.HTTP_POST);
        signRequest.setEnabled(v);
        if (!v) {
            signRequest.setValue(false);
        }
    });
    configBinder.forField(binding).bind("binding");
    configBinder.forField(signRequest).withValidator((v, c) -> {
        if (v != null && v && (binding.getValue().equals(Binding.HTTP_REDIRECT) || binding.getValue().equals(Binding.SOAP))) {
            return ValidationResult.error(msg.getMessage("EditIndividualTrustedIdpSubView.signRequestValidationError"));
        }
        return ValidationResult.ok();
    }).bind("signRequest");
    header.addComponent(binding);
    header.addComponent(signRequest);
    ChipsWithDropdown<String> certificatesCombo = new ChipsWithDropdown<>();
    certificatesCombo.setCaption(msg.getMessage("EditIndividualTrustedIdpSubView.certificates"));
    certificatesCombo.setItems(certificates.stream().collect(Collectors.toList()));
    configBinder.forField(certificatesCombo).bind("certificates");
    header.addComponent(certificatesCombo);
    TextField groupAttribute = new TextField(msg.getMessage("EditIndividualTrustedIdpSubView.groupMembershipAttribute"));
    configBinder.forField(groupAttribute).bind("groupMembershipAttribute");
    header.addComponent(groupAttribute);
    ComboBox<String> registrationForm = new ComboBox<>(msg.getMessage("EditIndividualTrustedIdpSubView.registrationForm"));
    registrationForm.setItems(registrationForms);
    header.addComponent(registrationForm);
    configBinder.forField(registrationForm).bind("registrationForm");
    EnableDisableCombo accountAssociation = new EnableDisableCombo(msg.getMessage("EditIndividualTrustedIdpSubView.accountAssociation"), msg);
    configBinder.forField(accountAssociation).bind("accountAssociation");
    header.addComponent(accountAssociation);
    return header;
}
Also used : FieldSizeConstans(pl.edu.icm.unity.webui.common.FieldSizeConstans) Arrays(java.util.Arrays) CustomComponent(com.vaadin.ui.CustomComponent) TextField(com.vaadin.ui.TextField) VerticalLayout(com.vaadin.ui.VerticalLayout) ComboBox(com.vaadin.ui.ComboBox) ValidationResult(com.vaadin.data.ValidationResult) ImageField(pl.edu.icm.unity.webui.common.file.ImageField) NoSpaceValidator(pl.edu.icm.unity.webui.common.validators.NoSpaceValidator) UnityServerConfiguration(pl.edu.icm.unity.engine.api.config.UnityServerConfiguration) UnitySubView(pl.edu.icm.unity.webui.common.webElements.UnitySubView) CheckBox(com.vaadin.ui.CheckBox) MessageSource(pl.edu.icm.unity.MessageSource) NotificationPopup(pl.edu.icm.unity.webui.common.NotificationPopup) CollapsibleLayout(pl.edu.icm.unity.webui.common.CollapsibleLayout) Binding(pl.edu.icm.unity.saml.SamlProperties.Binding) EnableDisableCombo(pl.edu.icm.unity.webui.common.EnableDisableCombo) Set(java.util.Set) InputTranslationProfileFieldFactory(io.imunity.webconsole.utils.tprofile.InputTranslationProfileFieldFactory) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) StandardButtonsHelper(pl.edu.icm.unity.webui.common.StandardButtonsHelper) Collectors(java.util.stream.Collectors) Binder(com.vaadin.data.Binder) Consumer(java.util.function.Consumer) List(java.util.List) SubViewSwitcher(pl.edu.icm.unity.webui.common.webElements.SubViewSwitcher) ChipsWithFreeText(pl.edu.icm.unity.webui.common.chips.ChipsWithFreeText) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) URIAccessService(pl.edu.icm.unity.engine.api.files.URIAccessService) FormLayout(com.vaadin.ui.FormLayout) FormValidationException(pl.edu.icm.unity.webui.common.FormValidationException) ChipsWithDropdown(pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown) Binding(pl.edu.icm.unity.saml.SamlProperties.Binding) ChipsWithFreeText(pl.edu.icm.unity.webui.common.chips.ChipsWithFreeText) ComboBox(com.vaadin.ui.ComboBox) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) ChipsWithDropdown(pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown) ImageField(pl.edu.icm.unity.webui.common.file.ImageField) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) CheckBox(com.vaadin.ui.CheckBox) TextField(com.vaadin.ui.TextField) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) EnableDisableCombo(pl.edu.icm.unity.webui.common.EnableDisableCombo) NoSpaceValidator(pl.edu.icm.unity.webui.common.validators.NoSpaceValidator)

Aggregations

ChipsWithDropdown (pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown)9 Binder (com.vaadin.data.Binder)7 List (java.util.List)7 MessageSource (pl.edu.icm.unity.MessageSource)7 CheckBox (com.vaadin.ui.CheckBox)6 TextField (com.vaadin.ui.TextField)6 VerticalLayout (com.vaadin.ui.VerticalLayout)6 Set (java.util.Set)6 Collectors (java.util.stream.Collectors)6 FormLayoutWithFixedCaptionWidth (pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth)6 ValidationResult (com.vaadin.data.ValidationResult)5 Component (com.vaadin.ui.Component)5 Consumer (java.util.function.Consumer)5 CollapsibleLayout (pl.edu.icm.unity.webui.common.CollapsibleLayout)5 FormValidationException (pl.edu.icm.unity.webui.common.FormValidationException)5 I18nTextField (pl.edu.icm.unity.webui.common.i18n.I18nTextField)5 Button (com.vaadin.ui.Button)4 ComboBox (com.vaadin.ui.ComboBox)4 FormLayout (com.vaadin.ui.FormLayout)4 HorizontalLayout (com.vaadin.ui.HorizontalLayout)4