private static void uppercaseFirstLetter(final StringBuffer buf) { if (buf.length() > 1) { char[] firstLetter = new char[1]; buf.getChars(0, 1, firstLetter, 0); buf.setCharAt(0, Character.toUpperCase(firstLetter[0])); } }
private String generateHTML(final RefEntity refEntity, final InspectionTool tool) { final StringBuffer buf = new StringBuffer(); if (refEntity instanceof RefElement) { final Runnable action = new Runnable() { @Override public void run() { tool.getComposer().compose(buf, refEntity); } }; ApplicationManager.getApplication().runReadAction(action); } else { tool.getComposer().compose(buf, refEntity); } uppercaseFirstLetter(buf); if (refEntity instanceof RefElement) { appendSuppressSection(buf); } insertHeaderFooter(buf); return buf.toString(); }
private void appendSuppressSection(final StringBuffer buf) { final InspectionTool tool = getTool(); if (tool != null) { final HighlightDisplayKey key = HighlightDisplayKey.find(tool.getShortName()); if (key != null) { // dummy entry points final SuppressActionWrapper.SuppressTreeAction[] suppressActions = new SuppressActionWrapper( myView.getProject(), tool, myView.getTree().getSelectionPaths()) .getChildren(null); if (suppressActions.length > 0) { final List<AnAction> activeSuppressActions = new ArrayList<AnAction>(); for (SuppressActionWrapper.SuppressTreeAction suppressAction : suppressActions) { if (suppressAction.isAvailable()) { activeSuppressActions.add(suppressAction); } } if (!activeSuppressActions.isEmpty()) { int idx = 0; @NonNls final String br = "<br>"; buf.append(br); HTMLComposerImpl.appendHeading( buf, InspectionsBundle.message("inspection.export.results.suppress")); for (AnAction suppressAction : activeSuppressActions) { buf.append(br); if (idx == activeSuppressActions.size() - 1) { buf.append(br); } HTMLComposer.appendAfterHeaderIndention(buf); @NonNls final String href = "<a HREF=\"file://bred.txt#suppress:" + idx + "\">" + suppressAction.getTemplatePresentation().getText() + "</a>"; buf.append(href); idx++; } } } } } }
public void showDescription(InspectionTool tool) { if (tool.getShortName().length() == 0) { 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(tool.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 = tool.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; } }
@SuppressWarnings({"HardCodedStringLiteral"}) private static void insertHeaderFooter(final StringBuffer buf) { buf.insert(0, "<HTML><BODY>"); buf.append("</BODY></HTML>"); }