Search in sources :

Example 1 with MessageRow

use of org.linkki.framework.ui.component.MessageRow in project linkki by linkki-framework.

the class OkCancelDialogTest method displayingMessage.

private Matcher<OkCancelDialog> displayingMessage(String text) {
    return new TypeSafeMatcher<OkCancelDialog>() {

        @SuppressWarnings("null")
        @Override
        public void describeTo(Description description) {
            description.appendText("an OkCancelDialog displaying a message with the text '");
            description.appendText(text);
            description.appendText("'");
        }

        @SuppressWarnings("null")
        @Override
        protected boolean matchesSafely(OkCancelDialog dialog) {
            VerticalLayout layout = (VerticalLayout) dialog.getContent();
            VerticalLayout nestedLayout = (VerticalLayout) layout.getComponent(0);
            return components(nestedLayout).filter(MessageRow.class::isInstance).findFirst().map(c -> ((MessageRow) c).getText().equals(text)).orElse(false);
        }
    };
}
Also used : Description(org.hamcrest.Description) ErrorLevel(com.vaadin.server.ErrorMessage.ErrorLevel) VerticalLayout(com.vaadin.ui.VerticalLayout) Matchers.not(org.hamcrest.Matchers.not) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) Assert.assertThat(org.junit.Assert.assertThat) Button(com.vaadin.ui.Button) Stream(java.util.stream.Stream) Matchers.contains(org.hamcrest.Matchers.contains) ValidationMarker(org.linkki.util.validation.ValidationMarker) HorizontalLayout(com.vaadin.ui.HorizontalLayout) MessageRow(org.linkki.framework.ui.component.MessageRow) Matcher(org.hamcrest.Matcher) ValidationService(org.linkki.core.binding.validation.ValidationService) Label(com.vaadin.ui.Label) MessageList(org.linkki.core.message.MessageList) Matchers.is(org.hamcrest.Matchers.is) StreamSupport(java.util.stream.StreamSupport) Message(org.linkki.core.message.Message) ValidationDisplayState(org.linkki.core.binding.validation.ValidationDisplayState) Component(com.vaadin.ui.Component) TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) Description(org.hamcrest.Description) VerticalLayout(com.vaadin.ui.VerticalLayout)

Example 2 with MessageRow

use of org.linkki.framework.ui.component.MessageRow in project linkki by linkki-framework.

the class OkCancelDialog method addMessageRow.

private void addMessageRow(Message message) {
    MessageRow newRow = new MessageRow(message);
    // $NON-NLS-1$
    newRow.setWidth("100%");
    messageRow = Optional.of(newRow);
    contentArea.addComponent(newRow);
    contentArea.setExpandRatio(newRow, 0f);
    contentArea.setComponentAlignment(newRow, Alignment.MIDDLE_LEFT);
}
Also used : MessageRow(org.linkki.framework.ui.component.MessageRow)

Aggregations

MessageRow (org.linkki.framework.ui.component.MessageRow)2 ErrorLevel (com.vaadin.server.ErrorMessage.ErrorLevel)1 Button (com.vaadin.ui.Button)1 Component (com.vaadin.ui.Component)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Label (com.vaadin.ui.Label)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Stream (java.util.stream.Stream)1 StreamSupport (java.util.stream.StreamSupport)1 Description (org.hamcrest.Description)1 Matcher (org.hamcrest.Matcher)1 Matchers.contains (org.hamcrest.Matchers.contains)1 Matchers.is (org.hamcrest.Matchers.is)1 Matchers.not (org.hamcrest.Matchers.not)1 TypeSafeMatcher (org.hamcrest.TypeSafeMatcher)1 Assert.assertThat (org.junit.Assert.assertThat)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Test (org.junit.Test)1 ValidationDisplayState (org.linkki.core.binding.validation.ValidationDisplayState)1 ValidationService (org.linkki.core.binding.validation.ValidationService)1