From efde227b9d0180122362133a750c6b322601c883 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Thu, 19 Jul 2007 20:28:20 +0000
Subject: [PATCH] This initial implementation lays most of the groundwork necessary for signaling information and actions to the user during upgrade and reversion. However the only public effect this code has on the current upgrade tool is an informational dialog dialog if an upgrade is attempted from a build prior to one of the issues (2049, 1582, 890).
---
opends/src/quicksetup/org/opends/quicksetup/util/Utils.java | 43 ++++++++++++++++++++++++++++++++-----------
1 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index d850a97..27c5846 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -1196,7 +1196,8 @@
* Inserts HTML break tags into <code>d</code> breaking it up
* so that ideally no line is longer than <code>maxll</code>
* assuming no single word is longer then <code>maxll</code>.
- * If the string already contains HTML line breaks, they are
+ * If the string already contains HTML tags that cause a line
+ * break (e.g break and closing list item tags) they are
* respected by this method when calculating where to place
* new breaks to control the maximum line length.
*
@@ -1210,18 +1211,29 @@
if (len <= 0)
return d;
if (len > maxll) {
- int p = d.lastIndexOf(Constants.HTML_LINE_BREAK, maxll);
- if (p > 0 && p < len) {
- return d.substring(0, p + Constants.HTML_LINE_BREAK.length()) +
- breakHtmlString(
- d.substring(p + Constants.HTML_LINE_BREAK.length()),
- maxll);
- } else {
- p = d.lastIndexOf(' ', maxll);
- if (p <= 0) {
- p = d.indexOf(' ', maxll);
+
+ // First see if there are any tags that would cause a
+ // natural break in the line. If so start line break
+ // point evaluation from that point.
+ for (String tag : Constants.BREAKING_TAGS) {
+ int p = d.lastIndexOf(tag, maxll);
+ if (p > 0 && p < len) {
+ return d.substring(0, p + tag.length()) +
+ breakHtmlString(
+ d.substring(p + tag.length()),
+ maxll);
}
}
+
+ // Now look for spaces in which to insert a break.
+ // First see if there are any spaces counting backward
+ // from the max line length. If there aren't any, then
+ // use the first space encountered after the max line
+ // lenght.
+ int p = d.lastIndexOf(' ', maxll);
+ if (p <= 0) {
+ p = d.indexOf(' ', maxll);
+ }
if (p > 0 && p < len) {
return d.substring(0, p) +
Constants.HTML_LINE_BREAK +
@@ -1235,6 +1247,15 @@
}
/**
+ * Converts existing HTML break tags to native line sparators.
+ * @param s string to convert
+ * @return converted string
+ */
+ static public String convertHtmlBreakToLineSeparator(String s) {
+ return s.replaceAll("\\<br\\>", Constants.LINE_SEPARATOR);
+ }
+
+ /**
* Strips any potential HTML markup from a given string.
* @param s string to strip
* @return resulting string
--
Gitblit v1.10.0