diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/MultilineHTML.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/MultilineHTML.java index 0806a834fb77e798dd762ca7adea29f18188b31b..85cb6c3f72f8bdc38e68daa1dad54ff5125669cb 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/MultilineHTML.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/MultilineHTML.java @@ -39,18 +39,24 @@ public final class MultilineHTML extends HTML // Another way to implement this would be to preserve white-space: // getElement().getStyle().setProperty("whiteSpace", "pre"); // but then too long lines would not fit in property grid with no word wrapping. - // So the only option is to replace newlines with <br/> - super(replaceNewlinesWithBRs(html)); + // So the only option is to replace newlines with <br/> and use ' ' for other + // whitespace characters. + super(preserveWhitespace(html)); } private static final String BR = DOM.toString(DOM.createElement("br")); - private static String replaceNewlinesWithBRs(String html) + private static String preserveWhitespace(String html) { String result = html; // to be independent of regexp implementation we have to replace newlines in two steps result = result.replaceAll("\n\r", BR); result = result.replaceAll("[\n\r]", BR); + // additionally preserve remaining whitespace (tabs and spaces) using ' ' + // the trick is not to change all whitespace to make word wrapping possible + result = result.replaceAll("\t", " "); + result = result.replaceAll("[\t]", " "); + result = result.replaceAll(" ", " "); // result will not be wrapped in AbstractBrowserGrid so we wrap it up in div with tooltip return wrapUpInDivWithTooltip(result, html); }