Java Code Examples for com.intellij.xml.util.XmlStringUtil#stripHtml()

The following examples show how to use com.intellij.xml.util.XmlStringUtil#stripHtml() . These examples are extracted from open source projects. 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 Project: consulo   File: HighlightInfoComposite.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
private static String createCompositeTooltip(@Nonnull List<? extends HighlightInfo> infos) {
  StringBuilder result = new StringBuilder();
  for (HighlightInfo info : infos) {
    String toolTip = info.getToolTip();
    if (toolTip != null) {
      if (result.length() != 0) {
        result.append(LINE_BREAK);
      }
      toolTip = XmlStringUtil.stripHtml(toolTip);
      result.append(toolTip);
    }
  }
  if (result.length() == 0) {
    return null;
  }
  return XmlStringUtil.wrapInHtml(result);
}
 
Example 2
Source Project: consulo   File: HighlightInfo.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Encodes \p tooltip so that substrings equal to a \p description
 * are replaced with the special placeholder to reduce size of the
 * tooltip. If encoding takes place, <html></html> tags are
 * stripped of the tooltip.
 *
 * @param tooltip     - html text
 * @param description - plain text (not escaped)
 * @return encoded tooltip (stripped html text with one or more placeholder characters)
 * or tooltip without changes.
 */
private static String encodeTooltip(String tooltip, String description) {
  if (tooltip == null || description == null || description.isEmpty()) return tooltip;

  String encoded = StringUtil.replace(tooltip, XmlStringUtil.escapeString(description), DESCRIPTION_PLACEHOLDER);
  //noinspection StringEquality
  if (encoded == tooltip) {
    return tooltip;
  }
  if (encoded.equals(DESCRIPTION_PLACEHOLDER)) encoded = DESCRIPTION_PLACEHOLDER;
  return XmlStringUtil.stripHtml(encoded);
}
 
Example 3
Source Project: consulo   File: ProblemDescriptionNode.java    License: Apache License 2.0 5 votes vote down vote up
public String toString() {
  CommonProblemDescriptor descriptor = getDescriptor();
  if (descriptor == null) return "";
  PsiElement element = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor)descriptor).getPsiElement() : null;

  return XmlStringUtil.stripHtml(ProblemDescriptorUtil.renderDescriptionMessage(descriptor, element,
                                                                                APPEND_LINE_NUMBER | TRIM_AT_TREE_END));
}
 
Example 4
@RequiredUIAccess
@Override
public void reset() {
  final String text = (myTemplate == null) ? "" : myTemplate.getText();
  String name = (myTemplate == null) ? "" : myTemplate.getName();
  String extension = (myTemplate == null) ? "" : myTemplate.getExtension();
  String description = (myTemplate == null) ? "" : myTemplate.getDescription();

  if ((description.length() == 0) && (myDefaultDescriptionUrl != null)) {
    try {
      description = UrlUtil.loadText(myDefaultDescriptionUrl);
    }
    catch (IOException e) {
      LOG.error(e);
    }
  }

  EditorFactory.getInstance().releaseEditor(myTemplateEditor);
  myFile = createFile(text, name);
  myTemplateEditor = createEditor();

  myNameField.setText(name);
  myExtensionField.setText(extension);
  myAdjustBox.setSelected(myTemplate != null && myTemplate.isReformatCode());
  myLiveTemplateBox.setSelected(myTemplate != null && myTemplate.isLiveTemplateEnabled());

  int i = description.indexOf("<html>");
  if (i > 0) {
    description = description.substring(i);
  }
  description = XmlStringUtil.stripHtml(description);
  description = description.replace("\n", "").replace("\r", "");
  description = XmlStringUtil.stripHtml(description);
  description = description + "<hr> <font face=\"verdana\" size=\"-1\"><a href='http://velocity.apache.org/engine/devel/user-guide.html#Velocity_Template_Language_VTL:_An_Introduction'>\n" +
                "Apache Velocity</a> template language is used</font>";

  myDescriptionComponent.setText(description);
  myDescriptionComponent.setCaretPosition(0);

  myNameField.setEditable((myTemplate != null) && (!myTemplate.isDefault()));
  myExtensionField.setEditable((myTemplate != null) && (!myTemplate.isDefault()));
  myModified = false;
}