From f04494e4675d454e90ef21227f1073e0d4e9981f Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 25 Feb 2005 22:53:41 +0300 Subject: [PATCH] add descriptions on the right of inspection tool in InspectionsResultView --- .../intellij/codeInspection/ui/Browser.java | 21 +++++++++++++++++++ .../ui/InspectionResultsView.java | 9 ++++++++ 2 files changed, 30 insertions(+) diff --git a/source/com/intellij/codeInspection/ui/Browser.java b/source/com/intellij/codeInspection/ui/Browser.java index e6403ecbc931..a58803a7dada 100644 --- a/source/com/intellij/codeInspection/ui/Browser.java +++ b/source/com/intellij/codeInspection/ui/Browser.java @@ -4,6 +4,7 @@ import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.codeInspection.ex.DescriptorProviderInspection; import com.intellij.codeInspection.ex.HTMLComposer; import com.intellij.codeInspection.ex.InspectionTool; +import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; import com.intellij.codeInspection.reference.RefElement; import com.intellij.codeInspection.reference.RefEntity; import com.intellij.codeInspection.reference.RefImplicitConstructor; @@ -25,6 +26,7 @@ import java.net.URL; import java.util.ArrayList; public class Browser extends JPanel { + private static final String UNDER_CONSTRUCTION = "Under construction"; private final ArrayList myClickListeners; private RefEntity myCurrentEntity; private final JEditorPane myHTMLViewer; @@ -251,6 +253,25 @@ public class Browser extends JPanel { } } + public void showDescription(InspectionTool tool){ + try { + myHTMLViewer.setPage(getDescriptionUrl(tool)); + } + catch (IOException e) { + try { + myHTMLViewer.read(new StringReader("" + UNDER_CONSTRUCTION + ""), null); + } + catch (IOException e1) { + //Can't be + } + } + } + + private URL getDescriptionUrl(InspectionTool tool) { + Class aClass = tool instanceof LocalInspectionToolWrapper ? ((LocalInspectionToolWrapper)tool).getTool().getClass() : tool.getClass(); + return aClass.getResource("/inspectionDescriptions/" + tool.getDescriptionFileName()); + } + private InspectionTool getTool() { return myView.getSelectedTool(); } private HTMLComposer getComposer() { return getTool().getComposer(); } diff --git a/source/com/intellij/codeInspection/ui/InspectionResultsView.java b/source/com/intellij/codeInspection/ui/InspectionResultsView.java index ae3c9e119f77..d4ec4bd5d1e6 100644 --- a/source/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/source/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -270,6 +270,8 @@ public class InspectionResultsView extends JPanel implements OccurenceNavigator, else if (node instanceof ProblemDescriptionNode) { final ProblemDescriptionNode problemNode = (ProblemDescriptionNode)node; showInBrowser(problemNode.getElement(), problemNode.getDescriptor()); + } else if (node instanceof InspectionNode){ + showInBrowser(((InspectionNode)node).getTool()); } else { myBrowser.showEmpty(); @@ -285,6 +287,13 @@ public class InspectionResultsView extends JPanel implements OccurenceNavigator, setCursor(currentCursor); } + public void showInBrowser(InspectionTool tool){ + Cursor currentCursor = getCursor(); + setCursor(new Cursor(Cursor.WAIT_CURSOR)); + myBrowser.showDescription(tool); + setCursor(currentCursor); + } + public void showInBrowser(final RefElement refElement, ProblemDescriptor descriptor) { Cursor currentCursor = getCursor(); setCursor(new Cursor(Cursor.WAIT_CURSOR));