| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011 ForgeRock AS |
| | | * Portions Copyright 2011-2012 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.util; |
| | |
| | | import java.util.Date; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | import javax.naming.CompositeName; |
| | | import javax.naming.InvalidNameException; |
| | |
| | | { |
| | | StringBuilder buf = new StringBuilder(); |
| | | |
| | | buf.append("font-family:" + font.getName()).append( |
| | | ";font-size:" + font.getSize() + "pt"); |
| | | buf.append("font-family:").append(font.getName()) |
| | | .append(";font-size:").append(font.getSize()).append("pt"); |
| | | |
| | | if (font.isItalic()) |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Strings any potential "separator" from a given string. |
| | | * @param s string to strip |
| | | * @param separator the separator string to remove |
| | | * @return resulting string |
| | | */ |
| | | public static String stripStringToSingleLine(String s, String separator) |
| | | { |
| | | String o = null; |
| | | if (s != null) |
| | | { |
| | | o = s.replaceAll(separator, ""); |
| | | } |
| | | return o; |
| | | } |
| | | |
| | | /* The pattern for control characters */ |
| | | private static Pattern cntrl_pattern = |
| | | Pattern.compile("\\p{Cntrl}", Pattern.MULTILINE); |
| | | |
| | | /** |
| | | * Checks if a string contains control characters. |
| | | * @param s : the string to check |
| | | * @return true if s contains control characters, false otherwise |
| | | */ |
| | | public static Boolean hasControlCharaters(String s) |
| | | { |
| | | Matcher m = cntrl_pattern.matcher(s); |
| | | return m.find(); |
| | | } |
| | | |
| | | /** |
| | | * This is a helper method that gets a String representation of the elements |
| | | * in the Collection. The String will display the different elements separated |
| | | * by the separator String. |
| | |
| | | { |
| | | msg.append(separator); |
| | | } |
| | | msg.append(m); |
| | | msg.append(stripStringToSingleLine(m, separator)); |
| | | } |
| | | return msg.toString(); |
| | | } |
| | |
| | | Message details, Font detailsFont) |
| | | { |
| | | StringBuilder buf = new StringBuilder(); |
| | | String space = " "; |
| | | buf.append(UIFactory.getIconHtml(UIFactory.IconType.ERROR_LARGE) + space |
| | | + space + applyFont(title.toString(), titleFont)); |
| | | buf.append(UIFactory.getIconHtml(UIFactory.IconType.ERROR_LARGE)) |
| | | .append(HTML_SPACE).append(HTML_SPACE) |
| | | .append(applyFont(title.toString(), titleFont)); |
| | | if (details != null) |
| | | { |
| | | buf.append("<br><br>") |
| | |
| | | Message details, Font detailsFont) |
| | | { |
| | | StringBuilder buf = new StringBuilder(); |
| | | String space = " "; |
| | | buf.append(UIFactory.getIconHtml(UIFactory.IconType.INFORMATION_LARGE) + |
| | | space + space + applyFont(title.toString(), titleFont)); |
| | | buf.append(UIFactory.getIconHtml(UIFactory.IconType.INFORMATION_LARGE)) |
| | | .append(HTML_SPACE).append(HTML_SPACE) |
| | | .append(applyFont(title.toString(), titleFont)); |
| | | if (details != null) |
| | | { |
| | | buf.append("<br><br>") |
| | |
| | | Message details, Font detailsFont) |
| | | { |
| | | StringBuilder buf = new StringBuilder(); |
| | | String space = " "; |
| | | buf.append(UIFactory.getIconHtml(UIFactory.IconType.WARNING_LARGE) + space |
| | | + space + applyFont(title.toString(), titleFont)); |
| | | buf.append(UIFactory.getIconHtml(UIFactory.IconType.WARNING_LARGE)) |
| | | .append(HTML_SPACE).append(HTML_SPACE) |
| | | .append(applyFont(title.toString(), titleFont)); |
| | | if (details != null) |
| | | { |
| | | buf.append("<br><br>") |
| | |
| | | Message details, Font detailsFont) |
| | | { |
| | | StringBuilder buf = new StringBuilder(); |
| | | String space = " "; |
| | | buf.append(UIFactory.getIconHtml(UIFactory.IconType.WARNING_LARGE) + |
| | | space + space + applyFont(title.toString(), titleFont)); |
| | | buf.append(UIFactory.getIconHtml(UIFactory.IconType.WARNING_LARGE)) |
| | | .append(HTML_SPACE).append(HTML_SPACE) |
| | | .append(applyFont(title.toString(), titleFont)); |
| | | if (details != null) |
| | | { |
| | | buf.append("<br><br>") |
| | |
| | | { |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | for (int i=0; i<pos.size(); i++) |