Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
b2faadee
Commit
b2faadee
authored
14 years ago
by
buczekp
Browse files
Options
Downloads
Patches
Plain Diff
minor: improve MultilineHTML to 'preserve' all whitespace (not only newlines)
SVN: 18172
parent
9213bf79
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/MultilineHTML.java
+9
-3
9 additions, 3 deletions
...lient/web/client/application/ui/widget/MultilineHTML.java
with
9 additions
and
3 deletions
openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/MultilineHTML.java
+
9
−
3
View file @
b2faadee
...
@@ -39,18 +39,24 @@ public final class MultilineHTML extends HTML
...
@@ -39,18 +39,24 @@ public final class MultilineHTML extends HTML
// Another way to implement this would be to preserve white-space:
// Another way to implement this would be to preserve white-space:
// getElement().getStyle().setProperty("whiteSpace", "pre");
// getElement().getStyle().setProperty("whiteSpace", "pre");
// but then too long lines would not fit in property grid with no word wrapping.
// 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/>
// So the only option is to replace newlines with <br/> and use ' ' for other
super
(
replaceNewlinesWithBRs
(
html
));
// whitespace characters.
super
(
preserveWhitespace
(
html
));
}
}
private
static
final
String
BR
=
DOM
.
toString
(
DOM
.
createElement
(
"br"
));
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
;
String
result
=
html
;
// to be independent of regexp implementation we have to replace newlines in two steps
// 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
);
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
// result will not be wrapped in AbstractBrowserGrid so we wrap it up in div with tooltip
return
wrapUpInDivWithTooltip
(
result
,
html
);
return
wrapUpInDivWithTooltip
(
result
,
html
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment