use of com.vaadin.flow.component.textfield.TextField in project furms by unity-idm.
the class AlarmFormView method prepareValidator.
private void prepareValidator(TextField nameField, ComboBox<String> allocationComboBox, IntegerField thresholdField, Checkbox checkbox, MultiselectComboBox<String> multiselectComboBox) {
binder.forField(nameField).withValidator(value -> Objects.nonNull(value) && !value.isBlank(), getTranslation("view.project-admin.alarms.form.error.name")).bind(model -> model.name, (model, name) -> model.name = name);
binder.forField(allocationComboBox).withValidator(Objects::nonNull, getTranslation("view.project-admin.alarms.form.error.allocation")).bind(model -> model.allocationId, (model, id) -> model.allocationId = id);
binder.forField(thresholdField).withValidator(threshold -> threshold >= 1.0 && threshold <= 100.0, getTranslation("view.project-admin.alarms.form.error.threshold")).bind(model -> model.threshold, (model, threshold) -> model.threshold = threshold);
binder.forField(checkbox).bind(model -> model.allUsers, (model, value) -> model.allUsers = value);
binder.forField(multiselectComboBox).withValidator(emails -> emails.stream().noneMatch(email -> emailValidator.apply(email, new ValueContext()).isError()), getTranslation("view.project-admin.alarms.form.error.emails")).bind(model -> model.users, (model, policyFile) -> model.users = multiselectComboBox.getSelectedItems());
}
use of com.vaadin.flow.component.textfield.TextField in project furms by unity-idm.
the class SitesView method updateAction.
private void updateAction(Editor<SiteGridItem> siteEditor) {
if (siteEditor.getBinder().isValid()) {
Optional<Component> component = siteEditor.getGrid().getColumnByKey("name").getEditorComponent().getChildren().filter(c -> c instanceof TextField).findFirst();
if (component.isPresent()) {
TextField name = component.map(c -> (TextField) c).get();
try {
siteService.update(Site.builder().id(siteEditor.getItem().getId()).name(name.getValue()).build());
siteEditor.cancel();
refreshGrid(siteEditor);
showSuccessNotification(getTranslation("view.sites.form.save.success"));
} catch (DuplicatedNameValidationError e) {
name.setErrorMessage(getTranslation("view.sites.form.error.validation.field.name.unique"));
name.setInvalid(true);
} catch (RuntimeException e) {
LOG.warn("Could not update Site.", e);
showErrorNotification(getTranslation("view.sites.form.error.unexpected", "update"));
}
}
}
}
use of com.vaadin.flow.component.textfield.TextField in project furms by unity-idm.
the class ProjectsView method createSearchFilterLayout.
private HorizontalLayout createSearchFilterLayout() {
TextField textField = new TextField();
textField.setPlaceholder(getTranslation("view.user-settings.projects.field.search"));
textField.setPrefixComponent(SEARCH.create());
textField.setValueChangeMode(ValueChangeMode.EAGER);
textField.setClearButtonVisible(true);
textField.addValueChangeListener(event -> {
searchText = textField.getValue().toLowerCase();
textField.blur();
loadGridContent();
textField.focus();
});
HorizontalLayout search = new HorizontalLayout(textField);
search.setJustifyContentMode(FlexComponent.JustifyContentMode.END);
return search;
}
use of com.vaadin.flow.component.textfield.TextField in project psip-automation by bssw-psip.
the class Assessment method displaySaveDialog.
private void displaySaveDialog(String url) {
Dialog dialog = new Dialog();
dialog.setCloseOnOutsideClick(false);
dialog.setWidth("500px");
Label header = new Label("Copy this URL and paste into your browser to resume your assessment.");
TextField field = new TextField();
field.setValue(url);
Button copyButton = new Button(VaadinIcon.COPY.create());
ClipboardHelper helper = new ClipboardHelper(url, copyButton);
HorizontalLayout fieldLayout = new HorizontalLayout(field, helper);
fieldLayout.setMargin(false);
fieldLayout.setWidthFull();
fieldLayout.setFlexGrow(1, field);
Anchor closeButton = new Anchor();
closeButton.setText("Close");
closeButton.getElement().addEventListener("click", event -> {
dialog.close();
});
VerticalLayout dialogLayout = new VerticalLayout(header, fieldLayout, closeButton);
dialogLayout.setHorizontalComponentAlignment(Alignment.START, header, field);
dialogLayout.setHorizontalComponentAlignment(Alignment.CENTER, closeButton);
dialog.add(dialogLayout);
dialog.open();
}
use of com.vaadin.flow.component.textfield.TextField in project testbench by vaadin.
the class ComponentQueryTest method id_matchingComponent_getsComponent.
@Test
void id_matchingComponent_getsComponent() {
Element rootElement = getCurrentView().getElement();
List<TextField> textFields = IntStream.rangeClosed(1, 5).mapToObj(idx -> {
TextField field = new TextField();
field.setId("field-" + idx);
return field;
}).peek(field -> rootElement.appendChild(field.getElement())).collect(Collectors.toList());
ComponentQuery<TextField> query = $view(TextField.class);
textFields.forEach(field -> Assertions.assertSame(field, query.id(field.getId().orElse("")).getComponent()));
}
Aggregations