mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-08 18:30:42 +00:00
Update ErrorNotification
This commit is contained in:
parent
d09345259a
commit
c554f5e9f3
@ -1,5 +1,6 @@
|
||||
package edu.kit.typicalc.view.main;
|
||||
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.dependency.CssImport;
|
||||
import com.vaadin.flow.component.details.Details;
|
||||
@ -24,6 +25,8 @@ public class ErrorNotification extends Notification {
|
||||
private static final String NOTIFICATION_CONTENT_ID = "errorNotificationContent";
|
||||
private static final String ADDITIONAL_INFO_ID = "additionalInfo";
|
||||
private static final String ERROR_SUMMARY_ID = "errorSummary";
|
||||
|
||||
private static final int NO_ADDITIONAL_INFO = -1;
|
||||
|
||||
/**
|
||||
* Creates a new ErrorNotification with a specific error.
|
||||
@ -42,20 +45,23 @@ public class ErrorNotification extends Notification {
|
||||
setId(NOTIFICATION_ID);
|
||||
}
|
||||
|
||||
private Details buildErrorMessage(ParseError error) {
|
||||
private Component buildErrorMessage(ParseError error) {
|
||||
VerticalLayout additionalInformation = new VerticalLayout();
|
||||
additionalInformation.setId(ADDITIONAL_INFO_ID);
|
||||
Paragraph summary = new Paragraph(getTranslation("root." + error.toString()));
|
||||
summary.setId(ERROR_SUMMARY_ID);
|
||||
Details errorMessage = new Details(summary, additionalInformation);
|
||||
|
||||
if (error == ParseError.TOO_FEW_TOKENS) {
|
||||
additionalInformation.add(new Span(getTranslation("root.tooFewTokensHelp")));
|
||||
} else {
|
||||
additionalInformation.add(new Span(getTranslation("root.wrongCharacter") + error.getCause().getText()));
|
||||
additionalInformation.add(new Span(getTranslation("root.position") + error.getCause().getPos()));
|
||||
if (error.getCause().getPos() == NO_ADDITIONAL_INFO) {
|
||||
return summary;
|
||||
} else {
|
||||
additionalInformation.add(new Span(getTranslation("root.wrongCharacter") + error.getCause().getText()));
|
||||
additionalInformation.add(new Span(getTranslation("root.position") + error.getCause().getPos()));
|
||||
}
|
||||
}
|
||||
|
||||
return errorMessage;
|
||||
return new Details(summary, additionalInformation);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user