com.intellij.xml.util.XmlStringUtil Java Examples

The following examples show how to use com.intellij.xml.util.XmlStringUtil. 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: LineTooltipRenderer.java    From consulo with 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 #2
Source File: IncompatibleEncodingDialog.java    From consulo with 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 #3
Source File: ProjectStructureProblemsHolderImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 #4
Source File: HighlightInfoComposite.java    From consulo with 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 #5
Source File: DaemonTooltipActionProvider.java    From consulo with 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 #6
Source File: VcsCommitInfoBalloon.java    From consulo with 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 File: PushController.java    From consulo with 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 #8
Source File: ArtifactErrorPanel.java    From consulo with 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 #9
Source File: PluginManagerMain.java    From consulo with 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 #10
Source File: CommentNodeRenderer.java    From Crucible4IDEA with 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 #11
Source File: LibraryClasspathTableItem.java    From consulo with 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 #12
Source File: PackagingElementNode.java    From consulo with 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 #13
Source File: NotificationsUtil.java    From consulo with 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 #14
Source File: LineTooltipRenderer.java    From consulo with 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 #15
Source File: DaemonTooltipRenderer.java    From consulo with 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 #16
Source File: HighlightInfo.java    From consulo with 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 #17
Source File: LocalInspectionsPass.java    From consulo with 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 #18
Source File: ParameterInfoComponent.java    From consulo with 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 #19
Source File: ProblemDescriptionNode.java    From consulo with 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 #20
Source File: UndoApplyPatchDialog.java    From consulo with 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 #21
Source File: Browser.java    From consulo with 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 #22
Source File: HighlightInfo.java    From consulo with 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 #23
Source File: LibraryProjectStructureElement.java    From consulo with 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);
}
 
Example #24
Source File: AnnotateStackTraceAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public String getToolTip(int line, Editor editor) {
  LastRevision revision = myRevisions.get(line);
  if (revision != null) {
    return XmlStringUtil.escapeString(revision.getAuthor() + " " + DateFormatUtil.formatDateTime(revision.getDate()) + "\n" + VcsUtil.trimCommitMessageToSaneSize(revision.getMessage()));
  }
  return null;
}
 
Example #25
Source File: HaxeAnnotation.java    From intellij-haxe with 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 #26
Source File: CC0001.java    From consulo-csharp with 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 #27
Source File: ShowUsagesAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static String suggestSecondInvocation(@Nonnull FindUsagesOptions options, @Nonnull FindUsagesHandler handler, @Nonnull String text) {
  final String title = getSecondInvocationTitle(options, handler);

  if (title != null) {
    text += "<br><small> " + title + "</small>";
  }
  return XmlStringUtil.wrapInHtml(UIUtil.convertSpace2Nbsp(text));
}
 
Example #28
Source File: DependenciesPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(final AnActionEvent e) {
  @NonNls final String delim = "&nbsp;-&gt;&nbsp;";
  final StringBuffer buf = new StringBuffer();
  processDependencies(getSelectedScope(myLeftTree), getSelectedScope(myRightTree), new Processor<List<PsiFile>>() {
    @Override
    public boolean process(final List<PsiFile> path) {
      if (buf.length() > 0) buf.append("<br>");
      buf.append(StringUtil.join(path, new Function<PsiFile, String>() {
        @Override
        public String fun(final PsiFile psiFile) {
          return psiFile.getName();
        }
      }, delim));
      return true;
    }
  });
  final JEditorPane pane = new JEditorPane(UIUtil.HTML_MIME, XmlStringUtil.wrapInHtml(buf));
  pane.setForeground(JBColor.foreground());
  pane.setBackground(HintUtil.INFORMATION_COLOR);
  pane.setOpaque(true);
  final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(pane);
  final Dimension dimension = pane.getPreferredSize();
  scrollPane.setMinimumSize(new Dimension(dimension.width, dimension.height + 20));
  scrollPane.setPreferredSize(new Dimension(dimension.width, dimension.height + 20));
  JBPopupFactory.getInstance().createComponentPopupBuilder(scrollPane, pane).setTitle("Dependencies")
    .setMovable(true).createPopup().showInBestPositionFor(e.getDataContext());
}
 
Example #29
Source File: HaskellAnnotationHolder.java    From intellij-haskforce with Apache License 2.0 5 votes vote down vote up
@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 #30
Source File: VueGeneratorPeer.java    From vue-for-idea with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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;
}