Convert \n in browser designer page
@@ -25,7 +25,7 @@ public final class MockLabel extends MockVisibleComponent {
// GWT label widget used to mock a Simple Label
private InlineHTML labelWidget;
- private String savedText; // Saved text, so if we change from
+ private String savedText = ""; // Saved text, so if we change from
// text to/from html we have the text
// to set
@@ -100,9 +100,15 @@ public final class MockLabel extends MockVisibleComponent {
private void setTextProperty(String text) {
savedText = text;
if (getPropertyValue(PROPERTY_NAME_HTMLFORMAT).equals("True")) {
- labelWidget.setHTML(SimpleHtmlSanitizer.sanitizeHtml(text).asString());
+ String sanitizedText = SimpleHtmlSanitizer.sanitizeHtml(text).asString();
+ if (sanitizedText != null) {
+ sanitizedText = sanitizedText.replaceAll("\\\\n", " ");
+ }
+ labelWidget.setHTML(sanitizedText);
} else {
- labelWidget.setText(text);
+ labelWidget.setHTML(text.replaceAll("&", "&amp;").replaceAll("<", "&lt;")
+ .replaceAll(">", "&gt;").replaceAll("\\\\n", "<br>")
+ );
}
}
