replaced duplicates

This commit is contained in:
Alexey Kudravtsev
2013-04-19 12:43:52 +04:00
parent e84e6246a0
commit 41c46d182e
43 changed files with 197 additions and 183 deletions
@@ -51,6 +51,7 @@ import com.intellij.util.PathUtil;
import com.intellij.util.PlatformIcons;
import com.intellij.util.download.DownloadableFileSetVersions;
import com.intellij.util.ui.RadioButtonEnumModel;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -374,7 +375,7 @@ public class LibraryOptionsPanel implements Disposable {
"name", 10));
}
((CardLayout)myConfigurationPanel.getLayout()).show(myConfigurationPanel, showConfigurePanel ? "configure" : "empty");
myMessageLabel.setText("<html>" + message + "</html>");
myMessageLabel.setText(XmlStringUtil.wrapInHtml(message));
}
private String getDownloadFilesMessage() {
@@ -23,6 +23,7 @@ import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.update.Activatable;
import com.intellij.util.ui.update.UiNotifyConnector;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -86,7 +87,7 @@ public class ArtifactErrorPanel {
public void showError(@NotNull String message, @NotNull List<? extends ConfigurationErrorQuickFix> quickFixes) {
myErrorLabel.setVisible(true);
final String errorText = "<html>" + message + "</html>";
final String errorText = XmlStringUtil.wrapInHtml(message);
if (myErrorLabel.isShowing()) {
myErrorLabel.setText(errorText);
}
@@ -31,6 +31,7 @@ import com.intellij.ui.treeStructure.SimpleNode;
import com.intellij.util.ArrayUtil;
import com.intellij.util.SmartList;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -60,7 +61,7 @@ public class PackagingElementNode<E extends PackagingElement<?>> extends Artifac
myPackagingElements.add(packagingElement);
}
@Nullable
@Nullable
public CompositePackagingElement<?> getParentElement(PackagingElement<?> element) {
return myParentElements.get(element);
}
@@ -105,13 +106,11 @@ public class PackagingElementNode<E extends PackagingElement<?>> extends Artifac
final String tooltip;
boolean isError = false;
try {
buffer.append("<html>");
for (ArtifactProblemDescription problem : problems) {
isError |= problem.getSeverity() == ProjectStructureProblemType.Severity.ERROR;
buffer.append(problem.getMessage(false)).append("<br>");
}
buffer.append("</html>");
tooltip = buffer.toString();
tooltip = XmlStringUtil.wrapInHtml(buffer);
}
finally {
StringBuilderSpinAllocator.dispose(buffer);
@@ -23,6 +23,7 @@ import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationManager;
import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.xml.util.XmlStringUtil;
import java.util.List;
@@ -60,6 +61,6 @@ class LibraryItem extends ClasspathTableItem<LibraryOrderEntry> {
final List<String> descriptions = LibraryPresentationManager.getInstance().getDescriptions(library, myContext);
if (descriptions.isEmpty()) return null;
return "<html>" + StringUtil.join(descriptions, "<br>") + "</html>";
return XmlStringUtil.wrapInHtml(StringUtil.join(descriptions, "<br>"));
}
}
@@ -36,6 +36,7 @@ import com.intellij.openapi.ui.NamedConfigurable;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.PathUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.InvocationHandler;
@@ -93,14 +94,12 @@ public class LibraryProjectStructureElement extends ProjectStructureElement {
private static String createInvalidRootsDescription(List<String> invalidClasses, String rootName, String libraryName) {
StringBuilder buffer = new StringBuilder();
buffer.append("<html>");
buffer.append("Library '").append(StringUtil.escapeXml(libraryName)).append("' has broken " + rootName + " " + StringUtil.pluralize("path", invalidClasses.size()) + ":");
for (String url : invalidClasses) {
buffer.append("<br>&nbsp;&nbsp;");
buffer.append(PathUtil.toPresentableUrl(url));
}
buffer.append("</html>");
return buffer.toString();
return XmlStringUtil.wrapInHtml(buffer);
}
@NotNull
@@ -134,7 +133,7 @@ public class LibraryProjectStructureElement extends ProjectStructureElement {
final Library source = realLibrary instanceof LibraryImpl? ((LibraryImpl)realLibrary).getSource() : null;
return source != null ? source : myLibrary;
}
@Override
public int hashCode() {
return System.identityHashCode(getSourceOrThis());
@@ -18,13 +18,13 @@ package com.intellij.refactoring.typeCook;
import com.intellij.openapi.help.HelpManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.PsiElement;
import com.intellij.refactoring.HelpID;
import com.intellij.refactoring.JavaRefactoringSettings;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.ui.RefactoringDialog;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.usageView.UsageViewUtil;
import com.intellij.xml.util.XmlStringUtil;
import javax.swing.*;
import java.awt.*;
@@ -56,7 +56,7 @@ public class TypeCookDialog extends RefactoringDialog {
init();
StringBuffer name = new StringBuffer("<html>");
StringBuffer name = new StringBuffer();
myElements = elements;
for (int i = 0; i < elements.length; i++) {
@@ -69,9 +69,7 @@ public class TypeCookDialog extends RefactoringDialog {
}
}
name.append("</html>");
myClassNameLabel.setText(name.toString());
myClassNameLabel.setText(XmlStringUtil.wrapInHtml(name));
}
protected JComponent createCenterPanel() {
@@ -30,6 +30,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiReference;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -100,13 +101,7 @@ public class ProblemsHolder {
assert vFile != null;
final String path = FileUtil.toSystemIndependentName(vFile.getPath());
String description = problem.getDescriptionTemplate();
if (description.startsWith("<html>")) {
description = description.replace("<html>", "").replace("</html>", "");
}
if (description.startsWith("<body>")) {
description = description.replace("<body>", "").replace("</body>", "");
}
String description = XmlStringUtil.stripHtml(problem.getDescriptionTemplate());
final String template =
InspectionsBundle.message("inspection.redirect.template",
@@ -111,13 +111,13 @@ public class HighlightInfo implements Segment {
String description = this.description;
if (toolTip == null || description == null || !toolTip.contains(DESCRIPTION_PLACEHOLDER)) return toolTip;
String decoded = toolTip.replace(DESCRIPTION_PLACEHOLDER, XmlStringUtil.escapeString(description));
String niceTooltip = wrapInHtml(decoded);
String niceTooltip = XmlStringUtil.wrapInHtml(decoded);
return niceTooltip;
}
private static String encodeTooltip(String toolTip, String description) {
if (toolTip == null || description == null) return toolTip;
String unescaped = StringUtil.unescapeXml(stripHtml(toolTip));
String unescaped = StringUtil.unescapeXml(XmlStringUtil.stripHtml(toolTip));
if (unescaped.contains(description)) {
String encoded = unescaped.replace(description, DESCRIPTION_PLACEHOLDER);
@@ -248,7 +248,7 @@ public class HighlightInfo implements Segment {
@Nullable
@NonNls
private static String htmlEscapeToolTip(@Nullable String unescapedTooltip) {
return unescapedTooltip == null ? null : wrapInHtml(XmlStringUtil.escapeString(unescapedTooltip));
return unescapedTooltip == null ? null : XmlStringUtil.wrapInHtml(XmlStringUtil.escapeString(unescapedTooltip));
}
@NotNull
@@ -844,26 +844,6 @@ public class HighlightInfo implements Segment {
return highlighter.getDocument().getText(TextRange.create(highlighter));
}
@NonNls private static final String HTML_HEADER = "<html>";
@NonNls private static final String BODY_HEADER = "<body>";
@NonNls private static final String HTML_FOOTER = "</html>";
@NonNls private static final String BODY_FOOTER = "</body>";
@NotNull
protected static String wrapInHtml(@NotNull CharSequence result) {
return HTML_HEADER + result + HTML_FOOTER;
}
@NotNull
protected static String stripHtml(@NotNull String toolTip) {
toolTip = StringUtil.trimStart(toolTip, HTML_HEADER);
toolTip = StringUtil.trimStart(toolTip, BODY_HEADER);
toolTip = StringUtil.trimEnd(toolTip, HTML_FOOTER);
toolTip = StringUtil.trimEnd(toolTip, BODY_FOOTER);
return toolTip;
}
// Deprecated methods for plugin compatibility
@@ -23,6 +23,7 @@ import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -84,13 +85,13 @@ public class HighlightInfoComposite extends HighlightInfo {
if (result.length() != 0) {
result.append(LINE_BREAK);
}
toolTip = stripHtml(toolTip);
toolTip = XmlStringUtil.stripHtml(toolTip);
result.append(toolTip);
}
}
if (result.length() == 0) {
return null;
}
return wrapInHtml(result);
return XmlStringUtil.wrapInHtml(result);
}
}
@@ -653,7 +653,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
if (!inspectionProfile.isToolEnabled(key, myFile)) return null;
HighlightInfoType type = new HighlightInfoType.HighlightInfoTypeImpl(level.getSeverity(element), level.getAttributesKey());
final String plainMessage = message.startsWith("<html>") ? StringUtil.unescapeXml(message.replaceAll("<[^>]*>", "")) : message;
final String plainMessage = message.startsWith("<html>") ? StringUtil.unescapeXml(XmlStringUtil.stripHtml(message).replaceAll("<[^>]*>", "")) : message;
@NonNls final String link = " <a "
+"href=\"#inspection/" + tool.getShortName() + "\""
+ (UIUtil.isUnderDarcula() ? " color=\"7AB4C9\" " : "")
@@ -663,10 +663,10 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
@NonNls String tooltip = null;
if (descriptor.showTooltip()) {
if (message.startsWith("<html>")) {
tooltip = HighlightInfo.wrapInHtml(HighlightInfo.stripHtml(message) + link);
tooltip = XmlStringUtil.wrapInHtml(XmlStringUtil.stripHtml(message) + link);
}
else {
tooltip = HighlightInfo.wrapInHtml(XmlStringUtil.escapeString(message) + link);
tooltip = XmlStringUtil.wrapInHtml(XmlStringUtil.escapeString(message) + link);
}
}
HighlightInfo highlightInfo = highlightInfoFromDescriptor(descriptor, type, plainMessage, tooltip,element);
@@ -28,6 +28,7 @@ import com.intellij.ui.JBColor;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.SideBorder;
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -387,7 +388,7 @@ class ParameterInfoComponent extends JPanel {
faultMap.put(highlightRange.getEndOffset(), endTag.length());
}
return "<html>" + labelText.toString() + "</html>";
return XmlStringUtil.wrapInHtml(labelText);
}
private String getTag(@NotNull final String tagValue) {
@@ -82,7 +82,7 @@ public class HTMLExporter {
buf.append("<hr>");
}
public static void writeFile(String folder, @NonNls String fileName, StringBuffer buf, final Project project) {
public static void writeFile(String folder, @NonNls String fileName, CharSequence buf, final Project project) {
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
final String fullPath = folder + File.separator + fileName;
@@ -39,6 +39,7 @@ import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
@@ -422,7 +423,7 @@ class Browser extends JPanel {
showEmpty();
return;
}
@NonNls StringBuffer page = new StringBuffer("<html>");
@NonNls StringBuffer page = new StringBuffer();
page.append("<table border='0' cellspacing='0' cellpadding='0' width='100%'>");
page.append("<tr><td colspan='2'>");
HTMLComposer.appendHeading(page, InspectionsBundle.message("inspection.tool.in.browser.id.title"));
@@ -446,9 +447,10 @@ class Browser extends JPanel {
page.append(UIUtil.getHtmlBody(description));
page.append("</td></tr></table>");
myHTMLViewer.setText(page.toString());
myHTMLViewer.setText(XmlStringUtil.wrapInHtml(page));
setupStyle();
} finally {
}
finally {
myCurrentEntity = null;
}
}
@@ -28,6 +28,7 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.containers.HashSet;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NonNls;
import javax.swing.*;
@@ -67,7 +68,7 @@ public class ConvertProjectDialog extends DialogWrapper {
myBackupDir = ProjectConversionUtil.getBackupDir(context.getProjectBaseDir());
myTextPane.setSize(new Dimension(350, Integer.MAX_VALUE));
StringBuilder message = new StringBuilder("<html>");
StringBuilder message = new StringBuilder();
if (myConversionRunners.size() == 1 && myConversionRunners.get(0).getProvider().getConversionDialogText(context) != null) {
message.append(myConversionRunners.get(0).getProvider().getConversionDialogText(context));
}
@@ -76,8 +77,7 @@ public class ConvertProjectDialog extends DialogWrapper {
ApplicationNamesInfo.getInstance().getFullProductName()));
}
message.append(IdeBundle.message("conversion.dialog.text.2", myBackupDir.getAbsolutePath()));
message.append("</html>");
Messages.configureMessagePaneUi(myTextPane, message.toString(), false);
Messages.configureMessagePaneUi(myTextPane, XmlStringUtil.wrapInHtml(message), false);
myTextPane.addHyperlinkListener(new HyperlinkListener() {
@Override
@@ -61,6 +61,7 @@ import com.intellij.usageView.UsageViewBundle;
import com.intellij.util.*;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.tree.TreeUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.jdom.Document;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -806,7 +807,7 @@ public class DependenciesPanel extends JPanel implements Disposable, DataProvide
return true;
}
});
final JEditorPane pane = new JEditorPane(UIUtil.HTML_MIME, "<html>" + buf.toString()+ "</html>");
final JEditorPane pane = new JEditorPane(UIUtil.HTML_MIME, XmlStringUtil.wrapInHtml(buf));
pane.setForeground(JBColor.foreground());
pane.setBackground(HintUtil.INFORMATION_COLOR);
pane.setOpaque(true);
@@ -36,6 +36,7 @@ import com.intellij.ui.NonFocusableCheckBox;
import com.intellij.usageView.UsageViewUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.xml.util.XmlStringUtil;
import com.intellij.xml.util.XmlTagUtilBase;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -78,7 +79,8 @@ public class RenameDialog extends RefactoringDialog {
createNewNameComponent();
init();
myNameLabel.setText("<html>" + XmlTagUtilBase.escapeString(RefactoringBundle.message("rename.0.and.its.usages.to", getFullName()), false) + "</html>");
myNameLabel.setText(XmlStringUtil.wrapInHtml(
XmlTagUtilBase.escapeString(RefactoringBundle.message("rename.0.and.its.usages.to", getFullName()), false)));
boolean toSearchInComments = isToSearchInCommentsForRename();
myCbSearchInComments.setSelected(toSearchInComments);
@@ -53,6 +53,7 @@ import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.text.DateFormatUtil;
import com.intellij.vcsUtil.VcsUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
@@ -145,13 +146,13 @@ class AnnotateStackTraceAction extends AnAction {
public String getToolTip(int line, Editor editor) {
final VcsFileRevision revision = cache.get(line);
if (revision != null) {
return "<html>" +
revision.getAuthor() +
" " +
DateFormatUtil.formatDateTime(revision.getRevisionDate()) +
"<br/>" +
revision.getCommitMessage() +
"</html>";
return XmlStringUtil.wrapInHtml(
revision.getAuthor() +
" " +
DateFormatUtil.formatDateTime(revision.getRevisionDate()) +
"<br/>" +
revision.getCommitMessage()
);
}
return null;
}
@@ -22,7 +22,7 @@
*/
package com.intellij.openapi.ui;
import org.jetbrains.annotations.NonNls;
import com.intellij.xml.util.XmlStringUtil;
import javax.swing.*;
import java.awt.*;
@@ -37,17 +37,11 @@ public class PanelWithText extends JPanel {
public PanelWithText(String text) {
super(new GridBagLayout());
setBorder(BorderFactory.createEtchedBorder());
myLabel.setText(wrapText(text));
myLabel.setText(XmlStringUtil.wrapInHtml(text));
add(myLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(8,8,8,8), 0, 0));
}
private static String wrapText(final String text) {
@NonNls String opentTag = "<html>";
@NonNls String closeTag = "</html>";
return opentTag + text + closeTag;
}
public void setText(String text){
myLabel.setText(wrapText(text));
myLabel.setText(XmlStringUtil.wrapInHtml(text));
}
}
@@ -15,6 +15,7 @@
*/
package com.intellij.ui.components.labels;
import com.intellij.xml.util.XmlStringUtil;
import org.intellij.lang.annotations.JdkConstants;
import javax.swing.*;
@@ -54,6 +55,8 @@ public class BoldLabel extends JLabel {
private static String toHtml(String text) {
if (text.startsWith("<html>")) return text;
return "<html><b>" + text.replaceAll("\\n", "<br>") + "</b></html>";
return XmlStringUtil.wrapInHtml(
"<b>" + text.replaceAll("\\n", "<br>") + "</b>"
);
}
}
@@ -16,12 +16,20 @@
package com.intellij.xml.util;
import com.intellij.openapi.util.text.StringUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author yole
*/
public class XmlStringUtil {
@NonNls private static final String HTML_HEADER = "<html>";
@NonNls private static final String BODY_HEADER = "<body>";
@NonNls private static final String HTML_FOOTER = "</html>";
@NonNls private static final String BODY_FOOTER = "</body>";
private XmlStringUtil() {
}
@@ -32,4 +40,18 @@ public class XmlStringUtil {
public static String escapeString(@Nullable String str, final boolean escapeWhiteSpace) {
return XmlTagUtilBase.escapeString(str, escapeWhiteSpace);
}
@NotNull
public static String wrapInHtml(@NotNull CharSequence result) {
return HTML_HEADER + result + HTML_FOOTER;
}
@NotNull
public static String stripHtml(@NotNull String toolTip) {
toolTip = StringUtil.trimStart(toolTip, HTML_HEADER);
toolTip = StringUtil.trimStart(toolTip, BODY_HEADER);
toolTip = StringUtil.trimEnd(toolTip, HTML_FOOTER);
toolTip = StringUtil.trimEnd(toolTip, BODY_FOOTER);
return toolTip;
}
}
@@ -38,6 +38,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Consumer;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NonNls;
import javax.swing.*;
@@ -143,7 +144,7 @@ public class ITNReporter extends ErrorReportSubmitter {
login = "idea_anonymous";
password = "guest";
}
ErrorReportSender.sendError(project, login, password, errorBean, new Consumer<Integer>() {
@SuppressWarnings({"AssignmentToStaticFieldFromInstanceMethod"})
@Override
@@ -156,20 +157,20 @@ public class ITNReporter extends ErrorReportSubmitter {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
StringBuilder text = new StringBuilder("<html>");
StringBuilder text = new StringBuilder();
final String url = IdeErrorsDialog.getUrl(reportInfo, true);
IdeErrorsDialog.appendSubmissionInformation(reportInfo, text, url);
text.append(".");
if (reportInfo.getStatus() != SubmittedReportInfo.SubmissionStatus.FAILED) {
text.append("<br/>").append(DiagnosticBundle.message("error.report.gratitude"));
}
text.append("</html>");
NotificationType type = reportInfo.getStatus() == SubmittedReportInfo.SubmissionStatus.FAILED
? NotificationType.ERROR
: NotificationType.INFORMATION;
NotificationListener listener = url != null ? new NotificationListener.UrlOpeningListener(true) : null;
ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT,
text.toString(),
XmlStringUtil.wrapInHtml(text),
type, listener).setImportant(false).notify(project);
}
});
@@ -45,6 +45,7 @@ import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.DateFormatUtil;
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -536,8 +537,7 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene
return;
}
StringBuilder text = new StringBuilder("<html>");
String url = null;
StringBuilder text = new StringBuilder();
PluginId pluginId = findPluginId(throwable);
if (pluginId == null || ApplicationInfoEx.getInstanceEx().isEssentialPlugin(pluginId.getIdString())) {
if (throwable instanceof AbstractMethodError) {
@@ -554,6 +554,7 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene
DateFormatUtil.formatPrettyDateTime(message.getDate()),
myMergedMessages.get(myIndex).size()));
String url = null;
if (message.isSubmitted()) {
final SubmittedReportInfo info = message.getSubmissionInfo();
url = getUrl(info, getSubmitter(throwable) instanceof ITNReporter);
@@ -566,7 +567,7 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene
else if (!message.isRead()) {
text.append(" ").append(DiagnosticBundle.message("error.list.message.unread"));
}
myInfoLabel.setHtmlText(text.toString());
myInfoLabel.setHtmlText(XmlStringUtil.wrapInHtml(text));
myInfoLabel.setHyperlinkTarget(url);
}
@@ -35,6 +35,7 @@ import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import com.intellij.util.net.IOExceptionDialog;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -181,7 +182,7 @@ public class ActionInstallPlugin extends AnAction implements DumbAware {
private static boolean suggestToEnableInstalledPlugins(final InstalledPluginsTableModel pluginsModel,
final Set<IdeaPluginDescriptor> disabled,
final Set<IdeaPluginDescriptor> disabledDependants,
final Set<IdeaPluginDescriptor> disabledDependants,
final ArrayList<PluginNode> list) {
if (!disabled.isEmpty() || !disabledDependants.isEmpty()) {
String message = "<html><body>";
@@ -261,26 +262,28 @@ public class ActionInstallPlugin extends AnAction implements DumbAware {
private static void notifyPluginsWereInstalled(@Nullable String pluginName) {
final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
final boolean restartCapable = app.isRestartCapable();
String message = "<html>";
message += restartCapable ? IdeBundle.message("message.idea.restart.required", ApplicationNamesInfo.getInstance().getFullProductName())
: IdeBundle.message("message.idea.shutdown.required", ApplicationNamesInfo.getInstance().getFullProductName());
String message =
restartCapable ? IdeBundle.message("message.idea.restart.required", ApplicationNamesInfo.getInstance().getFullProductName())
: IdeBundle.message("message.idea.shutdown.required", ApplicationNamesInfo.getInstance().getFullProductName());
message += "<br><a href=";
message += restartCapable ? "\"restart\">Restart now" : "\"shutdown\">Shutdown";
message += "</a></html>";
Notifications.Bus.notify(new Notification("Plugins Lifecycle Group",
message += "</a>";
Notifications.Bus.notify(new Notification("Plugins Lifecycle Group",
pluginName != null ? "Plugin \'" + pluginName + "\' was successfully installed" : "Plugins were installed",
message, NotificationType.INFORMATION, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
notification.expire();
if (restartCapable) {
app.restart(true);
}
else {
app.exit(true);
}
}
}));
XmlStringUtil.wrapInHtml(message), NotificationType.INFORMATION,
new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification,
@NotNull HyperlinkEvent event) {
notification.expire();
if (restartCapable) {
app.restart(true);
}
else {
app.exit(true);
}
}
}));
}
@@ -23,6 +23,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.ui.Gray;
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.XmlStringUtil;
import javax.swing.*;
import java.awt.*;
@@ -41,7 +42,8 @@ public class DarculaWelcomeScreenButtonBase {
description.setUI(DarculaWelcomeScreenLabelUI.createUI(description));
//icon.setIcon(action.getTemplatePresentation().getIcon());
final String text = action.getTemplatePresentation().getDescription();
final String html = "<html>" + MessageFormat.format(text, ApplicationNamesInfo.getInstance().getFullProductName()) + "</html>";
final String html = XmlStringUtil
.wrapInHtml(MessageFormat.format(text, ApplicationNamesInfo.getInstance().getFullProductName()));
root.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
description.setText(html);
description.setForeground(Gray._200);
@@ -19,6 +19,7 @@ import com.intellij.notification.Notification;
import com.intellij.notification.NotificationListener;
import com.intellij.openapi.ui.MessageType;
import com.intellij.ui.JBColor;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -36,7 +37,7 @@ public class NotificationsUtil {
}
public static String buildHtml(@NotNull final Notification notification, @Nullable String style) {
String result = "<html>";
String result = "";
if (style != null) {
result += "<div style=\"" + style + "\">";
}
@@ -44,8 +45,7 @@ public class NotificationsUtil {
if (style != null) {
result += "</div>";
}
result += "</html>";
return result;
return XmlStringUtil.wrapInHtml(result);
}
@Nullable
@@ -70,7 +70,7 @@ public class NotificationsUtil {
if (icon != null) {
return icon;
}
switch (notification.getType()) {
case ERROR:
return MessageType.ERROR.getDefaultIcon();
@@ -23,6 +23,7 @@ import com.intellij.ui.BrowserHyperlinkListener;
import com.intellij.ui.LicensingFacade;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -84,7 +85,7 @@ public class NewChannelDialog extends DialogWrapper {
}
private void initInfo() {
StringBuilder builder = new StringBuilder().append("<html>");
StringBuilder builder = new StringBuilder();
builder.append("<head>").append(UIUtil.getCssFontDeclaration(UIUtil.getLabelFont())).append("</head><body>");
builder.append("<b>").append(myChannel.getName()).append("</b><br>");
builder.append(StringUtil.formatLinks(myChannel.getLatestBuild().getMessage())).append("<br><br>");
@@ -108,7 +109,7 @@ public class NewChannelDialog extends DialogWrapper {
builder.append("The new version has an expiration date and does not require a license key.");
}
}
myInformationText = builder.toString();
myInformationText = XmlStringUtil.wrapInHtml(builder);
}
@Override
@@ -38,10 +38,10 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.WelcomeScreen;
import com.intellij.ui.*;
import com.intellij.ui.components.JBPanel;
import com.intellij.util.PlatformUtils;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.EmptyIcon;
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
@@ -99,8 +99,6 @@ public class DefaultWelcomeScreen implements WelcomeScreen {
private static final Color BUTTON_POPPED_COLOR = UIUtil.isUnderDarcula() ? Gray.get(WELCOME_PANEL_BACKGROUND.getRed() + 10) : Gray._241;
private static final Color BUTTON_PUSHED_COLOR = UIUtil.isUnderDarcula() ? Gray.get(WELCOME_PANEL_BACKGROUND.getRed() + 5) : Gray._228;
@NonNls private static final String HTML_PREFIX = "<html>";
@NonNls private static final String HTML_SUFFIX = "</html>";
@NonNls private static final String ___HTML_SUFFIX = "...</html>";
@NonNls private static final String ESC_NEW_LINE = "\\n";
@@ -117,7 +115,7 @@ public class DefaultWelcomeScreen implements WelcomeScreen {
private int mySelectedColumn = -1;
private int mySelectedGroup = -1;
private int myPluginsIdx = -1;
private JComponent myRecentProjectsPanel;
public JPanel getWelcomePanel() {
@@ -555,13 +553,7 @@ public class DefaultWelcomeScreen implements WelcomeScreen {
if (!StringUtil.isEmpty(description)) {
//noinspection ConstantConditions
description = description.trim();
if (description.startsWith(HTML_PREFIX)) {
description = description.replaceAll(HTML_PREFIX, "");
if (description.endsWith(HTML_SUFFIX)) {
description = description.replaceAll(HTML_SUFFIX, "");
}
}
description = XmlStringUtil.stripHtml(description.trim());
description = description.replaceAll(ESC_NEW_LINE, "");
String shortenedDcs = adjustStringBreaksByWidth(description, TEXT_FONT, false, PLUGIN_DSC_MAX_WIDTH, PLUGIN_DSC_MAX_ROWS);
JLabel pluginDescription = new JLabel(shortenedDcs);
@@ -598,7 +590,7 @@ public class DefaultWelcomeScreen implements WelcomeScreen {
final int maxRows) {
string = string.trim();
if (StringUtil.isEmpty(string)) {
return "<html>" + UIBundle.message("welcome.screen.text.not.specified.message") + "</html>";
return XmlStringUtil.wrapInHtml(UIBundle.message("welcome.screen.text.not.specified.message"));
}
string = string.replaceAll("<li>", " <>&gt; ");
@@ -672,7 +664,7 @@ public class DefaultWelcomeScreen implements WelcomeScreen {
string = prefix + suffix;
}
string = string.replaceAll(" <>", "<br>");
return HTML_PREFIX + string + HTML_SUFFIX;
return XmlStringUtil.wrapInHtml(string);
}
@SuppressWarnings({"HardCodedStringLiteral"})
@@ -729,17 +721,13 @@ public class DefaultWelcomeScreen implements WelcomeScreen {
gBC = new GridBagConstraints(1, y, 1, 1, 0, 0, SOUTHWEST, NONE, ACTION_NAME_INSETS, 5, 0);
myPanel.add(name, gBC);
description = wrapWithHtml(description);
description = XmlStringUtil.wrapInHtml(description);
JLabel shortDescription = new JLabel(description);
shortDescription.setFont(TEXT_FONT);
gBC = new GridBagConstraints(1, y + 1, 1, 1, 0, 0, NORTHWEST, HORIZONTAL, ACTION_DESCRIPTION_INSETS, 5, 0);
myPanel.add(shortDescription, gBC);
}
private String wrapWithHtml(final String description) {
return HTML_PREFIX + description + HTML_SUFFIX;
}
private void appendActionsFromGroup(final ActionGroup group) {
final AnAction[] actions = group.getChildren(null);
PresentationFactory factory = new PresentationFactory();
@@ -1203,7 +1203,7 @@ public class StringUtil extends StringUtilRt {
}
return result.toString();
}
@NotNull
public static <T> String join(@NotNull Iterable<T> items, @NotNull Function<T, String> f, @NotNull @NonNls String separator) {
final StringBuilder result = new StringBuilder();
@@ -44,6 +44,7 @@ import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.SeparatorFactory;
import com.intellij.util.NotNullFunction;
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -196,7 +197,7 @@ public class ChangeListViewerDialog extends DialogWrapper implements DataProvide
final String description = getDescription();
if (description != null) {
JPanel descPanel = new JPanel();
descPanel.add(new JLabel("<html>" + description + "</html>"));
descPanel.add(new JLabel(XmlStringUtil.wrapInHtml(description)));
descPanel.setBorder(BorderFactory.createEtchedBorder());
mainPanel.add(descPanel, BorderLayout.NORTH);
}
@@ -31,6 +31,7 @@ import com.intellij.ui.table.JBTable;
import com.intellij.util.IconUtil;
import com.intellij.util.ui.ColumnInfo;
import com.intellij.util.ui.ListTableModel;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
@@ -65,8 +66,9 @@ public class IssueNavigationConfigurationPanel extends JPanel implements Searcha
myLinkTable = new JBTable();
myLinkTable.getEmptyText().setText(VcsBundle.message("issue.link.no.patterns"));
reset();
add(new JLabel("<html>" + ApplicationNamesInfo.getInstance().getFullProductName() + " will search for the specified patterns in " +
"checkin comments and link them to issues in your issue tracker:</html>"), BorderLayout.NORTH);
add(new JLabel(
XmlStringUtil.wrapInHtml(ApplicationNamesInfo.getInstance().getFullProductName() + " will search for the specified patterns in " +
"checkin comments and link them to issues in your issue tracker:")), BorderLayout.NORTH);
add(
ToolbarDecorator.createDecorator(myLinkTable)
.setAddAction(new AnActionButtonRunnable() {
@@ -34,6 +34,7 @@ import com.intellij.ui.components.labels.LinkListener;
import com.intellij.ui.table.TableView;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.*;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -203,8 +204,9 @@ public class VcsDirectoryConfigurationPanel extends JPanel implements Configurab
public VcsDirectoryConfigurationPanel(final Project project) {
myProject = project;
myVcsConfiguration = getInstance(myProject);
myProjectMessage = "<html>" + StringUtil.escapeXml(VcsDirectoryMapping.PROJECT_CONSTANT) + " - " +
DefaultVcsRootPolicy.getInstance(myProject).getProjectConfigurationMessage(myProject).replace('\n', ' ') + "</html>";
myProjectMessage = XmlStringUtil.wrapInHtml(StringUtil.escapeXml(VcsDirectoryMapping.PROJECT_CONSTANT) + " - " +
DefaultVcsRootPolicy.getInstance(myProject).getProjectConfigurationMessage(myProject)
.replace('\n', ' '));
myIsDisabled = myProject.isDefault();
myVcsManager = ProjectLevelVcsManager.getInstance(project);
final VcsDescriptor[] vcsDescriptors = myVcsManager.getAllVcss();
@@ -34,6 +34,7 @@ import com.intellij.openapi.vcs.impl.VcsDescriptor;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.components.JBLabel;
import com.intellij.util.continuation.ModalityIgnorantBackgroundableTask;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -173,7 +174,7 @@ public class VcsMappingConfigurationDialog extends DialogWrapper {
}
public void initProjectMessage() {
myProjectButtonComment.setText("<html>" + DefaultVcsRootPolicy.getInstance(myProject).getProjectConfigurationMessage(myProject) + "</html>");
myProjectButtonComment.setText(XmlStringUtil.wrapInHtml(DefaultVcsRootPolicy.getInstance(myProject).getProjectConfigurationMessage(myProject)));
}
private class MyBrowseFolderListener extends ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> {
@@ -182,7 +183,7 @@ public class VcsMappingConfigurationDialog extends DialogWrapper {
FileChooserDescriptor fileChooserDescriptor) {
super(title, description, textField, project, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
}
@Override
protected VirtualFile getInitialFile() {
// suggest project base dir only if nothing is typed in the component.
@@ -17,6 +17,7 @@ package com.siyeh.ig.inheritance;
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import com.intellij.psi.*;
import com.intellij.xml.util.XmlStringUtil;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
@@ -47,8 +48,8 @@ public class RefusedBequestInspection extends BaseInspection {
public JComponent createOptionsPanel() {
//noinspection HardCodedStringLiteral
return new SingleCheckboxOptionsPanel(
"<html>" + InspectionGadgetsBundle.message("refused.bequest.ignore.empty.super.methods.option") +
"</html>", this, "ignoreEmptySuperMethods");
XmlStringUtil.wrapInHtml(InspectionGadgetsBundle.message("refused.bequest.ignore.empty.super.methods.option"))
, this, "ignoreEmptySuperMethods");
}
@Override
@@ -22,6 +22,7 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.components.JBLabel;
import com.intellij.util.ArrayUtil;
import com.intellij.xml.util.XmlStringUtil;
import git4idea.GitBranch;
import git4idea.GitPlatformFacade;
import git4idea.history.browser.GitCommit;
@@ -50,7 +51,7 @@ import java.util.Map;
public class GitBranchIsNotFullyMergedDialog extends DialogWrapper {
private static final Logger LOG = Logger.getInstance(GitBranchIsNotFullyMergedDialog.class);
private final Project myProject;
private final Map<GitRepository, List<GitCommit>> myCommits;
private final String myBranchToDelete;
@@ -74,7 +75,7 @@ public class GitBranchIsNotFullyMergedDialog extends DialogWrapper {
public static boolean showAndGetAnswer(@NotNull Project project,
@NotNull Map<GitRepository, List<GitCommit>> commits,
@NotNull String branchToDelete,
@NotNull List<String> mergedToBranches,
@NotNull List<String> mergedToBranches,
@Nullable String baseBranch) {
GitBranchIsNotFullyMergedDialog dialog = new GitBranchIsNotFullyMergedDialog(project, commits, branchToDelete, baseBranch, mergedToBranches);
ServiceManager.getService(project, GitPlatformFacade.class).showDialog(dialog);
@@ -122,7 +123,7 @@ public class GitBranchIsNotFullyMergedDialog extends DialogWrapper {
LOG.assertTrue(myBaseBranch != null, "Branches have unexpectedly diverged");
currentBranchOrRev = myBaseBranch;
onBranch = true;
}
}
else {
GitRepository repository = myInitialRepository;
if (repository.isOnBranch()) {
@@ -136,7 +137,7 @@ public class GitBranchIsNotFullyMergedDialog extends DialogWrapper {
onBranch = false;
}
}
StringBuilder description = new StringBuilder();
if (onBranch) {
description.append(GitBundle.message("branch.delete.not_fully_merged.description", myBranchToDelete, myBaseBranch));
@@ -160,8 +161,8 @@ public class GitBranchIsNotFullyMergedDialog extends DialogWrapper {
@Override
protected JComponent createNorthPanel() {
JBLabel descriptionLabel = new JBLabel("<html>" + makeDescription() + "</html>");
JBLabel descriptionLabel = new JBLabel(XmlStringUtil.wrapInHtml(makeDescription()));
final JComboBox repositorySelector = new JComboBox(ArrayUtil.toObjectArray(myRepositories, GitRepository.class));
repositorySelector.setRenderer(new GitRepositoryComboboxListCellRenderer(repositorySelector));
repositorySelector.setSelectedItem(myInitialRepository);
@@ -178,7 +179,7 @@ public class GitBranchIsNotFullyMergedDialog extends DialogWrapper {
label.setLabelFor(repoSelectorPanel);
repoSelectorPanel.add(label, BorderLayout.WEST);
repoSelectorPanel.add(repositorySelector);
if (myRepositories.size() < 2) {
repoSelectorPanel.setVisible(false);
}
@@ -29,6 +29,7 @@ import com.intellij.openapi.vcs.changes.ui.SelectFilesDialog;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.components.JBLabel;
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.XmlStringUtil;
import git4idea.*;
import git4idea.commands.Git;
import git4idea.history.browser.GitCommit;
@@ -46,8 +47,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.intellij.openapi.util.text.StringUtil.stripHtml;
/**
* @author Kirill Likhodedov
*/
@@ -92,12 +91,12 @@ class GitBranchUiHandlerImpl implements GitBranchUiHandler {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
StringBuilder description = new StringBuilder("<html>");
StringBuilder description = new StringBuilder();
if (!StringUtil.isEmptyOrSpaces(message)) {
description.append(message).append("<br/>");
}
description.append(rollbackProposal).append("</html>");
ok.set(Messages.OK == MessageManager.showYesNoDialog(myProject, description.toString(), title,
description.append(rollbackProposal);
ok.set(Messages.OK == MessageManager.showYesNoDialog(myProject, XmlStringUtil.wrapInHtml(description), title,
"Rollback", "Don't rollback", Messages.getErrorIcon()));
}
});
@@ -154,7 +153,7 @@ class GitBranchUiHandlerImpl implements GitBranchUiHandler {
String title = "Couldn't " + operationName;
String description = UntrackedFilesNotifier.createUntrackedFilesOverwrittenDescription(operationName, false);
final SelectFilesDialog dialog = new UntrackedFilesDialog(myProject, untrackedFiles, stripHtml(description, true), rollbackProposal);
final SelectFilesDialog dialog = new UntrackedFilesDialog(myProject, untrackedFiles, StringUtil.stripHtml(description, true), rollbackProposal);
dialog.setTitle(title);
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
@@ -217,7 +216,7 @@ class GitBranchUiHandlerImpl implements GitBranchUiHandler {
protected JComponent createSouthPanel() {
JComponent buttons = super.createSouthPanel();
JPanel panel = new JPanel(new VerticalFlowLayout());
panel.add(new JBLabel("<html>" + myRollbackProposal + "</html>"));
panel.add(new JBLabel(XmlStringUtil.wrapInHtml(myRollbackProposal)));
panel.add(buttons);
return panel;
}
@@ -35,6 +35,7 @@ import com.intellij.openapi.vcs.checkin.VcsCheckinHandlerFactory;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.PairConsumer;
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.XmlStringUtil;
import git4idea.GitPlatformFacade;
import git4idea.GitUtil;
import git4idea.GitVcs;
@@ -61,7 +62,7 @@ import java.util.concurrent.atomic.AtomicReference;
* @author Kirill Likhodedov
*/
public class GitCheckinHandlerFactory extends VcsCheckinHandlerFactory {
private static final Logger LOG = Logger.getInstance(GitCheckinHandlerFactory.class);
public GitCheckinHandlerFactory() {
@@ -89,7 +90,7 @@ public class GitCheckinHandlerFactory extends VcsCheckinHandlerFactory {
if (emptyCommitMessage()) {
return ReturnResult.CANCEL;
}
if (commitOrCommitAndPush(executor)) {
ReturnResult result = checkUserName();
if (result != ReturnResult.COMMIT) {
@@ -195,7 +196,7 @@ public class GitCheckinHandlerFactory extends VcsCheckinHandlerFactory {
// doing nothing - let commit with possibly empty user.name/email
}
}
if (notDefined.isEmpty()) {
return ReturnResult.COMMIT;
}
@@ -255,14 +256,14 @@ public class GitCheckinHandlerFactory extends VcsCheckinHandlerFactory {
}
return ReturnResult.CLOSE_WINDOW;
}
@NotNull
private Pair<String, String> getUserNameAndEmailFromGitConfig(@NotNull Project project, @NotNull VirtualFile root) throws VcsException {
String name = GitConfigUtil.getValue(project, root, GitConfigUtil.USER_NAME);
String email = GitConfigUtil.getValue(project, root, GitConfigUtil.USER_EMAIL);
return Pair.create(name, email);
}
private boolean emptyCommitMessage() {
if (myPanel.getCommitMessage().trim().isEmpty()) {
Messages.showMessageDialog(myPanel.getComponent(), GitBundle.message("git.commit.message.empty"),
@@ -297,8 +298,9 @@ public class GitCheckinHandlerFactory extends VcsCheckinHandlerFactory {
readMore("http://sitaramc.github.com/concepts/detached-head.html", "Read more about detached HEAD");
}
final int choice = Messages.showOkCancelDialog(myPanel.getComponent(), "<html>" + message + "</html>", title,
"Cancel", "Commit", Messages.getWarningIcon());
final int choice = Messages.showOkCancelDialog(myPanel.getComponent(), XmlStringUtil.wrapInHtml(message), title,
"Cancel", "Commit",
Messages.getWarningIcon());
if (choice == 1) {
return ReturnResult.COMMIT;
} else {
@@ -26,6 +26,7 @@ import com.intellij.ui.components.JBLabel;
import com.intellij.util.SystemProperties;
import com.intellij.util.ui.GridBag;
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -53,7 +54,7 @@ class GitUserNameNotDefinedDialog extends DialogWrapper {
private JBCheckBox myGlobalCheckbox;
GitUserNameNotDefinedDialog(@NotNull Project project,
@NotNull Collection<VirtualFile> rootsWithUndefinedProps,
@NotNull Collection<VirtualFile> rootsWithUndefinedProps,
@NotNull Collection<VirtualFile> allRootsAffectedByCommit,
@NotNull Map<VirtualFile, Pair<String, String>> rootsWithDefinedProps) {
super(project, false);
@@ -64,7 +65,7 @@ class GitUserNameNotDefinedDialog extends DialogWrapper {
setTitle("Git User Name Is Not Defined");
setOKButtonText("Set and Commit");
init();
}
@@ -103,10 +104,10 @@ class GitUserNameNotDefinedDialog extends DialogWrapper {
@Override
protected JComponent createCenterPanel() {
JLabel icon = new JLabel(UIUtil.getWarningIcon(), SwingConstants.LEFT);
JLabel description = new JLabel(getMessageText());
myNameTextField = new JTextField(20);
JBLabel nameLabel = new JBLabel("Name: ");
nameLabel.setDisplayedMnemonic('n');
@@ -133,7 +134,7 @@ class GitUserNameNotDefinedDialog extends DialogWrapper {
.setDefaultInsets(new Insets(0, 0, DEFAULT_VGAP, DEFAULT_HGAP))
.setDefaultAnchor(GridBagConstraints.LINE_START)
.setDefaultFill(GridBagConstraints.HORIZONTAL);
rootPanel.add(description, g.nextLine().next().coverLine(3).pady(DEFAULT_HGAP));
rootPanel.add(icon, g.nextLine().next().coverColumn(3));
rootPanel.add(nameLabel, g.next().fillCellNone().insets(new Insets(0, 6, DEFAULT_VGAP, DEFAULT_HGAP)));
@@ -159,7 +160,7 @@ class GitUserNameNotDefinedDialog extends DialogWrapper {
for (VirtualFile root : myRootsWithUndefinedProps) {
text += root.getPresentableUrl() + "<br/>";
}
return "<html>" + text + "</html>";
return XmlStringUtil.wrapInHtml(text);
}
public String getUserName() {
@@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.execution.HgCommandResult;
@@ -69,9 +70,9 @@ public final class HgCommandResultNotifier {
"Failure title, failure description and errors log can not be empty at the same time");
errorMessage = failureDescription;
} else if (failureDescription.isEmpty()) {
errorMessage = "<html>" + StringUtil.join(err, "<br>") + "</html>";
errorMessage = XmlStringUtil.wrapInHtml(StringUtil.join(err, "<br>"));
} else {
errorMessage = "<html>" + failureDescription + "<br>" + StringUtil.join(err, "<br>") + "</html>";
errorMessage = XmlStringUtil.wrapInHtml(failureDescription + "<br>" + StringUtil.join(err, "<br>"));
}
}
IMPORTANT_ERROR_NOTIFICATION
@@ -24,6 +24,7 @@ import com.intellij.openapi.vcs.AbstractVcs;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.zmlx.hg4idea.*;
@@ -135,21 +136,21 @@ public class HgRemoteStatusUpdater implements HgUpdater {
return myProjectSettings.isCheckIncomingOutgoing();
}
private final class ChangesetFormatter implements HgChangesetStatus.ChangesetWriter {
private final StringBuilder builder = new StringBuilder();
private static final class ChangesetFormatter implements HgChangesetStatus.ChangesetWriter {
private final String string;
private ChangesetFormatter(HgChangesetStatus status, List<HgRevisionNumber> changesets) {
builder.append("<html>");
StringBuilder builder = new StringBuilder();
builder.append("<b>").append(status.getStatusName()).append(" changesets</b>:<br>");
for (HgRevisionNumber revisionNumber : changesets) {
builder.append(revisionNumber.asString()).append(" ").append(revisionNumber.getCommitMessage()).append(" (")
.append(revisionNumber.getAuthor()).append(")<br>");
}
builder.append("</html>");
string = XmlStringUtil.wrapInHtml(builder);
}
public String asString() {
return builder.toString();
return string;
}
}
}
@@ -40,6 +40,7 @@ import com.intellij.ui.components.JBLabel;
import com.intellij.util.PairProcessor;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.AsyncProcessIcon;
import com.intellij.xml.util.XmlStringUtil;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -87,8 +88,10 @@ public class RepositoryAttachDialog extends DialogWrapper {
myProject = project;
myManaged = managed;
myProgressIcon.suspend();
myCaptionLabel.setText("<html>" + StringUtil.escapeXml("enter keyword, pattern or class name to search by or Maven coordinates," +
"i.e. 'springframework', 'Logger' or 'org.hibernate:hibernate-core:3.5.0.GA':") + "</html>");
myCaptionLabel.setText(
XmlStringUtil.wrapInHtml(StringUtil.escapeXml("enter keyword, pattern or class name to search by or Maven coordinates," +
"i.e. 'springframework', 'Logger' or 'org.hibernate:hibernate-core:3.5.0.GA':")
));
myInfoLabel.setPreferredSize(
new Dimension(myInfoLabel.getFontMetrics(myInfoLabel.getFont()).stringWidth("Showing: 1000"), myInfoLabel.getPreferredSize().height));
@@ -22,6 +22,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.tasks.Comment;
import com.intellij.tasks.Task;
import com.intellij.xml.util.XmlStringUtil;
import com.petebevin.markdown.MarkdownProcessor;
import org.jetbrains.annotations.Nullable;
@@ -48,7 +49,7 @@ public class TaskDocumentationProvider extends AbstractDocumentationProvider imp
public String generateDoc(PsiElement element, @Nullable PsiElement originalElement) {
if (!(element instanceof TaskPsiElement)) return null;
final Task task = ((TaskPsiElement)element).getTask();
final StringBuilder builder = new StringBuilder("<html>");
final StringBuilder builder = new StringBuilder();
builder.append("<b>Summary:</b> ").append(task.getSummary()).append("<br>");
builder.append("<b>Id:</b> ").append(task.getId()).append("<br>");
if (task.getCreated() != null) {
@@ -65,8 +66,7 @@ public class TaskDocumentationProvider extends AbstractDocumentationProvider imp
for (Comment comment : task.getComments()) {
comment.appendTo(builder);
}
builder.append("</html>");
return builder.toString();
return XmlStringUtil.wrapInHtml(builder);
}
@Override
@@ -28,6 +28,7 @@ import com.intellij.util.PlatformIcons;
import com.intellij.util.ui.ColumnInfo;
import com.intellij.util.ui.ListTableModel;
import com.intellij.util.ui.UIUtil;
import com.intellij.xml.util.XmlStringUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -98,7 +99,7 @@ public abstract class AbstractTableView<T> extends JPanel implements TypeSafeDat
myInnerPanel.add(ScrollPaneFactory.createScrollPane(myTable), TREE);
if (getEmptyPaneText() != null) {
//noinspection HardCodedStringLiteral
myEmptyPane = new EmptyPane("<html>" + getEmptyPaneText() + "</html>");
myEmptyPane = new EmptyPane(XmlStringUtil.wrapInHtml(getEmptyPaneText()));
final JComponent emptyPanel = myEmptyPane.getComponent();
myInnerPanel.add(emptyPanel, EMPTY_PANE);
}
@@ -25,6 +25,7 @@ import com.intellij.psi.xml.XmlElement;
import com.intellij.psi.xml.XmlTag;
import com.intellij.xml.XmlAttributeDescriptor;
import com.intellij.xml.XmlElementDescriptor;
import com.intellij.xml.util.XmlStringUtil;
import org.intellij.plugins.relaxNG.model.descriptors.CompositeDescriptor;
import org.intellij.plugins.relaxNG.model.descriptors.RngElementDescriptor;
import org.intellij.plugins.relaxNG.model.descriptors.RngXmlAttributeDescriptor;
@@ -95,11 +96,11 @@ public class RngDocumentationProvider implements DocumentationProvider {
private static String makeDocumentation(StringBuilder sb) {
if (sb == null) return null;
if (!sb.toString().startsWith("<html>")) {
sb.insert(0, "<html>");
sb.append("</html>");
String s = sb.toString().replaceAll("\n", "<br>");
if (!s.startsWith("<html>")) {
s = XmlStringUtil.wrapInHtml(s);
}
return sb.toString().replaceAll("\n", "<br>");
return s;
}
private static StringBuilder getDocumentationFromTag(XmlTag tag, String localName, String kind) {