mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inspection tool window: inspection report: read and copy css&js files from resources
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
</content>
|
||||
<orderEntry type="module" module-name="boot" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License);
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* @author: Dmitry Batkovich
|
||||
*/
|
||||
function navigate(an_id) {
|
||||
problem_div = document.getElementById("d" + an_id);
|
||||
preview_div = document.getElementById("preview");
|
||||
preview_div.innerHTML = problem_div != null ? problem_div.innerHTML : "Select a problem element in tree";
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License);
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
html {
|
||||
font-family: \Helvetica Neue\, Helvetica, Arial, \Lucida Grande\, sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
color: #4C4C4C;
|
||||
margin: 60px 60px 0 60px;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1em;
|
||||
margin: 0 0 1em 0;
|
||||
}
|
||||
|
||||
.grayout {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
body, input, select, textarea, th, td {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
li {
|
||||
position: relative;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
label:hover {
|
||||
color: #0C479D;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
li::before {
|
||||
content: "\23FA";
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
li input {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
margin-left: 0;
|
||||
background: none;
|
||||
opacity: 0;
|
||||
z-index: 2;
|
||||
cursor: pointer;
|
||||
height: 1em;
|
||||
width: 1em;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
li input + ol {
|
||||
margin: -15px 0 0 -44px;
|
||||
height: 1em;
|
||||
}
|
||||
|
||||
li input + ol > li {
|
||||
display: none;
|
||||
margin-left: -14px !important;
|
||||
padding-left: 1px;
|
||||
}
|
||||
|
||||
li label {
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
li input:checked + ol {
|
||||
margin: -20px 0 0 -44px;
|
||||
padding: 25px 0 0 80px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
li input:checked + ol > li {
|
||||
display: block;
|
||||
margin: 0 0 2px;
|
||||
}
|
||||
|
||||
li input:checked + ol > li:last-child {
|
||||
margin: 0 0 1px;
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInspection.export;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
class InspectionTreeCss {
|
||||
static final String CSS_TEXT;
|
||||
|
||||
static {
|
||||
CSS_TEXT = "html {\n" +
|
||||
" font-family: \"Helvetica Neue\", Helvetica, Arial, \"Lucida Grande\", sans-serif;\n" +
|
||||
"}\n" +
|
||||
"body {\n" +
|
||||
" color: #4C4C4C;\n" +
|
||||
" margin: 60px 60px 0 60px;\n" +
|
||||
"}\n" +
|
||||
"p {\n" +
|
||||
" font-size: 1em;\n" +
|
||||
" margin: 0 0 1em 0;\n" +
|
||||
"}\n" +
|
||||
".grayout {\n" +
|
||||
" opacity: 0.6;\n" +
|
||||
"}\n" +
|
||||
"body, input, select, textarea, th, td {\n" +
|
||||
" font-size: 1em;\n" +
|
||||
"}\n" +
|
||||
"li {\n" +
|
||||
" position: relative;\n" +
|
||||
" list-style: none;\n" +
|
||||
"}\n" +
|
||||
"label:hover {\n" +
|
||||
" color: #0C479D;\n" +
|
||||
" text-decoration: underline;\n" +
|
||||
"}\n" +
|
||||
"li::before {\n" +
|
||||
" content: \"\\23FA\";\n" +
|
||||
" margin: 0;\n" +
|
||||
"}\n" +
|
||||
"li input {\n" +
|
||||
" position: absolute;\n" +
|
||||
" left: 0;\n" +
|
||||
" margin-left: 0;\n" +
|
||||
" background: none;\n" +
|
||||
" opacity: 0;\n" +
|
||||
" z-index: 2;\n" +
|
||||
" cursor: pointer;\n" +
|
||||
" height: 1em;\n" +
|
||||
" width: 1em;\n" +
|
||||
" top: 0;\n" +
|
||||
" content: \"some text>\";\n" +
|
||||
"}\n" +
|
||||
"li input + ol {\n" +
|
||||
" margin: -15px 0 0 -44px;\n" +
|
||||
" height: 1em;\n" +
|
||||
"}\n" +
|
||||
"li input + ol > li {\n" +
|
||||
" display: none;\n" +
|
||||
" margin-left: -14px !important;\n" +
|
||||
" padding-left: 1px;\n" +
|
||||
"}\n" +
|
||||
"li label {\n" +
|
||||
" padding-left: 5px;\n" +
|
||||
"}\n" +
|
||||
"li input:checked + ol {\n" +
|
||||
" margin: -20px 0 0 -44px;\n" +
|
||||
" padding: 25px 0 0 80px;\n" +
|
||||
" height: auto;\n" +
|
||||
"}\n" +
|
||||
"li input:checked + ol > li {\n" +
|
||||
" display: block;\n" +
|
||||
" margin: 0 0 2px;\n" +
|
||||
"}\n" +
|
||||
"li input:checked + ol > li:last-child {\n" +
|
||||
" margin: 0 0 1px;\n" +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInspection.export;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
|
||||
import java.io.*;
|
||||
/**
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
class InspectionTreeHtmlExportResources {
|
||||
private static final Logger LOG = Logger.getInstance(InspectionTreeHtmlExportResources.class);
|
||||
|
||||
static void copyInspectionReportResources(final String targetDirectory) {
|
||||
copyInspectionReportResource("styles.css", targetDirectory);
|
||||
copyInspectionReportResource("script.js", targetDirectory);
|
||||
}
|
||||
|
||||
private static void copyInspectionReportResource(final String resourceName, final String targetDirectory) {
|
||||
final File resourceTargetFile = new File(targetDirectory, resourceName);
|
||||
if (!FileUtil.createIfDoesntExist(resourceTargetFile)) {
|
||||
LOG.error("Can't create file: " + resourceTargetFile.getAbsolutePath());
|
||||
}
|
||||
try (InputStream input = InspectionTreeHtmlExportResources.class.getClassLoader().getResourceAsStream("/inspectionReport/" + resourceName)) {
|
||||
try (OutputStream f = new FileOutputStream(resourceTargetFile)) {
|
||||
FileUtil.copy(input, f);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-12
@@ -42,6 +42,7 @@ public class InspectionTreeHtmlWriter {
|
||||
private final StringBuffer myBuilder = new StringBuffer();
|
||||
private final InspectionProfile myProfile;
|
||||
private final RefManager myManager;
|
||||
private final ExcludedInspectionTreeNodesManager myExcludedManager;
|
||||
|
||||
public InspectionTreeHtmlWriter(InspectionTree tree,
|
||||
String outputDir) {
|
||||
@@ -49,12 +50,16 @@ public class InspectionTreeHtmlWriter {
|
||||
myOutputDir = outputDir;
|
||||
myProfile = tree.getContext().getCurrentProfile();
|
||||
myManager = tree.getContext().getRefManager();
|
||||
myExcludedManager = tree.getContext().getView().getExcludedManager();
|
||||
serializeTreeToHtml();
|
||||
}
|
||||
|
||||
private static void traverseInspectionTree(final InspectionTreeNode node,
|
||||
private void traverseInspectionTree(final InspectionTreeNode node,
|
||||
final Consumer<InspectionTreeNode> preAction,
|
||||
final Consumer<InspectionTreeNode> postAction) {
|
||||
if (node.isResolved(myExcludedManager)) {
|
||||
return;
|
||||
}
|
||||
preAction.accept(node);
|
||||
for (int i = 0; i < node.getChildCount(); i++) {
|
||||
traverseInspectionTree((InspectionTreeNode)node.getChildAt(i), preAction, postAction);
|
||||
@@ -104,7 +109,7 @@ public class InspectionTreeHtmlWriter {
|
||||
});
|
||||
|
||||
HTMLExportUtil.writeFile(myOutputDir, "index.html", myBuilder, myTree.getContext().getProject());
|
||||
HTMLExportUtil.writeFile(myOutputDir, "styles.css", InspectionTreeCss.CSS_TEXT, myTree.getContext().getProject());
|
||||
InspectionTreeHtmlExportResources.copyInspectionReportResources(myOutputDir);
|
||||
}
|
||||
|
||||
private String convertNodeToHtml(InspectionTreeNode node) {
|
||||
@@ -161,17 +166,11 @@ public class InspectionTreeHtmlWriter {
|
||||
myBuilder.append("<html><head>" +
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">" +
|
||||
"<meta name=\"author\" content=\"JetBrains\">" +
|
||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\">" +
|
||||
"<script type=\"text/javascript\" src=\"script.js\"></script>" +
|
||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\"/>" +
|
||||
"<title>")
|
||||
.append(title).append("</title><script>function navigate(an_id) {" +
|
||||
"problem_div = document.getElementById(\"d\" + an_id); " +
|
||||
"preview_div = document.getElementById(\"preview\");" +
|
||||
"if (problem_div == null) {" +
|
||||
"preview_div.innerHTML = \"Select a problem element in tree\"" +
|
||||
"} else { " +
|
||||
"preview_div.innerHTML = problem_div.innerHTML; " +
|
||||
"}" +
|
||||
"}</script></head><body><h3>")
|
||||
.append(title)
|
||||
.append("</title></head><body><h3>")
|
||||
.append(title)
|
||||
.append(":</h3>");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user