add descriptions on the right of inspection tool in InspectionsResultView

This commit is contained in:
Anna Kozlova
2005-02-25 22:53:41 +03:00
parent 1704b6ca37
commit f04494e467
2 changed files with 30 additions and 0 deletions
@@ -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("<html><body><b>" + UNDER_CONSTRUCTION + "</b></body></html>"), 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(); }
@@ -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));