use of org.linkki.core.message.Message in project linkki by linkki-framework.
the class ReflectionPropertyDispatcherTest method testGetMessages_IgnoreIrrelevantMessages.
@Test
public void testGetMessages_IgnoreIrrelevantMessages() {
MessageList messageList = new MessageList();
Message msg1 = Message.builder(ABC, ErrorLevel.ERROR).invalidObjectWithProperties(new Object(), XYZ).create();
Message msg2 = Message.builder(ABC, ErrorLevel.ERROR).invalidObjectWithProperties(new Object(), ABC).create();
messageList.add(msg1);
messageList.add(msg2);
assertThat(setupPmoDispatcher(XYZ).getMessages(messageList), emptyMessageList());
assertThat(setupPmoDispatcher(ABC).getMessages(messageList), emptyMessageList());
assertThat(setupPmoDispatcher("invalidProperty").getMessages(messageList), emptyMessageList());
}
use of org.linkki.core.message.Message in project linkki by linkki-framework.
the class ValidationDisplayStateTest method testFilter.
@Test
public void testFilter() {
ValidationMarker mandatoryFieldMarker = () -> true;
ValidationMarker nonMandatoryFieldMarker = () -> false;
Message m1 = Message.builder("m1", ErrorLevel.ERROR).markers(mandatoryFieldMarker).create();
Message m2 = Message.builder("m2", ErrorLevel.ERROR).markers(nonMandatoryFieldMarker).create();
Message m3 = Message.builder("m3", ErrorLevel.ERROR).create();
MessageList messages = new MessageList(m1, m2, m3);
assertThat(SHOW_ALL.filter(messages), contains(m1, m2, m3));
assertThat(HIDE_MANDATORY_FIELD_VALIDATIONS.filter(messages), contains(m2, m3));
}
use of org.linkki.core.message.Message in project linkki by linkki-framework.
the class MessagesPanel method updateMessages.
public void updateMessages(MessageList messages) {
setVisible(!messages.isEmpty());
VerticalLayout layout = new VerticalLayout();
for (Message message : messages) {
Label messageLabel = new Label();
messageLabel.setIcon(getMessageIcon(message));
// tag::mandatory[]
String text = message.getText();
if (message.isMandatoryFieldMessage()) {
text += " *";
}
messageLabel.setCaption(text);
// end::mandatory[]
messageLabel.setContentMode(ContentMode.PREFORMATTED);
layout.addComponent(messageLabel);
}
setContent(layout);
}
Aggregations