Search in sources :

Example 66 with TextField

use of com.vaadin.ui.TextField in project unity by unity-idm.

the class UsernameIdentityEditor method getEditor.

@Override
public ComponentsContainer getEditor(IdentityEditorContext context) {
    this.context = context;
    field = new TextField();
    setLabel(new UsernameIdentity().getHumanFriendlyName(msg));
    field.setId("UsernameIdentityEditor.username");
    if (context.isCustomWidth())
        field.setWidth(context.getCustomWidth(), context.getCustomWidthUnit());
    binder = new SingleStringFieldBinder(msg);
    binder.forField(field, context.isRequired()).bind("value");
    binder.setBean(new StringBindingValue(""));
    return new ComponentsContainer(field);
}
Also used : TextField(com.vaadin.ui.TextField) UsernameIdentity(pl.edu.icm.unity.stdext.identity.UsernameIdentity) StringBindingValue(pl.edu.icm.unity.webui.common.binding.StringBindingValue) ComponentsContainer(pl.edu.icm.unity.webui.common.ComponentsContainer) SingleStringFieldBinder(pl.edu.icm.unity.webui.common.binding.SingleStringFieldBinder)

Example 67 with TextField

use of com.vaadin.ui.TextField in project unity by unity-idm.

the class X500IdentityEditor method getEditor.

@Override
public ComponentsContainer getEditor(IdentityEditorContext context) {
    binder = new SingleStringFieldBinder(msg);
    this.context = context;
    field = new TextField();
    if (context.isCustomWidth())
        field.setWidth(context.getCustomWidth(), context.getCustomWidthUnit());
    else
        field.setWidth(100, Unit.PERCENTAGE);
    Upload upload = new Upload();
    upload.setButtonCaption(msg.getMessage("X500IdentityEditor.certUploadCaption"));
    upload.addStyleName(Styles.vButtonLink.toString());
    CertUploader uploader = new CertUploader();
    upload.setReceiver(uploader);
    upload.addSucceededListener(uploader);
    setLabel(new X500Identity().getHumanFriendlyName(msg));
    binder.forField(field, context.isRequired()).withValidator(this::validate).bind("value");
    binder.setBean(new StringBindingValue(""));
    return new ComponentsContainer(field, upload);
}
Also used : TextField(com.vaadin.ui.TextField) Upload(com.vaadin.ui.Upload) StringBindingValue(pl.edu.icm.unity.webui.common.binding.StringBindingValue) X500Identity(pl.edu.icm.unity.stdext.identity.X500Identity) ComponentsContainer(pl.edu.icm.unity.webui.common.ComponentsContainer) SingleStringFieldBinder(pl.edu.icm.unity.webui.common.binding.SingleStringFieldBinder)

Example 68 with TextField

use of com.vaadin.ui.TextField in project unity by unity-idm.

the class EmailConfirmationConfigurationEditor method initUI.

private void initUI() {
    binder = new Binder<>(EmailConfirmationConfiguration.class);
    msgTemplate = new CompatibleTemplatesComboBox(EmailConfirmationTemplateDef.NAME, msgTemplateMan);
    msgTemplate.setCaption(msg.getMessage("EmailConfirmationConfiguration.confirmationMsgTemplate"));
    msgTemplate.setDescription(msg.getMessage("EmailConfirmationConfiguration.confirmationMsgTemplateDesc"));
    msgTemplate.setEmptySelectionAllowed(true);
    validityTime = new TextField(msg.getMessage("EmailConfirmationConfiguration.validityTime"));
    addFieldToLayout(this);
    binder.forField(msgTemplate).bind("messageTemplate");
    binder.forField(validityTime).asRequired(msg.getMessage("fieldRequired")).withConverter(new StringToIntegerConverter(msg.getMessage("notAnIntNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("outOfBoundsNumber", 1, 60 * 24 * 365), 1, 60 * 24 * 365)).bind("validityTime");
    if (initial != null) {
        binder.setBean(initial);
    } else {
        EmailConfirmationConfiguration init = new EmailConfirmationConfiguration();
        init.setMessageTemplate(msgTemplate.getValue());
        init.setValidityTime(EmailConfirmationConfiguration.DEFAULT_VALIDITY);
        binder.setBean(init);
    }
}
Also used : IntegerRangeValidator(com.vaadin.data.validator.IntegerRangeValidator) TextField(com.vaadin.ui.TextField) StringToIntegerConverter(com.vaadin.data.converter.StringToIntegerConverter) EmailConfirmationConfiguration(pl.edu.icm.unity.types.confirmation.EmailConfirmationConfiguration) CompatibleTemplatesComboBox(pl.edu.icm.unity.webui.common.CompatibleTemplatesComboBox)

Example 69 with TextField

use of com.vaadin.ui.TextField 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 70 with TextField

use of com.vaadin.ui.TextField in project unity by unity-idm.

the class EditTrustedFederationSubView method buildHeaderSection.

private FormLayout buildHeaderSection() {
    FormLayoutWithFixedCaptionWidth header = new FormLayoutWithFixedCaptionWidth();
    header.setMargin(true);
    TextField name = new TextField(msg.getMessage("EditTrustedFederationSubView.name"));
    binder.forField(name).asRequired(msg.getMessage("fieldRequired")).withValidator(new NoSpaceValidator(msg)).withValidator((s, c) -> {
        if (usedNames.contains(s)) {
            return ValidationResult.error(msg.getMessage("EditTrustedFederationSubView.nameExists"));
        } else {
            return ValidationResult.ok();
        }
    }).bind("name");
    header.addComponent(name);
    name.focus();
    url = new TextField(msg.getMessage("EditTrustedFederationSubView.url"));
    url.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    binder.forField(url).asRequired(msg.getMessage("fieldRequired")).bind("url");
    header.addComponent(url);
    httpsTruststore = new ComboBox<>(msg.getMessage("EditTrustedFederationSubView.httpsTruststore"));
    httpsTruststore.setItems(validators);
    binder.forField(httpsTruststore).bind("httpsTruststore");
    header.addComponent(httpsTruststore);
    CheckBox ignoreSignatureVerification = new CheckBox(msg.getMessage("EditTrustedFederationSubView.ignoreSignatureVerification"));
    binder.forField(ignoreSignatureVerification).bind("ignoreSignatureVerification");
    header.addComponent(ignoreSignatureVerification);
    ComboBox<String> signatureVerificationCertificate = new ComboBox<>(msg.getMessage("EditTrustedFederationSubView.signatureVerificationCertificate"));
    signatureVerificationCertificate.setItems(certificates);
    binder.forField(signatureVerificationCertificate).asRequired((v, c) -> ((v == null || v.isEmpty()) && !ignoreSignatureVerification.getValue()) ? ValidationResult.error(msg.getMessage("fieldRequired")) : ValidationResult.ok()).bind("signatureVerificationCertificate");
    header.addComponent(signatureVerificationCertificate);
    TextField refreshInterval = new TextField();
    refreshInterval.setCaption(msg.getMessage("EditTrustedFederationSubView.refreshInterval"));
    binder.forField(refreshInterval).asRequired(msg.getMessage("fieldRequired")).withConverter(new StringToIntegerConverter(msg.getMessage("notAPositiveNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 0, null)).bind("refreshInterval");
    header.addComponent(refreshInterval);
    return header;
}
Also used : FieldSizeConstans(pl.edu.icm.unity.webui.common.FieldSizeConstans) Arrays(java.util.Arrays) CustomComponent(com.vaadin.ui.CustomComponent) URIHelper(pl.edu.icm.unity.engine.api.files.URIHelper) TextField(com.vaadin.ui.TextField) VerticalLayout(com.vaadin.ui.VerticalLayout) Alignment(com.vaadin.ui.Alignment) ComboBox(com.vaadin.ui.ComboBox) UI(com.vaadin.ui.UI) CompletableFuture(java.util.concurrent.CompletableFuture) FileStreamResource(pl.edu.icm.unity.webui.common.FileStreamResource) ValidationResult(com.vaadin.data.ValidationResult) NoSpaceValidator(pl.edu.icm.unity.webui.common.validators.NoSpaceValidator) MetadataDownloader(pl.edu.icm.unity.saml.metadata.srv.MetadataDownloader) UnitySubView(pl.edu.icm.unity.webui.common.webElements.UnitySubView) Resource(com.vaadin.server.Resource) CheckBox(com.vaadin.ui.CheckBox) Image(com.vaadin.ui.Image) Orientation(com.vaadin.shared.ui.Orientation) FilterableGridHelper(pl.edu.icm.unity.webui.common.grid.FilterableGridHelper) GridWithActionColumn(pl.edu.icm.unity.webui.common.GridWithActionColumn) ProgressBar(com.vaadin.ui.ProgressBar) SearchField(pl.edu.icm.unity.webui.common.SearchField) MessageSource(pl.edu.icm.unity.MessageSource) NotificationPopup(pl.edu.icm.unity.webui.common.NotificationPopup) IntegerRangeValidator(com.vaadin.data.validator.IntegerRangeValidator) CollapsibleLayout(pl.edu.icm.unity.webui.common.CollapsibleLayout) SAMLEntityWithLogo(pl.edu.icm.unity.saml.idp.console.SimpleIDPMetaConverter.SAMLEntityWithLogo) Set(java.util.Set) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) StandardButtonsHelper(pl.edu.icm.unity.webui.common.StandardButtonsHelper) Binder(com.vaadin.data.Binder) Images(pl.edu.icm.unity.webui.common.Images) Consumer(java.util.function.Consumer) List(java.util.List) Button(com.vaadin.ui.Button) SubViewSwitcher(pl.edu.icm.unity.webui.common.webElements.SubViewSwitcher) HorizontalLayout(com.vaadin.ui.HorizontalLayout) URIAccessService(pl.edu.icm.unity.engine.api.files.URIAccessService) FormLayout(com.vaadin.ui.FormLayout) FormValidationException(pl.edu.icm.unity.webui.common.FormValidationException) EntitiesDescriptorDocument(xmlbeans.org.oasis.saml2.metadata.EntitiesDescriptorDocument) StringToIntegerConverter(com.vaadin.data.converter.StringToIntegerConverter) FileStorageService(pl.edu.icm.unity.engine.api.files.FileStorageService) ComponentWithToolbar(pl.edu.icm.unity.webui.common.ComponentWithToolbar) Toolbar(pl.edu.icm.unity.webui.common.Toolbar) Collections(java.util.Collections) IntegerRangeValidator(com.vaadin.data.validator.IntegerRangeValidator) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) CheckBox(com.vaadin.ui.CheckBox) ComboBox(com.vaadin.ui.ComboBox) TextField(com.vaadin.ui.TextField) StringToIntegerConverter(com.vaadin.data.converter.StringToIntegerConverter) NoSpaceValidator(pl.edu.icm.unity.webui.common.validators.NoSpaceValidator)

Aggregations

TextField (com.vaadin.ui.TextField)185 VerticalLayout (com.vaadin.ui.VerticalLayout)51 CheckBox (com.vaadin.ui.CheckBox)45 Label (com.vaadin.ui.Label)41 Button (com.vaadin.ui.Button)40 ComboBox (com.vaadin.ui.ComboBox)39 HorizontalLayout (com.vaadin.ui.HorizontalLayout)39 FormLayoutWithFixedCaptionWidth (pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth)38 FormLayout (com.vaadin.ui.FormLayout)28 CollapsibleLayout (pl.edu.icm.unity.webui.common.CollapsibleLayout)28 I18nTextField (pl.edu.icm.unity.webui.common.i18n.I18nTextField)27 Binder (com.vaadin.data.Binder)23 StringToIntegerConverter (com.vaadin.data.converter.StringToIntegerConverter)23 Test (org.junit.Test)22 MessageSource (pl.edu.icm.unity.MessageSource)22 Component (com.vaadin.ui.Component)21 ValidationResult (com.vaadin.data.ValidationResult)19 List (java.util.List)18 IntegerRangeValidator (com.vaadin.data.validator.IntegerRangeValidator)17 Set (java.util.Set)17