use of com.intellij.codeEditor.printing.ExportToHTMLSettings in project intellij-community by JetBrains.
the class ExportToHTMLDialog method reset.
public void reset() {
ExportToHTMLSettings exportToHTMLSettings = ExportToHTMLSettings.getInstance(myProject);
if (myCanBeOpenInBrowser) {
myCbOpenInBrowser.setSelected(exportToHTMLSettings.OPEN_IN_BROWSER);
}
final String text = exportToHTMLSettings.OUTPUT_DIRECTORY;
myTargetDirectoryField.setText(text);
if (text != null) {
myTargetDirectoryField.setPreferredSize(new Dimension(GraphicsUtil.stringWidth(text, myTargetDirectoryField.getFont()) + 100, myTargetDirectoryField.getPreferredSize().height));
}
}
use of com.intellij.codeEditor.printing.ExportToHTMLSettings in project intellij-community by JetBrains.
the class ExportHTMLAction method exportHTML.
private void exportHTML(final boolean exportToHTML) {
ExportToHTMLDialog exportToHTMLDialog = new ExportToHTMLDialog(myView.getProject(), exportToHTML);
final ExportToHTMLSettings exportToHTMLSettings = ExportToHTMLSettings.getInstance(myView.getProject());
if (exportToHTMLSettings.OUTPUT_DIRECTORY == null) {
exportToHTMLSettings.OUTPUT_DIRECTORY = PathManager.getHomePath() + File.separator + "inspections";
}
exportToHTMLDialog.reset();
if (!exportToHTMLDialog.showAndGet()) {
return;
}
exportToHTMLDialog.apply();
final String outputDirectoryName = exportToHTMLSettings.OUTPUT_DIRECTORY;
ApplicationManager.getApplication().invokeLater(() -> {
final Runnable exportRunnable = () -> ApplicationManager.getApplication().runReadAction(() -> {
if (!exportToHTML) {
dump2xml(outputDirectoryName);
} else {
try {
new InspectionTreeHtmlWriter(myView, outputDirectoryName);
} catch (ProcessCanceledException e) {
// Do nothing here.
}
}
});
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(exportRunnable, InspectionsBundle.message(exportToHTML ? "inspection.generating.html.progress.title" : "inspection.generating.xml.progress.title"), true, myView.getProject())) {
return;
}
if (exportToHTML && exportToHTMLSettings.OPEN_IN_BROWSER) {
BrowserUtil.browse(new File(exportToHTMLSettings.OUTPUT_DIRECTORY, "index.html"));
}
});
}
use of com.intellij.codeEditor.printing.ExportToHTMLSettings in project intellij-community by JetBrains.
the class ExportToHTMLDialog method apply.
public void apply() {
ExportToHTMLSettings exportToHTMLSettings = ExportToHTMLSettings.getInstance(myProject);
if (myCanBeOpenInBrowser) {
exportToHTMLSettings.OPEN_IN_BROWSER = myCbOpenInBrowser.isSelected();
}
exportToHTMLSettings.OUTPUT_DIRECTORY = myTargetDirectoryField.getText();
}
use of com.intellij.codeEditor.printing.ExportToHTMLSettings in project intellij-community by JetBrains.
the class JavaCoverageEngine method generateJavaReport.
protected static void generateJavaReport(@NotNull final Project project, final File tempFile, final CoverageSuitesBundle currentSuite) {
final ExportToHTMLSettings settings = ExportToHTMLSettings.getInstance(project);
final ProjectData projectData = currentSuite.getCoverageData();
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Generating coverage report ...") {
final Exception[] myExceptions = new Exception[1];
public void run(@NotNull final ProgressIndicator indicator) {
try {
new SaveHook(tempFile, true, new IdeaClassFinder(project, currentSuite)).save(projectData);
final HTMLReportBuilder builder = ReportBuilderFactory.createHTMLReportBuilder();
builder.setReportDir(new File(settings.OUTPUT_DIRECTORY));
final SourceCodeProvider sourceCodeProvider = new SourceCodeProvider() {
public String getSourceCode(@NotNull final String classname) throws IOException {
return DumbService.getInstance(project).runReadActionInSmartMode(() -> {
if (project.isDisposed())
return "";
final PsiClass psiClass = ClassUtil.findPsiClassByJVMName(PsiManager.getInstance(project), classname);
return psiClass != null ? psiClass.getNavigationElement().getContainingFile().getText() : "";
});
}
};
builder.generateReport(new IDEACoverageData(projectData, sourceCodeProvider) {
@NotNull
@Override
public Collection<ClassInfo> getClasses() {
final Collection<ClassInfo> classes = super.getClasses();
if (!currentSuite.isTrackTestFolders()) {
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
final GlobalSearchScope productionScope = GlobalSearchScopesCore.projectProductionScope(project);
for (Iterator<ClassInfo> iterator = classes.iterator(); iterator.hasNext(); ) {
final ClassInfo aClass = iterator.next();
final PsiClass psiClass = DumbService.getInstance(project).runReadActionInSmartMode(() -> {
if (project.isDisposed())
return null;
return psiFacade.findClass(aClass.getFQName(), productionScope);
});
if (psiClass == null) {
iterator.remove();
}
}
}
return classes;
}
});
} catch (IOException e) {
LOG.error(e);
} catch (ReportGenerationFailedException e) {
myExceptions[0] = e;
}
}
@Override
public void onSuccess() {
if (myExceptions[0] != null) {
Messages.showErrorDialog(project, myExceptions[0].getMessage(), CommonBundle.getErrorTitle());
return;
}
if (settings.OPEN_IN_BROWSER) {
BrowserUtil.browse(new File(settings.OUTPUT_DIRECTORY, "index.html"));
}
}
});
}
use of com.intellij.codeEditor.printing.ExportToHTMLSettings in project intellij-plugins by JetBrains.
the class JstdCoverageEngine method generateReport.
@Override
public void generateReport(@NotNull Project project, @NotNull DataContext dataContext, @NotNull CoverageSuitesBundle currentSuiteBundle) {
CoverageReport coverageReport = new CoverageReport();
for (CoverageSuite suite : currentSuiteBundle.getSuites()) {
ProjectData projectData = suite.getCoverageData(CoverageDataManager.getInstance(project));
if (projectData != null) {
@SuppressWarnings("unchecked") Map<String, ClassData> classDataMap = projectData.getClasses();
for (Map.Entry<String, ClassData> classDataEntry : classDataMap.entrySet()) {
String fileName = classDataEntry.getKey();
ClassData classData = classDataEntry.getValue();
List<CoverageReport.LineHits> lineHitsList = convertClassDataToLineHits(classData);
coverageReport.mergeFileReport(fileName, lineHitsList);
}
}
}
final ExportToHTMLSettings settings = ExportToHTMLSettings.getInstance(project);
final File outputDir = new File(settings.OUTPUT_DIRECTORY);
FileUtil.createDirectory(outputDir);
String outputFileName = getOutputFileName(currentSuiteBundle);
String title = "Coverage Report Generation";
try {
File output = new File(outputDir, outputFileName);
CoverageSerializationUtils.writeLCOV(coverageReport, output);
refresh(output);
String url = "http://ltp.sourceforge.net/coverage/lcov.php";
Messages.showInfoMessage("<html>Coverage report has been successfully saved as '" + outputFileName + "' file.<br>Use <a href='" + url + "'>" + url + "</a>" + " to generate HTML output." + "</html>", title);
} catch (IOException e) {
LOG.warn("Can not export coverage data", e);
Messages.showErrorDialog("Can not generate coverage report: " + e.getMessage(), title);
}
}
Aggregations