use of com.vaadin.data.validator.IntegerRangeValidator in project GridFastNavigation by TatuLund.
the class DemoUI method initGrid.
private void initGrid(final Grid grid) {
grid.setEditorEnabled(true);
// Add some columns
DeleteButtonRenderer deleteButton = new DeleteButtonRenderer(new DeleteRendererClickListener() {
@Override
public void click(DeleteRendererClickEvent event) {
grid.getContainerDataSource().removeItem(event.getItem());
}
}, FontAwesome.TRASH.getHtml() + " Delete", FontAwesome.CHECK.getHtml() + " Confirm");
deleteButton.setHtmlContentAllowed(true);
grid.addColumn("action", Boolean.class);
grid.getColumn("action").setEditable(false);
grid.getColumn("action").setRenderer(deleteButton);
grid.addColumn("col1", String.class);
grid.addColumn("col2", String.class);
for (int i = 0; i < 5; ++i) {
grid.addColumn("col" + (i + 3), Integer.class);
}
TextField field = new TextField();
field.addValidator(new IntegerRangeValidator("The value needs to be between 0 and 10", 0, 40));
grid.getColumn("col3").setEditorField(field);
grid.addColumn("col8", Date.class);
grid.addColumn("col10", Boolean.class);
grid.addColumn("col11", String.class);
ComboBox comboBox = new ComboBox();
comboBox.addItems("Soft", "Medium", "Hard");
grid.getColumn("col11").setEditorField(comboBox);
// Make column 2 read only to test statically read only columns
grid.getColumn("col2").setEditable(false);
Random rand = new Random();
for (int i = 0; i < 100; ++i) {
grid.addRow(true, "string 1 " + i, "string 2 " + i, rand.nextInt(i + 10), rand.nextInt(i + 10), rand.nextInt(i + 10), rand.nextInt(i + 10), rand.nextInt(i + 10), new Date(), false, "Medium");
}
grid.setSelectionMode(SelectionMode.SINGLE);
grid.setSizeFull();
}
use of com.vaadin.data.validator.IntegerRangeValidator in project unity by unity-idm.
the class OTPWithLDAPAuthenticatorEditor method buildServersConnectionConfigurationSection.
private CollapsibleLayout buildServersConnectionConfigurationSection() {
FormLayoutWithFixedCaptionWidth serverConnectionLayout = new FormLayoutWithFixedCaptionWidth();
serverConnectionLayout.setMargin(false);
GridWithEditor<ServerSpecification> serverConfig = new GridWithEditor<>(msg, ServerSpecification.class);
serverConnectionLayout.addComponent(serverConfig);
serverConfig.addTextColumn(s -> s.getServer(), (t, v) -> t.setServer(v), msg.getMessage("LdapAuthenticatorEditor.server"), 40, true);
serverConfig.addIntColumn(s -> s.getPort(), (t, v) -> t.setPort(v), msg.getMessage("LdapAuthenticatorEditor.port"), 10, Optional.of(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 1, 65535)));
serverConfig.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
configBinder.forField(serverConfig).withValidator((v, c) -> {
if (v == null || v.isEmpty()) {
return ValidationResult.error(msg.getMessage("fieldRequired"));
} else {
return ValidationResult.ok();
}
}).bind("servers");
ComboBox<ConnectionMode> connectionMode = new ComboBox<>(msg.getMessage("LdapAuthenticatorEditor.connectionMode"));
connectionMode.setItems(ConnectionMode.values());
connectionMode.setEmptySelectionAllowed(false);
configBinder.forField(connectionMode).bind("connectionMode");
serverConnectionLayout.addComponent(connectionMode);
TextField followReferrals = new TextField(msg.getMessage("LdapAuthenticatorEditor.followReferrals"));
configBinder.forField(followReferrals).asRequired(msg.getMessage("notAPositiveNumber")).withConverter(new StringToIntegerConverter(msg.getMessage("notAPositiveNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 0, null)).bind("followReferrals");
serverConnectionLayout.addComponent(followReferrals);
TextField searchTimeLimit = new TextField(msg.getMessage("LdapAuthenticatorEditor.searchTimeLimit"));
configBinder.forField(searchTimeLimit).asRequired(msg.getMessage("notAPositiveNumber")).withConverter(new StringToIntegerConverter(msg.getMessage("notAPositiveNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 0, null)).bind("searchTimeLimit");
serverConnectionLayout.addComponent(searchTimeLimit);
TextField socketTimeout = new TextField(msg.getMessage("LdapAuthenticatorEditor.socketTimeout"));
configBinder.forField(socketTimeout).asRequired(msg.getMessage("notAPositiveNumber")).withConverter(new StringToIntegerConverter(msg.getMessage("notAPositiveNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 0, null)).bind("socketTimeout");
serverConnectionLayout.addComponent(socketTimeout);
CheckBox trustAllCerts = new CheckBox(msg.getMessage("LdapAuthenticatorEditor.trustAllCerts"));
configBinder.forField(trustAllCerts).bind("trustAllCerts");
serverConnectionLayout.addComponent(trustAllCerts);
ComboBox<String> clientTrustStore = new ComboBox<>(msg.getMessage("LdapAuthenticatorEditor.clientTrustStore"));
clientTrustStore.setItems(validators);
configBinder.forField(clientTrustStore).bind("clientTrustStore");
serverConnectionLayout.addComponent(clientTrustStore);
trustAllCerts.addValueChangeListener(e -> {
clientTrustStore.setEnabled(!e.getValue());
});
TextField resultEntriesLimit = new TextField(msg.getMessage("LdapAuthenticatorEditor.resultEntriesLimit"));
configBinder.forField(resultEntriesLimit).asRequired(msg.getMessage("notAPositiveNumber")).withConverter(new StringToIntegerConverter(msg.getMessage("notAPositiveNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 0, null)).bind("resultEntriesLimit");
serverConnectionLayout.addComponent(resultEntriesLimit);
return new CollapsibleLayout(msg.getMessage("OTPWithLDAPAuthenticatorEditor.serverConnectionConfiguration"), serverConnectionLayout);
}
use of com.vaadin.data.validator.IntegerRangeValidator 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);
}
}
use of com.vaadin.data.validator.IntegerRangeValidator 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;
}
use of com.vaadin.data.validator.IntegerRangeValidator in project unity by unity-idm.
the class JWTAuthenticatorEditor method getEditor.
@Override
public Component getEditor(AuthenticatorDefinition toEdit, SubViewSwitcher switcher, boolean forceNameEditable) {
boolean editMode = init(msg.getMessage("JWTAuthenticatorEditor.defaultName"), toEdit, forceNameEditable);
ComboBox<String> credential = new ComboBox<>();
credential.setCaption(msg.getMessage("JWTAuthenticatorEditor.signingCredential"));
credential.setEmptySelectionAllowed(false);
credential.setItems(credentials);
TextField ttl = new TextField();
ttl.setCaption(msg.getMessage("JWTAuthenticatorEditor.tokenTTL"));
configBinder = new Binder<>(JWTConfiguration.class);
configBinder.forField(credential).asRequired(msg.getMessage("fieldRequired")).bind("credential");
configBinder.forField(ttl).asRequired(msg.getMessage("fieldRequired")).withConverter(new StringToIntegerConverter(msg.getMessage("notAPositiveNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 0, null)).bind("ttl");
FormLayoutWithFixedCaptionWidth main = new FormLayoutWithFixedCaptionWidth();
main.setMargin(true);
main.addComponents(name);
main.addComponent(credential);
main.addComponent(ttl);
JWTConfiguration config = new JWTConfiguration();
if (!credentials.isEmpty()) {
config.setCredential(credentials.iterator().next());
}
if (editMode) {
config.fromProperties(toEdit.configuration, msg);
}
configBinder.setBean(config);
return main;
}
Aggregations