| | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import java.net.URLEncoder; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | |
| | | import org.opends.quicksetup.i18n.ResourceProvider; |
| | | import org.opends.quicksetup.ui.UIFactory; |
| | | import org.opends.quicksetup.Constants; |
| | | |
| | | /** |
| | | * This is an implementation of the ProgressMessageFormatter class that |
| | |
| | | */ |
| | | public class HtmlProgressMessageFormatter implements ProgressMessageFormatter |
| | | { |
| | | static private final Logger LOG = |
| | | Logger.getLogger(HtmlProgressMessageFormatter.class.getName()); |
| | | |
| | | private String doneHtml; |
| | | private String errorHtml; |
| | | |
| | | /** |
| | | * The line break in HTML. |
| | | */ |
| | | private static String LINE_BREAK = "<br>"; |
| | | |
| | | /** |
| | | * The constant used to separate parameters in an URL. |
| | | */ |
| | | private String PARAM_SEPARATOR = "&&&&"; |
| | |
| | | UIFactory.getIconHtml(UIFactory.IconType.INFORMATION_LARGE) + SPACE |
| | | + SPACE + UIFactory.applyFontToHtml(text, UIFactory.PROGRESS_FONT); |
| | | |
| | | String result = UIFactory.applySuccessfulBackgroundToHtml(html); |
| | | return result; |
| | | return UIFactory.applySuccessfulBackgroundToHtml(html); |
| | | } |
| | | |
| | | /** |
| | |
| | | Throwable root = ex.getCause(); |
| | | while (root != null) |
| | | { |
| | | stackBuf.append(getHtml(getMsg("exception-root-cause")) + LINE_BREAK); |
| | | stackBuf.append(getHtml(getMsg("exception-root-cause"))) |
| | | .append(Constants.HTML_LINE_BREAK); |
| | | stackBuf.append(getHtmlStack(root)); |
| | | root = root.getCause(); |
| | | } |
| | |
| | | if (msg != null) |
| | | { |
| | | buf.append(UIFactory.applyFontToHtml(getHtml(ex.getMessage()), |
| | | UIFactory.PROGRESS_ERROR_FONT) |
| | | + LINE_BREAK); |
| | | UIFactory.PROGRESS_ERROR_FONT)).append(Constants.HTML_LINE_BREAK); |
| | | } else |
| | | { |
| | | buf.append(ex.toString() + LINE_BREAK); |
| | | buf.append(ex.toString()).append(Constants.HTML_LINE_BREAK); |
| | | } |
| | | buf.append(getErrorWithStackHtml(openDiv, hideText, showText, stackText, |
| | | closeDiv, false)); |
| | |
| | | */ |
| | | public String getLineBreak() |
| | | { |
| | | return LINE_BREAK; |
| | | return Constants.HTML_LINE_BREAK; |
| | | } |
| | | |
| | | /** |
| | |
| | | int index = lastText.indexOf(urlText); |
| | | if (index == -1) |
| | | { |
| | | System.out.println("lastText: " + lastText); |
| | | System.out.println("does not contain: " + urlText); |
| | | LOG.log(Level.FINE, "lastText: " + lastText + |
| | | "does not contain: " + urlText); |
| | | } else |
| | | { |
| | | lastText = |
| | |
| | | { |
| | | if (i != 0) |
| | | { |
| | | buffer.append("<br>"); |
| | | buffer.append(Constants.HTML_LINE_BREAK); |
| | | } |
| | | buffer.append(escape(lines[i])); |
| | | } |
| | |
| | | { |
| | | StringBuilder buf = new StringBuilder(); |
| | | StackTraceElement[] stack = ex.getStackTrace(); |
| | | for (int i = 0; i < stack.length; i++) |
| | | { |
| | | buf.append(SPACE + SPACE + SPACE + SPACE + SPACE + SPACE + SPACE + |
| | | SPACE + SPACE + SPACE + getHtml(stack[i].toString()) + LINE_BREAK); |
| | | for (StackTraceElement aStack : stack) { |
| | | buf.append(SPACE) |
| | | .append(SPACE) |
| | | .append(SPACE) |
| | | .append(SPACE) |
| | | .append(SPACE) |
| | | .append(SPACE) |
| | | .append(SPACE) |
| | | .append(SPACE) |
| | | .append(SPACE) |
| | | .append(SPACE) |
| | | .append(getHtml(aStack.toString())) |
| | | .append(Constants.HTML_LINE_BREAK); |
| | | } |
| | | return buf.toString(); |
| | | } |
| | |
| | | try |
| | | { |
| | | String text = hide ? hideText : showText; |
| | | buf.append(openDiv + "<a href=\"http://").append( |
| | | URLEncoder.encode(params, "UTF-8") + "\">" + text + "</a>"); |
| | | buf.append(openDiv).append("<a href=\"http://") |
| | | .append(URLEncoder.encode(params, "UTF-8")) |
| | | .append("\">").append(text).append("</a>"); |
| | | if (hide) |
| | | { |
| | | buf.append(LINE_BREAK + stackText); |
| | | buf.append(Constants.HTML_LINE_BREAK).append(stackText); |
| | | } |
| | | buf.append(closeDiv); |
| | | |
| | |
| | | String showText, String stackText, String closeDiv, boolean hide) |
| | | { |
| | | StringBuilder buf = new StringBuilder(); |
| | | buf.append(openDiv + PARAM_SEPARATOR); |
| | | buf.append(hideText + PARAM_SEPARATOR); |
| | | buf.append(showText + PARAM_SEPARATOR); |
| | | buf.append(stackText + PARAM_SEPARATOR); |
| | | buf.append(closeDiv + PARAM_SEPARATOR); |
| | | buf.append(openDiv).append(PARAM_SEPARATOR); |
| | | buf.append(hideText).append(PARAM_SEPARATOR); |
| | | buf.append(showText).append(PARAM_SEPARATOR); |
| | | buf.append(stackText).append(PARAM_SEPARATOR); |
| | | buf.append(closeDiv).append(PARAM_SEPARATOR); |
| | | buf.append(hide); |
| | | return buf.toString(); |
| | | } |
| | |
| | | String showText = params[i++]; |
| | | String stackText = params[i++]; |
| | | String closeDiv = params[i++]; |
| | | boolean isHide = new Boolean(params[i]); |
| | | boolean isHide = Boolean.valueOf(params[i]); |
| | | |
| | | if (isHide) |
| | | { |