Search in sources :

Example 51 with TextField

use of com.vaadin.ui.TextField in project esup-ecandidat by EsupPortail.

the class TestMailWindow method generateHlTf.

private HorizontalLayout generateHlTf(final String property) {
    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth(100, Unit.PERCENTAGE);
    hl.setSpacing(true);
    TextField tfLabel = new TextField();
    tfLabel.setValue("${" + property + "}");
    tfLabel.setReadOnly(true);
    hl.addComponent(tfLabel);
    hl.setExpandRatio(tfLabel, 1);
    TextField tf = new TextField();
    tf.setId(property);
    tf.setWidth(100, Unit.PERCENTAGE);
    tf.setValue("test" + property.replaceAll("\\.", ""));
    hl.addComponent(tf);
    hl.setExpandRatio(tf, 1.5f);
    listTf.add(tf);
    return hl;
}
Also used : TextField(com.vaadin.ui.TextField) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 52 with TextField

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

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

the class TranslationProfileEditor method initUI.

protected void initUI() {
    rulesLayout = new VerticalLayout();
    rulesLayout.setSpacing(false);
    rulesLayout.setMargin(false);
    rulesLayout.setHeightUndefined();
    rulesLayout.setWidth(100, Unit.PERCENTAGE);
    rulesLayout.setStyleName(Styles.vDropLayout.toString());
    name = new TextField(msg.getMessage("TranslationProfileEditor.name"));
    description = new DescriptionTextField(msg);
    rulesHeader = new HorizontalLayout();
    rulesHeader.setMargin(false);
    addRule = new Button();
    addRule.setDescription(msg.getMessage("TranslationProfileEditor.newRule"));
    addRule.setIcon(Images.add.getResource());
    addRule.addStyleName(Styles.vButtonLink.toString());
    addRule.addStyleName(Styles.toolbarButton.toString());
    addRule.addClickListener(event -> addRuleComponent(null));
    testProfileButton = new StartStopButton();
    testProfileButton.setVisible(false);
    testProfileButton.setDescription(msg.getMessage("TranslationProfileEditor.testProfile"));
    testProfileButton.addClickListener(new StartStopButton.StartStopListener() {

        @Override
        public void onStop(ClickStopEvent event) {
            clearTestResults();
        }

        @Override
        public void onStart(ClickStartEvent event) {
            testRules();
        }
    });
    Label t = new Label(msg.getMessage("TranslationProfileEditor.rules"));
    rulesHeader.addComponents(t, addRule, testProfileButton);
    FormLayout main = new CompactFormLayout();
    main.addComponents(name, description);
    main.setSizeFull();
    VerticalLayout wrapper = new VerticalLayout();
    wrapper.addComponents(main, rulesHeader, rulesLayout);
    binder = new Binder<>(TranslationProfile.class);
    binder.forField(name).asRequired(msg.getMessage("fieldRequired")).bind("name");
    binder.bind(description, "description");
    binder.setBean(new TranslationProfile(msg.getMessage("TranslationProfileEditor.defaultName"), null, type, new ArrayList<TranslationRule>()));
    setSpacing(false);
    setMargin(false);
    addComponents(wrapper);
    refreshRules();
}
Also used : CompactFormLayout(pl.edu.icm.unity.webui.common.CompactFormLayout) FormLayout(com.vaadin.ui.FormLayout) CompactFormLayout(pl.edu.icm.unity.webui.common.CompactFormLayout) DescriptionTextField(pl.edu.icm.unity.webui.common.widgets.DescriptionTextField) TranslationProfile(pl.edu.icm.unity.types.translation.TranslationProfile) ClickStartEvent(io.imunity.webconsole.tprofile.StartStopButton.ClickStartEvent) Label(com.vaadin.ui.Label) ArrayList(java.util.ArrayList) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ClickStopEvent(io.imunity.webconsole.tprofile.StartStopButton.ClickStopEvent) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField) DescriptionTextField(pl.edu.icm.unity.webui.common.widgets.DescriptionTextField)

Example 54 with TextField

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

the class MainAuthenticatorEditor method initUI.

private void initUI() {
    Map<AuthenticatorTypeDescription, String> authnTypesSorted = getAuthenticatorTypes();
    authenticatorTypeCombo = new ComboBox<>();
    authenticatorTypeCombo.setCaption(msg.getMessage("MainAuthenticatorEditor.typeComboCaption"));
    authenticatorTypeCombo.addSelectionListener(e -> reloadEditor());
    if (typeChangeListener.isPresent()) {
        authenticatorTypeCombo.addSelectionListener(typeChangeListener.get());
    }
    authenticatorTypeCombo.setEmptySelectionAllowed(false);
    authenticatorTypeCombo.setItemCaptionGenerator(t -> authnTypesSorted.get(t));
    authenticatorTypeCombo.setWidth(25, Unit.EM);
    authenticatorTypeCombo.setItems(authnTypesSorted.keySet());
    authenticatorTypeLabel = new TextField();
    authenticatorTypeLabel.setWidth(25, Unit.EM);
    authenticatorTypeLabel.setCaption(msg.getMessage("MainAuthenticatorEditor.typeLabelCaption"));
    authenticatorTypeLabel.setReadOnly(true);
    mainLayout = new VerticalLayout();
    mainLayout.setMargin(false);
    FormLayoutWithFixedCaptionWidth typeWrapper = new FormLayoutWithFixedCaptionWidth();
    typeWrapper.setMargin(new MarginInfo(false, true));
    typeWrapper.addComponent(authenticatorTypeCombo);
    typeWrapper.addComponent(authenticatorTypeLabel);
    mainLayout.addComponent(typeWrapper);
    setCompositionRoot(mainLayout);
    if (toEdit != null) {
        AuthenticatorTypeDescription desc = authnTypesSorted.keySet().stream().filter(t -> t.getVerificationMethod().equals(toEdit.authenticator.type)).findFirst().orElse(null);
        authenticatorTypeCombo.setValue(desc);
        authenticatorTypeCombo.setVisible(false);
        authenticatorTypeLabel.setValue(desc != null ? AuthenticatorTypeLabelHelper.getAuthenticatorTypeLabel(msg, desc) : "");
        authenticatorTypeLabel.setVisible(true);
    } else {
        authenticatorTypeCombo.setVisible(true);
        authenticatorTypeLabel.setVisible(false);
        authenticatorTypeCombo.setValue(authnTypesSorted.keySet().iterator().next());
    }
}
Also used : FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) MarginInfo(com.vaadin.shared.ui.MarginInfo) TextField(com.vaadin.ui.TextField) VerticalLayout(com.vaadin.ui.VerticalLayout) AuthenticatorTypeDescription(pl.edu.icm.unity.types.authn.AuthenticatorTypeDescription)

Example 55 with TextField

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

the class CredentialRequirementEditor method init.

private void init(CredentialRequirements initial, Collection<CredentialDefinition> allCredentials) {
    setWidth(100, Unit.PERCENTAGE);
    TextField name = new TextField(msg.getMessage("CredentialRequirements.name"));
    addComponent(name);
    if (initial != null)
        name.setReadOnly(true);
    DescriptionTextField description = new DescriptionTextField(msg);
    addComponent(description);
    TwinColSelect<String> requiredCredentials = new TwinColSelect<>(msg.getMessage("CredentialRequirements.credentials"));
    requiredCredentials.setLeftColumnCaption(msg.getMessage("CredentialRequirements.available"));
    requiredCredentials.setRightColumnCaption(msg.getMessage("CredentialRequirements.chosen"));
    requiredCredentials.setWidth(48, Unit.EM);
    requiredCredentials.setRows(5);
    requiredCredentials.setItems(allCredentials.stream().map(cr -> cr.getName()));
    addComponent(requiredCredentials);
    CredentialRequirements cr = initial == null ? new CredentialRequirements(msg.getMessage("CredentialRequirements.defaultName"), "", new HashSet<>()) : initial;
    binder = new Binder<>(CredentialRequirements.class);
    binder.forField(name).asRequired(msg.getMessage("fieldRequired")).bind("name");
    binder.bind(description, "description");
    binder.bind(requiredCredentials, "requiredCredentials");
    binder.setBean(cr);
}
Also used : HashSet(java.util.HashSet) CompactFormLayout(pl.edu.icm.unity.webui.common.CompactFormLayout) TextField(com.vaadin.ui.TextField) TwinColSelect(com.vaadin.ui.TwinColSelect) CredentialDefinition(pl.edu.icm.unity.types.authn.CredentialDefinition) Collection(java.util.Collection) CredentialRequirements(pl.edu.icm.unity.types.authn.CredentialRequirements) Binder(com.vaadin.data.Binder) DescriptionTextField(pl.edu.icm.unity.webui.common.widgets.DescriptionTextField) MessageSource(pl.edu.icm.unity.MessageSource) IllegalCredentialException(pl.edu.icm.unity.exceptions.IllegalCredentialException) DescriptionTextField(pl.edu.icm.unity.webui.common.widgets.DescriptionTextField) CredentialRequirements(pl.edu.icm.unity.types.authn.CredentialRequirements) TextField(com.vaadin.ui.TextField) DescriptionTextField(pl.edu.icm.unity.webui.common.widgets.DescriptionTextField) TwinColSelect(com.vaadin.ui.TwinColSelect) HashSet(java.util.HashSet)

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