Java Code Examples for com.intellij.xml.util.XmlStringUtil

The following examples show how to use com.intellij.xml.util.XmlStringUtil. 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: Crucible4IDEA   Source File: CommentNodeRenderer.java    License: MIT License 6 votes vote down vote up
void setComment(final Comment comment) {
  String avatar = comment.getAuthor().getAvatar();
  Icon icon = AllIcons.Ide.Notification.WarningEvents;
  if (avatar != null) {
    try {
      icon = IconLoader.findIcon(new URL(avatar));
    }
    catch (MalformedURLException e) {
      LOG.warn(e);
    }
  }

  myIconLabel.setIcon(icon);
  myMessageLabel.setText(XmlStringUtil.wrapInHtml(comment.getMessage()));

  RoundedLineBorder roundedLineBorder = new RoundedLineBorder(comment.isDraft() ? DRAFT_BORDER_COLOR : COMMENT_BORDER_COLOR, 20, 2);
  Border marginBorder = BorderFactory.createEmptyBorder(0, 0, UIUtil.DEFAULT_VGAP, 0);
  myMainPanel.setBorder(BorderFactory.createCompoundBorder(marginBorder, roundedLineBorder));

  myMainPanel.setBackground(comment.isDraft() ? DRAFT_BG_COLOR : COMMENT_BG_COLOR);

  myPostLink.setVisible(comment.isDraft());
}
 
Example 2
Source Project: consulo   Source File: LineTooltipRenderer.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
private static String colorizeSeparators(@Nonnull String html) {
  String body = UIUtil.getHtmlBody(html);
  List<String> parts = StringUtil.split(body, UIUtil.BORDER_LINE, true, false);
  if (parts.size() <= 1) return html;
  StringBuilder b = new StringBuilder();
  for (String part : parts) {
    boolean addBorder = b.length() > 0;
    b.append("<div");
    if (addBorder) {
      b.append(" style='margin-top:6; padding-top:6; border-top: thin solid #");
      b.append(ColorUtil.toHex(UIUtil.getTooltipSeparatorColor()));
      b.append("'");
    }
    b.append("'>").append(part).append("</div>");
  }
  return XmlStringUtil.wrapInHtml(b.toString());
}
 
Example 3
Source Project: consulo   Source File: IncompatibleEncodingDialog.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
protected JComponent createCenterPanel() {
  JLabel label = new JLabel(XmlStringUtil.wrapInHtml("The encoding you've chosen ('" +
                                                     charset.displayName() +
                                                     "') may change the contents of '" +
                                                     virtualFile.getName() +
                                                     "'.<br>" +
                                                     "Do you want to<br>" +
                                                     "1. <b>Reload</b> the file from disk in the new encoding '" +
                                                     charset.displayName() +
                                                     "' and overwrite editor contents or<br>" +
                                                     "2. <b>Convert</b> the text and overwrite file in the new encoding" +
                                                     "?"));
  label.setIcon(Messages.getQuestionIcon());
  label.setIconTextGap(10);
  return label;
}
 
Example 4
Source Project: consulo   Source File: PluginManagerMain.java    License: Apache License 2.0 6 votes vote down vote up
public static void notifyPluginsWereUpdated(final String title, final Project project) {
  final ApplicationEx app = (ApplicationEx)Application.get();
  final boolean restartCapable = app.isRestartCapable();
  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>";
  new NotificationGroup("Plugins Lifecycle Group", NotificationDisplayType.STICKY_BALLOON, true)
          .createNotification(title, XmlStringUtil.wrapInHtml(message), NotificationType.INFORMATION, new NotificationListener() {
            @Override
            public void hyperlinkUpdate(@Nonnull Notification notification, @Nonnull HyperlinkEvent event) {
              notification.expire();
              if (restartCapable) {
                app.restart(true);
              }
              else {
                app.exit(true, true);
              }
            }
          }).notify(project);
}
 
Example 5
Source Project: consulo   Source File: PushController.java    License: Apache License 2.0 6 votes vote down vote up
public boolean ensureForcePushIsNeeded() {
  Collection<MyRepoModel<?, ?, ?>> selectedNodes = getSelectedRepoNode();
  MyRepoModel<?, ?, ?> selectedModel = ContainerUtil.getFirstItem(selectedNodes);
  if (selectedModel == null) return false;
  final PushSupport activePushSupport = selectedModel.getSupport();
  final PushTarget commonTarget = getCommonTarget(selectedNodes);
  if (commonTarget != null && activePushSupport.isSilentForcePushAllowed(commonTarget)) return true;
  return Messages.showOkCancelDialog(myProject, XmlStringUtil.wrapInHtml(DvcsBundle.message("push.force.confirmation.text",
                                                                                            commonTarget != null
                                                                                            ? " to <b>" +
                                                                                              commonTarget.getPresentation() + "</b>"
                                                                                            : "")),
                                     "Force Push", "&Force Push",
                                     CommonBundle.getCancelButtonText(),
                                     Messages.getWarningIcon(),
                                     commonTarget != null ? new MyDoNotAskOptionForPush(activePushSupport, commonTarget) : null) == OK;
}
 
Example 6
Source Project: consulo   Source File: VcsCommitInfoBalloon.java    License: Apache License 2.0 6 votes vote down vote up
public void updateCommitDetails() {
  if (myBalloon != null && myBalloon.isVisible()) {
    TreePath[] selectionPaths = myTree.getSelectionPaths();
    if (selectionPaths == null || selectionPaths.length != 1) {
      myBalloon.cancel();
    }
    else {
      Object node = selectionPaths[0].getLastPathComponent();
      myEditorPane.setText(
              XmlStringUtil.wrapInHtml(node instanceof TooltipNode ? ((TooltipNode)node).getTooltip().replaceAll("\n", "<br>") :
                                       EMPTY_COMMIT_INFO));
      //workaround: fix initial size for JEditorPane
      RepaintManager rp = RepaintManager.currentManager(myEditorPane);
      rp.markCompletelyDirty(myEditorPane);
      rp.validateInvalidComponents();
      rp.paintDirtyRegions();
      //
      myBalloon.setSize(myWrapper.getPreferredSize());
      myBalloon.setLocation(calculateBestPopupLocation());
    }
  }
}
 
Example 7
Source Project: consulo   Source 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 8
Source Project: consulo   Source File: DaemonTooltipActionProvider.java    License: Apache License 2.0 6 votes vote down vote up
private static IntentionAction getFirstAvailableAction(PsiFile psiFile, Editor editor, ShowIntentionsPass.IntentionsInfo intentionsInfo) {
  Project project = psiFile.getProject();

  //sort the actions
  CachedIntentions cachedIntentions = CachedIntentions.createAndUpdateActions(project, psiFile, editor, intentionsInfo);

  List<IntentionActionWithTextCaching> allActions = cachedIntentions.getAllActions();

  if (allActions.isEmpty()) return null;

  for (IntentionActionWithTextCaching it : allActions) {
    IntentionAction action = IntentionActionDelegate.unwrap(it.getAction());

    if (!(action instanceof AbstractEmptyIntentionAction) && action.isAvailable(project, editor, psiFile)) {
      String text = it.getText();
      //we cannot properly render html inside the fix button fixes with html text
      if (!XmlStringUtil.isWrappedInHtml(text)) {
        return action;
      }
    }
  }
  return null;
}
 
Example 9
public String composeTooltipMessage() {
  final StringBuilder buf = StringBuilderSpinAllocator.alloc();
  try {
    buf.append("<html><body>");
    if (myProblemDescriptions != null) {
      int problems = 0;
      for (ProjectStructureProblemDescription problemDescription : myProblemDescriptions) {
        buf.append(XmlStringUtil.escapeString(problemDescription.getMessage(false))).append("<br>");
        problems++;
        if (problems >= 10 && myProblemDescriptions.size() > 12) {
          buf.append(myProblemDescriptions.size() - problems).append(" more problems...<br>");
          break;
        }
      }
    }
    buf.append("</body></html>");
    return buf.toString();
  }
  finally {
    StringBuilderSpinAllocator.dispose(buf);
  }
}
 
Example 10
Source Project: consulo   Source File: ArtifactErrorPanel.java    License: Apache License 2.0 6 votes vote down vote up
public void showError(@Nonnull String message, @Nonnull List<? extends ConfigurationErrorQuickFix> quickFixes) {
  myErrorLabel.setVisible(true);
  final String errorText = XmlStringUtil.wrapInHtml(message);
  if (myErrorLabel.isShowing()) {
    myErrorLabel.setText(errorText);
  }
  else {
    myErrorText = errorText;
  }
  myMainPanel.setVisible(true);
  myCurrentQuickFixes = quickFixes;
  myFixButton.setVisible(!quickFixes.isEmpty());
  if (!quickFixes.isEmpty()) {
    myFixButton.setText(quickFixes.size() == 1 ? ContainerUtil.getFirstItem(quickFixes, null).getActionName() : "Fix...");
  }
}
 
Example 11
Source Project: consulo   Source File: PackagingElementNode.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void update(PresentationData presentation) {
  final Collection<ArtifactProblemDescription> problems = ((ArtifactEditorImpl)myContext.getThisArtifactEditor()).getValidationManager().getProblems(this);
  if (problems == null || problems.isEmpty()) {
    super.update(presentation);
    return;
  }
  StringBuilder buffer = StringBuilderSpinAllocator.alloc();
  final String tooltip;
  boolean isError = false;
  try {
    for (ArtifactProblemDescription problem : problems) {
      isError |= problem.getSeverity() == ProjectStructureProblemType.Severity.ERROR;
      buffer.append(problem.getMessage(false)).append("<br>");
    }
    tooltip = XmlStringUtil.wrapInHtml(buffer);
  }
  finally {
    StringBuilderSpinAllocator.dispose(buffer);
  }

  getElementPresentation().render(presentation, addErrorHighlighting(isError, SimpleTextAttributes.REGULAR_ATTRIBUTES),
                                  addErrorHighlighting(isError, SimpleTextAttributes.GRAY_ATTRIBUTES));
  presentation.setTooltip(tooltip);
}
 
Example 12
Source Project: consulo   Source File: LibraryClasspathTableItem.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public String getTooltipText() {
  final Library library = myEntry.getLibrary();
  if (library == null) return null;

  final String name = library.getName();
  if (name != null) {
    final List<String> invalidUrls = ((LibraryEx)library).getInvalidRootUrls(BinariesOrderRootType.getInstance());
    if (!invalidUrls.isEmpty()) {
      return ProjectBundle.message("project.roots.tooltip.library.has.broken.paths", name, invalidUrls.size());
    }
  }

  final List<String> descriptions = LibraryPresentationManager.getInstance().getDescriptions(library, myContext);
  if (descriptions.isEmpty()) return null;

  return XmlStringUtil.wrapInHtml(StringUtil.join(descriptions, "<br>"));
}
 
Example 13
@Override
public boolean validate() {
  final ValidationInfo info = validateSdk();
  if (info != null) {
    errorText.setText(XmlStringUtil.wrapInHtml(info.message));
  }
  errorIcon.setVisible(info != null);
  errorPane.setVisible(info != null);

  myInstallActionLink.setEnabled(info != null || getSdkComboPath().trim().isEmpty());

  return info == null;
}
 
Example 14
@Override
public boolean validate() {
  final ValidationInfo info = validateSdk();
  if (info != null) {
    errorText.setText(XmlStringUtil.wrapInHtml(info.message));
  }
  errorIcon.setVisible(info != null);
  errorPane.setVisible(info != null);

  myInstallActionLink.setEnabled(info != null || getSdkComboPath().trim().isEmpty());

  return info == null;
}
 
Example 15
Source Project: intellij   Source File: SyncDirectoriesWarning.java    License: Apache License 2.0 5 votes vote down vote up
/** Warns the user that sources may not resolve. Returns false if sync should be aborted. */
public static boolean warn(Project project) {
  if (warningSuppressed()) {
    return true;
  }
  String buildSystem = Blaze.buildSystemName(project);
  String message =
      String.format(
          "Syncing without a %s build will result in unresolved symbols "
              + "in your source files.<p>This can be useful for quickly adding directories to "
              + "your project, but if you're seeing sources marked as '(unsynced)', run a normal "
              + "%<s sync to fix it.",
          buildSystem);
  String title = String.format("Syncing without a %s build", buildSystem);
  DialogWrapper.DoNotAskOption dontAskAgain =
      new DialogWrapper.DoNotAskOption.Adapter() {
        @Override
        public void rememberChoice(boolean isSelected, int exitCode) {
          if (isSelected) {
            suppressWarning();
          }
        }

        @Override
        public String getDoNotShowMessage() {
          return "Don't warn again";
        }
      };
  int result =
      Messages.showOkCancelDialog(
          project,
          XmlStringUtil.wrapInHtml(message),
          title,
          "Run Sync",
          "Cancel",
          Messages.getWarningIcon(),
          dontAskAgain);
  return result == Messages.OK;
}
 
Example 16
public boolean validateInIntelliJ() {
    final ValidationInfo info = validate();

    if (info == null) {
        myErrorLabel.setVisible(false);
        return true;
    }
    else {
        myErrorLabel.setVisible(true);
        myErrorLabel.setText(XmlStringUtil.wrapInHtml("<font color='#" + ColorUtil.toHex(JBColor.RED) + "'><left>" + info.message + "</left></font>"));
    }
    return false;
}
 
Example 17
@Nullable
private Annotation createAnnotation(@NotNull HighlightSeverity severity, @NotNull TextRange range, @Nullable String message) {
    // Skip duplicate messages.
    if (!messages.add(message)) return null;
    String tooltip = message == null ? null : XmlStringUtil.wrapInHtml(escapeSpacesForHtml(XmlStringUtil.escapeString(message)));
    return holder.createAnnotation(severity, range, message, tooltip);
}
 
Example 18
Source Project: consulo-csharp   Source File: CC0001.java    License: Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
private static void appendType(@Nonnull StringBuilder builder, @Nonnull DotNetTypeRef typeRef, @Nonnull PsiElement scope)
{
	if(typeRef == DotNetTypeRef.ERROR_TYPE)
	{
		builder.append("?");
	}
	else
	{
		builder.append(XmlStringUtil.escapeString(CSharpTypeRefPresentationUtil.buildText(typeRef, scope)));
	}
}
 
Example 19
Source Project: intellij-haxe   Source File: HaxeAnnotation.java    License: Apache License 2.0 5 votes vote down vote up
public Annotation toAnnotation() {
  String tooltip = this.tooltip;
  if (null == tooltip && null != message && !message.isEmpty()) {
    tooltip = XmlStringUtil.wrapInHtml(XmlStringUtil.escapeString(message));
  }
  Annotation anno = new Annotation(range.getStartOffset(), range.getEndOffset(), severity, message, tooltip);

  for (IntentionAction action : intentions) {
    anno.registerFix(action);
  }
  return anno;
}
 
Example 20
Source Project: consulo   Source File: HighlightInfo.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
public String getToolTip() {
  String toolTip = this.toolTip;
  String description = this.description;
  if (toolTip == null || description == null || !toolTip.contains(DESCRIPTION_PLACEHOLDER)) return toolTip;
  String decoded = StringUtil.replace(toolTip, DESCRIPTION_PLACEHOLDER, XmlStringUtil.escapeString(description));
  return XmlStringUtil.wrapInHtml(decoded);
}
 
Example 21
Source Project: consulo   Source 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 22
Source Project: consulo   Source File: LineTooltipRenderer.java    License: Apache License 2.0 5 votes vote down vote up
public void addBelow(@Nonnull String text) {
  @NonNls String newBody;
  if (myText == null) {
    newBody = UIUtil.getHtmlBody(text);
  }
  else {
    String html1 = UIUtil.getHtmlBody(myText);
    String html2 = UIUtil.getHtmlBody(text);
    newBody = html1 + UIUtil.BORDER_LINE + html2;
  }
  myText = XmlStringUtil.wrapInHtml(newBody);
}
 
Example 23
Source Project: consulo   Source File: NotificationsUtil.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
public static String buildHtml(@Nullable String title,
                               @Nullable String subtitle,
                               @Nullable String content,
                               @Nullable String style,
                               @Nullable String titleColor,
                               @Nullable String contentColor,
                               @Nullable String contentStyle) {
  if (StringUtil.isEmpty(title) && !StringUtil.isEmpty(subtitle)) {
    title = subtitle;
    subtitle = null;
  }
  else if (!StringUtil.isEmpty(title) && !StringUtil.isEmpty(subtitle)) {
    title += ":";
  }

  StringBuilder result = new StringBuilder();
  if (style != null) {
    result.append("<div style=\"").append(style).append("\">");
  }
  if (!StringUtil.isEmpty(title)) {
    result.append("<b").append(titleColor == null ? ">" : " color=\"" + titleColor + "\">").append(title).append("</b>");
  }
  if (!StringUtil.isEmpty(subtitle)) {
    result.append("&nbsp;").append(titleColor == null ? "" : "<span color=\"" + titleColor + "\">").append(subtitle)
            .append(titleColor == null ? "" : "</span>");
  }
  if (!StringUtil.isEmpty(content)) {
    result.append("<p").append(contentStyle == null ? "" : " style=\"" + contentStyle + "\"")
            .append(contentColor == null ? ">" : " color=\"" + contentColor + "\">").append(content).append("</p>");
  }
  if (style != null) {
    result.append("</div>");
  }
  return XmlStringUtil.wrapInHtml(result.toString());
}
 
Example 24
Source Project: consulo   Source File: UndoApplyPatchDialog.java    License: Apache License 2.0 5 votes vote down vote up
@javax.annotation.Nullable
@Override
protected JComponent createCenterPanel() {
  final JPanel panel = new JPanel(new BorderLayout());
  int numFiles = myFailedFilePaths.size();
  JPanel labelsPanel = new JPanel(new BorderLayout());
  String detailedText = numFiles == 0 ? "" : String.format("Failed to apply %s below.<br>", StringUtil.pluralize("file", numFiles));
  final JLabel infoLabel = new JBLabel(XmlStringUtil.wrapInHtml(detailedText + "Would you like to rollback all applied?"));
  labelsPanel.add(infoLabel, BorderLayout.NORTH);
  if (myShouldInformAboutBinaries) {
    JLabel warningLabel = new JLabel("Rollback will not affect binaries");
    warningLabel.setIcon(AllIcons.General.BalloonWarning);
    labelsPanel.add(warningLabel, BorderLayout.CENTER);
  }
  panel.add(labelsPanel, BorderLayout.NORTH);
  if (numFiles > 0) {
    FilePathChangesTreeList browser = new FilePathChangesTreeList(myProject, myFailedFilePaths, false, false, null, null) {
      @Override
      public Dimension getPreferredSize() {
        return new Dimension(infoLabel.getPreferredSize().width, 50);
      }
    };
    browser.setChangesToDisplay(myFailedFilePaths);
    panel.add(ScrollPaneFactory.createScrollPane(browser), BorderLayout.CENTER);
  }
  return panel;
}
 
Example 25
Source Project: consulo   Source File: Browser.java    License: Apache License 2.0 5 votes vote down vote up
public void showDescription(@Nonnull InspectionToolWrapper toolWrapper){
  if (toolWrapper.getShortName().isEmpty()){
    showEmpty();
    return;
  }
  @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"));
  page.append("</td></tr>");
  page.append("<tr><td width='37'></td>" +
              "<td>");
  page.append(toolWrapper.getShortName());
  page.append("</td></tr>");
  page.append("<tr height='10'></tr>");
  page.append("<tr><td colspan='2'>");
  HTMLComposer.appendHeading(page, InspectionsBundle.message("inspection.tool.in.browser.description.title"));
  page.append("</td></tr>");
  page.append("<tr><td width='37'></td>" +
              "<td>");
  @NonNls final String underConstruction = "<b>" + UNDER_CONSTRUCTION + "</b></html>";
  try {
    @NonNls String description = toolWrapper.loadDescription();
    if (description == null) {
      description = underConstruction;
    }
    page.append(UIUtil.getHtmlBody(description));

    page.append("</td></tr></table>");
    myHTMLViewer.setText(XmlStringUtil.wrapInHtml(page));
    setupStyle();
  }
  finally {
    myCurrentEntity = null;
  }
}
 
Example 26
Source Project: consulo   Source 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 27
Source Project: consulo   Source File: ParameterInfoComponent.java    License: Apache License 2.0 5 votes vote down vote up
private String doSetup(@Nonnull String text, @Nonnull Color background) {
  myLabel.setBackground(background);
  setBackground(background);

  myLabel.setForeground(FOREGROUND);

  myLabel.setText(XmlStringUtil.wrapInHtml(text));
  return myLabel.getText();
}
 
Example 28
Source Project: consulo   Source File: LocalInspectionsPass.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
private HighlightInfo createHighlightInfo(@Nonnull ProblemDescriptor descriptor,
                                          @Nonnull LocalInspectionToolWrapper tool,
                                          @Nonnull HighlightInfoType level,
                                          @Nonnull Set<Pair<TextRange, String>> emptyActionRegistered,
                                          @Nonnull PsiElement element) {
  @NonNls String message = ProblemDescriptorUtil.renderDescriptionMessage(descriptor, element);

  final HighlightDisplayKey key = HighlightDisplayKey.find(tool.getShortName());
  final InspectionProfile inspectionProfile = myProfileWrapper.getInspectionProfile();
  if (!inspectionProfile.isToolEnabled(key, getFile())) return null;

  HighlightInfoType type = new HighlightInfoType.HighlightInfoTypeImpl(level.getSeverity(element), level.getAttributesKey());
  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\" " : "") +
                              ">" +
                              DaemonBundle.message("inspection.extended.description") +
                              "</a> " +
                              myShortcutText;

  @NonNls String tooltip = null;
  if (descriptor.showTooltip()) {
    tooltip = XmlStringUtil.wrapInHtml((message.startsWith("<html>") ? XmlStringUtil.stripHtml(message) : XmlStringUtil.escapeString(message)) + link);
  }
  HighlightInfo highlightInfo = highlightInfoFromDescriptor(descriptor, type, plainMessage, tooltip, element);
  if (highlightInfo != null) {
    registerQuickFixes(tool, descriptor, highlightInfo, emptyActionRegistered);
  }
  return highlightInfo;
}
 
Example 29
Source Project: consulo   Source File: DaemonTooltipRenderer.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
protected String dressDescription(@Nonnull final Editor editor, @Nonnull String tooltipText, boolean expand) {
  if (!expand) {
    return super.dressDescription(editor, tooltipText, false);
  }

  final List<String> problems = getProblems(tooltipText);
  StringBuilder text = new StringBuilder();
  for (String problem : problems) {
    final String ref = getLinkRef(problem);
    if (ref != null) {
      String description = TooltipLinkHandlerEP.getDescription(ref, editor);
      if (description != null) {
        description = InspectionNodeInfo.stripUIRefsFromInspectionDescription(UIUtil.getHtmlBody(new Html(description).setKeepFont(true)));
        text.append(getHtmlForProblemWithLink(problem)).append(END_MARKER).append("<p>").append("<span style=\"color:").append(ColorUtil.toHex(getDescriptionTitleColor())).append("\">")
                .append(TooltipLinkHandlerEP.getDescriptionTitle(ref, editor)).append(":</span>").append(description).append(UIUtil.BORDER_LINE);
      }
    }
    else {
      text.append(UIUtil.getHtmlBody(new Html(problem).setKeepFont(true))).append(UIUtil.BORDER_LINE);
    }
  }
  if (text.length() > 0) { //otherwise do not change anything
    return XmlStringUtil.wrapInHtml(StringUtil.trimEnd(text.toString(), UIUtil.BORDER_LINE));
  }
  return super.dressDescription(editor, tooltipText, true);
}
 
Example 30
Source Project: consulo   Source File: LibraryProjectStructureElement.java    License: Apache License 2.0 5 votes vote down vote up
private static String createInvalidRootsDescription(List<String> invalidClasses, String rootName, String libraryName) {
  StringBuilder buffer = new StringBuilder();
  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));
  }
  return XmlStringUtil.wrapInHtml(buffer);
}