use of com.vaadin.flow.data.binder.StatusChangeEvent in project flow-components by vaadin.
the class EditorImplTest method save_editorIsOpened_editorIsInBufferedMode_beanIsInvalid_editorIsNotClosed.
@Test
public void save_editorIsOpened_editorIsInBufferedMode_beanIsInvalid_editorIsNotClosed() {
editor.getBinder().forField(new TextField()).withValidator(value -> !value.equals("bar"), "").bind(ValueProvider.identity(), (item, value) -> {
});
editor.editItem("bar");
fakeClientResponse();
editor.refreshedItems.clear();
editor.setBuffered(true);
AtomicReference<StatusChangeEvent> statusEventCapture = new AtomicReference<>();
AtomicReference<EditorEvent<String>> saveEventCapture = new AtomicReference<>();
AtomicReference<EditorEvent<String>> closeEventCapture = new AtomicReference<>();
Assert.assertFalse(doSave(statusEventCapture, saveEventCapture, closeEventCapture));
Assert.assertEquals(0, editor.refreshedItems.size());
Assert.assertNotNull(statusEventCapture.get());
Assert.assertNull(saveEventCapture.get());
Assert.assertNull(closeEventCapture.get());
Assert.assertTrue(statusEventCapture.get().hasValidationErrors());
}
use of com.vaadin.flow.data.binder.StatusChangeEvent in project karnak by OsiriX-Foundation.
the class DicomWorkListView method bindFields.
@SuppressWarnings("serial")
private void bindFields() {
binderForWorkListQuery.forField(callingAetFld).asRequired("Ce champ est obligatoire").bind(WorkListQueryData::getCallingAet, WorkListQueryData::setCallingAet);
binderForWorkListQuery.forField(workListAetFld).asRequired("Ce champ est obligatoire").bind(WorkListQueryData::getWorkListAet, WorkListQueryData::setWorkListAet);
binderForWorkListQuery.forField(workListHostnameFld).asRequired("Ce champ est obligatoire").bind(WorkListQueryData::getWorkListHostname, WorkListQueryData::setWorkListHostname);
binderForWorkListQuery.forField(workListPortFld).asRequired("Ce champ est obligatoire").withValidator(new IntegerRangeValidator("Le port est invalide", 1, 65535)).bind(WorkListQueryData::getWorkListPort, WorkListQueryData::setWorkListPort);
binderForWorkListQuery.bind(scheduledStationAetFld, WorkListQueryData::getScheduledStationAet, WorkListQueryData::setScheduledStationAet);
binderForWorkListQuery.bind(scheduledModalitySelector, WorkListQueryData::getScheduledModality, WorkListQueryData::setScheduledModality);
binderForWorkListQuery.bind(patientIdfld, WorkListQueryData::getPatientId, WorkListQueryData::setPatientId);
binderForWorkListQuery.bind(admissionIdFld, WorkListQueryData::getAdmissionId, WorkListQueryData::setAdmissionId);
binderForWorkListQuery.bind(scheduledFromFld, WorkListQueryData::getScheduledFrom, WorkListQueryData::setScheduledFrom);
binderForWorkListQuery.bind(scheduledToFld, WorkListQueryData::getScheduledTo, WorkListQueryData::setScheduledTo);
binderForWorkListQuery.bind(patientNameFld, WorkListQueryData::getPatientName, WorkListQueryData::setPatientName);
binderForWorkListQuery.bind(accessionNumberFld, WorkListQueryData::getAccessionNumber, WorkListQueryData::setAccessionNumber);
binderForWorkListQuery.readBean(workListQueryData);
binderForWorkListQuery.addStatusChangeListener(new StatusChangeListener() {
@Override
public void statusChange(StatusChangeEvent event) {
if (callingAetFld.isEmpty() || workListAetFld.isEmpty() || workListHostnameFld.isEmpty() || workListPortFld.isEmpty()) {
queryBtn.setEnabled(false);
} else {
queryBtn.setEnabled(!event.hasValidationErrors());
}
attributes.clear();
dataProviderForAttributes.refreshAll();
queryResultLayout.setVisible(false);
}
});
}
Aggregations