inspections view: use editor font settings; borders (IDEA-91395; IDEA-55378)

This commit is contained in:
Anna Kozlova
2012-09-13 21:17:34 +04:00
parent 0fa288f232
commit 1fd115a6b5
6 changed files with 45 additions and 38 deletions
@@ -216,7 +216,7 @@ public class DeadHTMLComposer extends HTMLComposerImpl {
}
//noinspection HardCodedStringLiteral
buf.append("<br><font style=\"font-family:verdana;color:#808080\">");
buf.append("<br>");
if (refElement instanceof RefClass) {
RefClassImpl refClass = (RefClassImpl)refElement;
if (refClass.isSuspicious()) {
@@ -251,9 +251,6 @@ public class DeadHTMLComposer extends HTMLComposerImpl {
buf.append(InspectionsBundle.message("inspection.dead.code.problem.synopsis6", nUsageCount));
}
}
//noinspection HardCodedStringLiteral
buf.append("</font>");
}
private static int getDerivedRefsCount(RefMethod refMethod) {
@@ -343,8 +340,6 @@ public class DeadHTMLComposer extends HTMLComposerImpl {
if (possibleChildren.size() > 0) {
if (appendCallees){
appendHeading(buf, InspectionsBundle.message("inspection.export.results.callees"));
@NonNls String font = "<font style=\"font-family:verdana;\" size = \"3\">";
buf.append(font);
}
@NonNls final String ul = "<ul>";
buf.append(ul);
@@ -361,10 +356,6 @@ public class DeadHTMLComposer extends HTMLComposerImpl {
}
@NonNls final String closeUl = "</ul>";
buf.append(closeUl);
if (appendCallees){
@NonNls String closeFont = "</font>";
buf.append(closeFont);
}
}
}
@@ -324,11 +324,10 @@ public class HTMLJavaHTMLComposerImpl extends HTMLJavaHTMLComposer {
myComposer.appendElementReference(buf, ((RefElement)refElement.getOwner()), isPackageIncluded);
}
else if (isPackageIncluded) {
@NonNls final String color = "color:#808080\">";
buf.append(" ").append(HTMLComposerImpl.CODE_OPENING).append(HTMLComposerImpl.FONT_OPENING).append(color).append("(");
buf.append(" ").append(HTMLComposerImpl.CODE_OPENING).append("(");
myComposer.appendQualifiedName(buf, refElement.getOwner());
// buf.append(RefUtil.getPackageName(refElement));
buf.append(")").append(HTMLComposerImpl.FONT_CLOSING).append(HTMLComposerImpl.CODE_CLOSING);
buf.append(")").append(HTMLComposerImpl.CODE_CLOSING);
}
}
@@ -39,9 +39,9 @@ public abstract class HTMLComposer {
public static void appendHeading(@NonNls StringBuffer buf, String name){
buf.append(
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font style=\"font-family:verdana; font-weight:bold; color:#005555; size = 3\">");
"&nbsp;&nbsp;<font style=\"font-weight:bold; color:#005555;\">");
buf.append(name);
buf.append(":</font>");
buf.append("</font>");
}
public abstract void appendElementReference(StringBuffer buf, RefElement refElement, boolean isPackageIncluded);
@@ -55,7 +55,7 @@ public abstract class HTMLComposer {
public abstract void startListItem(@NonNls StringBuffer buf);
public static void appendAfterHeaderIndention(@NonNls StringBuffer buf) {
buf.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
buf.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
}
public abstract void appendNoProblems(StringBuffer buf);
@@ -112,13 +112,12 @@ public class DescriptorComposer extends HTMLComposerImpl {
int idx = 0;
for (QuickFix fix : fixes) {
//noinspection HardCodedStringLiteral
buf.append("<font style=\"font-family:verdana;\"");
//noinspection HardCodedStringLiteral
buf.append("<a HREF=\"file://bred.txt#invokelocal:" + (idx++));
buf.append("\">");
buf.append(fix.getName());
//noinspection HardCodedStringLiteral
buf.append("</a></font>");
buf.append("</a>");
//noinspection HardCodedStringLiteral
buf.append("<br>");
appendAfterHeaderIndention(buf);
@@ -156,7 +155,7 @@ public class DescriptorComposer extends HTMLComposerImpl {
}
else {
//noinspection HardCodedStringLiteral
anchor.append("<font style=\"font-family:verdana; font-weight:bold; color:#FF0000\";>");
anchor.append("<font style=\"font-weight:bold; color:#FF0000\";>");
anchor.append(InspectionsBundle.message("inspection.export.results.invalidated.item"));
//noinspection HardCodedStringLiteral
anchor.append("</font>");
@@ -56,10 +56,9 @@ public abstract class HTMLComposerImpl extends HTMLComposer {
@NonNls protected static final String NBSP = "&nbsp;";
@NonNls protected static final String CODE_CLOSING = "</code>";
@NonNls protected static final String CODE_OPENING = "<code>";
@NonNls protected static final String FONT_CLOSING = "</font>";
@NonNls protected static final String B_OPENING = "<b>";
@NonNls protected static final String B_CLOSING = "</b>";
@NonNls protected static final String FONT_OPENING = "<font style=\"font-family:verdana;";
@NonNls protected static final String CLOSE_TAG = "\">";
@NonNls protected static final String A_HREF_OPENING = "<a HREF=\"";
@NonNls protected static final String A_CLOSING = "</a>";
@@ -106,8 +105,6 @@ public abstract class HTMLComposerImpl extends HTMLComposer {
}
private void appendLocation(final StringBuffer buf, final RefElement refElement) {
buf.append(FONT_OPENING);
buf.append(CLOSE_TAG);
final HTMLComposerExtension extension = getLanguageExtension(refElement);
if (extension != null) {
extension.appendLocation(refElement, buf);
@@ -117,7 +114,6 @@ public abstract class HTMLComposerImpl extends HTMLComposer {
buf.append(NBSP);
appendElementReference(buf, refElement, false);
}
buf.append(FONT_CLOSING);
}
@Nullable
@@ -197,12 +193,10 @@ public abstract class HTMLComposerImpl extends HTMLComposer {
protected void appendQuickFix(@NonNls final StringBuffer buf, String text, int index) {
if (myExporter == null) {
buf.append(FONT_OPENING);
buf.append(CLOSE_TAG);
buf.append("<a HREF=\"file://bred.txt#invoke:").append(index);
buf.append("\">");
buf.append(text);
buf.append("</a></font>");
buf.append("</a>");
}
}
@@ -267,11 +261,9 @@ public abstract class HTMLComposerImpl extends HTMLComposer {
public void appendListItem(StringBuffer buf, RefElement refElement) {
startListItem(buf);
buf.append(FONT_OPENING);
buf.append(CLOSE_TAG);
appendElementReference(buf, refElement, true);
appendAdditionalListItemInfo(buf, refElement);
buf.append(FONT_CLOSING);
doneListItem(buf);
}
@@ -26,6 +26,8 @@ import com.intellij.codeInspection.ui.actions.SuppressActionWrapper;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -35,7 +37,6 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.psi.util.PsiModificationTracker;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.SideBorder;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
@@ -43,6 +44,10 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.Document;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLFrameHyperlinkEvent;
import java.awt.*;
@@ -123,6 +128,7 @@ class Browser extends JPanel {
try {
String html = generateHTML(newEntity, tool);
myHTMLViewer.read(new StringReader(html), null);
setupStyle();
myHTMLViewer.setCaretPosition(0);
}
catch (Exception e) {
@@ -140,6 +146,7 @@ class Browser extends JPanel {
try {
String html = generateHTML(refEntity, descriptor);
myHTMLViewer.read(new StringReader(html), null);
setupStyle();
myHTMLViewer.setCaretPosition(0);
}
catch (Exception e) {
@@ -253,7 +260,27 @@ class Browser extends JPanel {
};
myHTMLViewer.addHyperlinkListener(myHyperLinkListener);
add(ScrollPaneFactory.createScrollPane(myHTMLViewer, SideBorder.LEFT), BorderLayout.CENTER);
final JScrollPane pane = ScrollPaneFactory.createScrollPane(myHTMLViewer);
pane.setBorder(null);
add(pane, BorderLayout.CENTER);
setupStyle();
}
private void setupStyle() {
Document document = myHTMLViewer.getDocument();
if (!(document instanceof StyledDocument)) {
return;
}
StyledDocument styledDocument = (StyledDocument)document;
EditorColorsManager colorsManager = EditorColorsManager.getInstance();
EditorColorsScheme scheme = colorsManager.getGlobalScheme();
Style style = styledDocument.addStyle("active", null);
StyleConstants.setFontFamily(style, scheme.getEditorFontName());
StyleConstants.setFontSize(style, scheme.getEditorFontSize());
styledDocument.setCharacterAttributes(0, document.getLength(), style, false);
}
public void addClickListener(ClickListener listener) {
@@ -295,8 +322,8 @@ class Browser extends JPanel {
@SuppressWarnings({"HardCodedStringLiteral"})
private static void insertHeaderFooter(final StringBuffer buf) {
buf.insert(0, "<HTML><BODY><font style=\"font-family:verdana;\" size = \"3\">");
buf.append("</font></BODY></HTML>");
buf.insert(0, "<HTML><BODY>");
buf.append("</BODY></HTML>");
}
private String generateHTML(final RefEntity refEntity, final CommonProblemDescriptor descriptor) {
@@ -349,20 +376,19 @@ class Browser extends JPanel {
}
if (!activeSuppressActions.isEmpty()) {
int idx = 0;
@NonNls String font = "<font style=\"font-family:verdana;\" size = \"3\">";
buf.append(font);
@NonNls final String br = "<br>";
buf.append(br).append(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++;
}
@NonNls String closeFont = "</font>";
buf.append(closeFont);
}
}
}