/** * Create a new empty canvas based on the receiver. * NOTE: Id generation will no longer work for the local canvas. * @return */ public HtmlCanvas createLocalCanvas(){ return new HtmlCanvas(); } /**
private static String render(Renderable r) { HtmlCanvas c = new HtmlCanvas(); try { r.renderOn(c); } catch (IOException e) { e.printStackTrace(); } return c.toHtml(); }
private static String render(Renderable r) { HtmlCanvas c = new HtmlCanvas(); try { r.renderOn(c); } catch (IOException e) { e.printStackTrace(); } return c.toHtml(); }
public void generateReport(IRunTestResults iRunTestResults, String reportDirectory) throws IOException { String reportFileName = String.format(TEST_CASE_REPORT_NAME + FORMATTER_STRING + REPORT_EXTENSION, valueOf(currentTimeMillis())); Path path = Paths.get(reportDirectory, reportFileName); try (Writer writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter( new FileOutputStream(path.toFile(), false), UTF_8)))) { HtmlCanvas reportPage = new HtmlCanvas(writer); HtmlCanvas reportPageHtml = reportPage.html(); appendReportPageHead(reportPageHtml); HtmlCanvas reportPageBody = reportPageHtml.body(); createResourcesFolder(reportDirectory); copyResources(reportDirectory); generateHeader(reportPageBody, CURRENT_DIRECTORY + RES + SLASH + CLOUD_SLANG_LOGO_PNG); generatePiechart(reportPageBody, iRunTestResults); generateTestCaseReportTable(reportPageBody, iRunTestResults); } }
@Override public void execute() throws MojoExecutionException, MojoFailureException { super.execute(); File htmlFile; try { HtmlCanvas html = getContent(new HtmlCanvas()); if (html != null) { htmlFile = copyFromIndex(); saveDocumentationFile(htmlFile, html); } } catch (IOException | SAXException e) { throw new MojoExecutionException(e.getLocalizedMessage(), e); } }
protected HtmlCanvas createArchetypesCommandLines(Dependency dependency, String archetypeAdditionalArguments, boolean addBreak) throws IOException { HtmlCanvas archetypesCommandLine = new HtmlCanvas(); String commandLine = "mvn archetype:generate"; List<String> arguments = new ArrayList<>(); arguments.add("-DarchetypeGroupId=" + dependency.getGroupId()); arguments.add("-DarchetypeArtifactId=" + dependency.getArtifactId()); arguments.add("-DarchetypeVersion=" + dependency.getVersion()); if (archetypeAdditionalArguments != null) { String[] lines = archetypeAdditionalArguments.split(" "); if (lines.length > 0) { for (int i = 0; i < lines.length; i++) { arguments.add(lines[i].trim()); } } else { arguments.add(archetypeAdditionalArguments); } } this.project.getProperties().put("data-clipboard-text", getFullCommandLine(commandLine, arguments)); this.project.getProperties().put("command-title", " "); String templateStart = replaceProperties(replaceProperties("${commandLineStart}")); String templateEnd = replaceProperties(replaceProperties("${commandLineEnd}")); archetypesCommandLine = createCommandLines(commandLine, templateStart, templateEnd, arguments, new ArrayList<String>(), addBreak); addPropertyInSessionRequest(dependency.getArtifactId() + "_ArchetypeCommandLine", archetypesCommandLine.toHtml()); HtmlCanvas result = new HtmlCanvas(); result. p().write("Command line for this archetype:")._p(). write(archetypesCommandLine.toHtml(), false); return result; }
/** * Answer a pretty formatted HTML output for a Renderable component. * @param component * @return */ public static String toString(Renderable component) { HtmlCanvas html = new HtmlCanvas(new PrettyWriter()); try { component.renderOn(html); } catch (Exception ex){ throw new RuntimeException("Error writing HTML for component:" + component); } return html.toHtml(); }
private HtmlCanvas generateSample(String title, String sample) throws IOException { HtmlCanvas html = new HtmlCanvas(); this.project.getProperties().put("data-clipboard-text", sample.replace("\n", "
")); this.project.getProperties().put("config-title", title); String templateStart = replaceProperties(replaceProperties("${configTextStart}")); String templateEnd = replaceProperties(replaceProperties("${configTextEnd}")); html.write(templateStart, false); html. pre(class_("xml")). write(sample, false) ._pre(); html.write(templateEnd, false); return html; }
protected HtmlCanvas createCommandLines(String commandLine, String templateStart, String templateEnd, List<String> arguments, List<String> results, boolean addBreak) throws IOException { HtmlCanvas result = new HtmlCanvas(); result.write(templateStart, false); result.write(commandLine, false); String spacing = " "; String breakAdd; if (addBreak) { breakAdd = "<br />"; } else { breakAdd = ""; } boolean first = true; for (String argument : arguments) { if (first) { result.write("<span>" + spacing + argument + "</span>" + breakAdd + "\n", false); spacing = StringUtils.repeat(" ", commandLine.length() + 1); first = false; } else { result.write("<span class='command-space'>" + spacing + argument + "</span>" + breakAdd + "\n", false); } } if (!results.isEmpty()) { result.write("<span class='result'> </span>" + breakAdd + "\n", false); } for (String r : results) { result.write("<span class='result'>" + r + "</span>" + breakAdd + "\n", false); } result.write(templateEnd, false); return result; }
@Override public void processHTMLFile(File htmlFile) throws Exception { HtmlCanvas html = new HtmlCanvas(); html .div(class_("brand")); updateTop(project, html, true, false); html ._div(); replaceByLine(htmlFile, "<div class=\"brand\".*</div>", formatHtml(html.toHtml())); }
private HtmlCanvas getArchetypeSection() throws IOException { HtmlCanvas html = new HtmlCanvas(); html.div(class_("section")). div(class_("page-header")). h2(id("Archetype")).em().write(project.getArtifactId())._em().write(" archetype")._h2() ._div(). a(name("Archetype"))._a(); String additionalHTML = replaceProperties(getPropertyValue(project, "archetypeAdditionalHTML", false, false, false)); if (additionalHTML != null && ! additionalHTML.isEmpty()) { html.write(additionalHTML, false); } Dependency dependency = new Dependency(); dependency.setGroupId(project.getGroupId()); dependency.setArtifactId(project.getArtifactId()); dependency.setVersion(project.getVersion()); String archetypeAdditionalArguments = replaceProperties(project.getProperties().getProperty("archetypeAdditionalArguments")); HtmlCanvas commandLine = createArchetypesCommandLines(dependency, archetypeAdditionalArguments, false); html.write(commandLine.toHtml(), false) ._div(); return html; }
private String buildHtml() { HtmlCanvas html = new HtmlCanvas(); try { html .head() .title() .content("StreamPipes Connector Worker Container") ._head() .body() .h1().write("Worker Connector Container with ID: " + this.id)._h1() ._body(); } catch (IOException e) { e.printStackTrace(); } return html.toHtml(); } }
private void updateMenu(File htmlFile, List<SubMenuReplacement> subMenuReplacements) throws IOException, MojoExecutionException { if (subMenuReplacements == null || subMenuReplacements.isEmpty()) return; for (SubMenuReplacement subMenuReplacement : subMenuReplacements) { HtmlCanvas html = new HtmlCanvas(); html .li(class_("dropdown-submenu")) .a(href(subMenuReplacement.getOriginalMenuElementLink())).write(subMenuReplacement.getOriginalMenuElement())._a() .ul(class_("dropdown-menu")); if (subMenuReplacement.getSubMenuElements() != null) { for (String subMenuElement : subMenuReplacement.getSubMenuElements().keySet()) { html.render(new SubMenuElement(subMenuElement, subMenuReplacement.getSubMenuElements().get(subMenuElement))); } } html ._ul() ._li(); replaceByLine(htmlFile, "<li.*><a href=.*>" + subMenuReplacement.getOriginalMenuElement() + "</a></li>", formatHtml(html.toHtml())); } }
HtmlCanvas result = new HtmlCanvas(); result = result.h3().write(tag.getName() + " (" + tag.getCommit().getCommittedDate().toString(DateTimeFormat.forPattern("yyyy-MM-dd")) + ")")._h3(); DateTime tagDate = tag.getCommit().getCommittedDate();
private String buildHtml() { HtmlCanvas html = new HtmlCanvas(); try { HtmlCanvas tmp = html .head() .title() .content("StreamPipes Connector Master Container") ._head() .body() .h1().write("Connector Master Container")._h1() .h2().write("All Running Adapters")._h2() .ol(); tmp = getAllRunningAdapters(tmp); html = tmp._ol() ._body(); } catch (IOException e) { logger.error("Error in SP Connect Master Container: ", e); } return html.toHtml(); }
void generateHeader(HtmlCanvas reportPageBody, String cloudSlangImage) throws IOException { HtmlCanvas headerDiv = reportPageBody.div(new HtmlAttributes().id(HEADER_BAR_ID)); HtmlCanvas anchor = headerDiv.a(new HtmlAttributes().href(HTTP_CLOUD_SLANG_IO).target(BLANK)); HtmlCanvas img = new HtmlCanvas().img(new HtmlAttributes().src(cloudSlangImage).alt(CLOUD_SLANG_LOGO_ALT)); anchor.content(img.toHtml(), false); headerDiv._div(); reportPageBody.h1(new HtmlAttributes().class_(REPORT_TITLE_CLASS)).content(TEST_CASE_REPORT); }
@SuppressWarnings("unchecked") protected void generateHTMLReport() throws IOException, SecurityException { html = new HtmlCanvas(); html.html().head(); writeCss(); html.title().content(title + ": Test Cases Coverage Report")._head().body(); html.h1().content("W3C Linked Data Platform (" + title + ") Test Suite: Test Cases Coverage Report"); html.p().a(href("http://www.w3.org/2012/ldp/")).content("See also W3C Linked Data Platform WG")._p(); html.p().a(href(specUri)).content("Specification Requirements Page")._p(); final String commit = BuildProperties.getRevision(); if (commit != null) { html.div() .write("Test Suite Revision: ") .a(href("https://github.com/w3c/ldp-testsuite/commit/" + commit)).content(commit)._div(); } DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH); html.div().content("Updated: " + dateFormat.format(new Date())); // Generate the summary diagrams and information createSummaryReport(); toTop(); // Go through all the classes and generate details of each test case for (@SuppressWarnings("rawtypes") Class testcaseClass: testClasses) { writeTestCasesForClass(testcaseClass); } }
private void displayResultsOnCanvas(StateSpaceExplorer.StateSpaceExplorerResults results) throws IOException, StateSpaceLoaderException { HtmlCanvas html = new HtmlCanvas(); html.html().head(); html.style(type("text/css").media("screen")).content(HTML_STYLE); html._head(); html.body(); if (results.numberOfStates < MAX_DISPLAY_STATES) { StateSpaceLoader.Results stateSpace = stateSpaceLoader.loadStateSpace(); solveSteadyState(stateSpace.records, stateSpace.stateMappings, html); } else { html.write("State space is too large to show tabular results"); html.br(); html.write("Number of states: " + results.numberOfStates); html.br(); html.write("Number of transitions: " + results.processedTransitions); } html._body()._html(); resultsPane.setText(html.toHtml()); }
private HtmlCanvas generateSampleProfileDocumentation(HtmlCanvas html) throws IOException { HtmlCanvas sampleProfile = new HtmlCanvas(); sampleProfile = generateSampleProfile(sampleProfile); html. div(class_("section")). h3(id("Sample_Profile")).write("Sample Profile")._h3(). p().em().write("Based on above properties, here is a sample profile to include in ").a(href("https://maven.apache.org/settings.html")).write("Maven settings.xml file")._a().write(":")._em()._p(). write(sampleProfile.toHtml(), false). write(sampleProfileCommandLineGenerator, false) ._div(); addPropertyInSessionRequest("sampleProfile", sampleProfile.toHtml()); return html; }
public String buildHtml() { HtmlCanvas html = new HtmlCanvas(); try { html