Java Code Examples for com.intellij.openapi.util.text.StringUtil#escapeXml()

The following examples show how to use com.intellij.openapi.util.text.StringUtil#escapeXml() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShowUsagesAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private static List<UsageNode> collectData(@Nonnull List<Usage> usages,
                                           @Nonnull Collection<UsageNode> visibleNodes,
                                           @Nonnull UsageViewImpl usageView,
                                           @Nonnull UsageViewPresentation presentation) {
  @Nonnull List<UsageNode> data = new ArrayList<>();
  int filtered = filtered(usages, usageView);
  if (filtered != 0) {
    data.add(createStringNode(UsageViewBundle.message("usages.were.filtered.out", filtered)));
  }
  data.addAll(visibleNodes);
  if (data.isEmpty()) {
    String progressText = StringUtil.escapeXml(UsageViewManagerImpl.getProgressTitle(presentation));
    data.add(createStringNode(progressText));
  }
  Collections.sort(data, USAGE_NODE_COMPARATOR);
  return data;
}
 
Example 2
Source File: UIVcsUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static JPanel infoPanel(final String header, final String text) {
  final JLabel label = new JLabel("<html><body><h4>" + StringUtil.escapeXml(header) +
                                  "</h4>" + escapeXmlAndAddBr(text) + "</body></html>");
  final JPanel wrapper = new JPanel(new GridBagLayout());
  wrapper.add(label, new GridBagConstraints(0,0,1,1,0,0,GridBagConstraints.CENTER, GridBagConstraints.NONE,
                                                       new Insets(1,1,1,1), 0,0));
  return wrapper;
}
 
Example 3
Source File: HighlightHandlerBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static String getLineTextErrorStripeTooltip(Document document, int offset, boolean escape) {
  final int lineNumber = document.getLineNumber(offset);
  int lineStartOffset = document.getLineStartOffset(lineNumber);
  int lineEndOffset = document.getLineEndOffset(lineNumber);
  int lineFragmentEndOffset = Math.min(lineStartOffset + 140, lineEndOffset);
  String lineText = document.getText().substring(lineStartOffset, lineFragmentEndOffset);
  if (lineFragmentEndOffset != lineEndOffset) {
    lineText = lineText.trim() + "...";
  }
  return "  " + (escape ? StringUtil.escapeXml(lineText.trim()) : lineText.trim()) + "  ";
}
 
Example 4
Source File: LibraryProjectStructureElement.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public ProjectStructureProblemDescription createUnusedElementWarning() {
  final List<ConfigurationErrorQuickFix> fixes = Arrays.asList(new AddLibraryToDependenciesFix(), new RemoveLibraryFix());
  return new ProjectStructureProblemDescription("Library '" + StringUtil.escapeXml(myLibrary.getName()) + "'" + " is not used", null, createPlace(),
                                                ProjectStructureProblemType.unused("unused-library"), ProjectStructureProblemDescription.ProblemLevel.PROJECT,
                                                fixes, false);
}
 
Example 5
Source File: Bookmark.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
  StringBuilder result = new StringBuilder(getQualifiedName());
  String description = StringUtil.escapeXml(getNotEmptyDescription());
  if (description != null) {
    result.append(": ").append(description);
  }
  return result.toString();
}
 
Example 6
Source File: Bookmark.java    From consulo with Apache License 2.0 5 votes vote down vote up
private String getBookmarkTooltip() {
  StringBuilder result = new StringBuilder("Bookmark");
  if (myMnemonic != 0) {
    result.append(" ").append(myMnemonic);
  }
  String description = StringUtil.escapeXml(getNotEmptyDescription());
  if (description != null) {
    result.append(": ").append(description);
  }
  return result.toString();
}
 
Example 7
Source File: HoverHyperlinkLabel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@NonNls private static String underlineTextInHtml(final String text) {
  return "<html><u>" + StringUtil.escapeXml(text) + "</u></html>";
}
 
Example 8
Source File: UIVcsUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static String escapeXmlAndAddBr(String text) {
  String escaped = StringUtil.escapeXml(text);
  escaped = StringUtil.replace(escaped, "\n", "<br/>");
  return escaped;
}