
com.android.build.gradle.internal.test.report.TabbedPageRenderer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle Show documentation
Show all versions of gradle Show documentation
Gradle plug-in to build Android applications.
/*
* Copyright 2011 the original author or authors.
*
* 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.android.build.gradle.internal.test.report;
import org.gradle.reporting.ReportRenderer;
import org.gradle.util.GradleVersion;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Date;
public abstract class TabbedPageRenderer extends ReportRenderer {
private T model;
protected T getModel() {
return model;
}
protected abstract String getTitle();
protected abstract ReportRenderer getHeaderRenderer();
protected abstract ReportRenderer getContentRenderer();
protected String getPageTitle() {
return getTitle();
}
@Override
public void render(final T model, SimpleHtmlWriter htmlWriter) throws
IOException {
this.model = model;
htmlWriter.startElement("head")
.startElement("meta").attribute("http-equiv", "Content-Type").attribute("content", "text/html; charset=utf-8").endElement()
.startElement("title").characters(getPageTitle()).endElement()
.startElement("link").attribute("href", "css/base-style.css").attribute("rel", "stylesheet").attribute("type", "text/css").endElement()
.startElement("link").attribute("href", "css/style.css").attribute("rel", "stylesheet").attribute("type", "text/css").endElement()
.startElement("script").attribute("src", "js/report.js").attribute("type", "text/javascript").characters("").endElement() //html does not like
.endElement();
htmlWriter.startElement("body")
.startElement("div").attribute("id", "content")
.startElement("h1").characters(getTitle()).endElement();
getHeaderRenderer().render(model, htmlWriter);
getContentRenderer().render(model, htmlWriter);
htmlWriter.startElement("div").attribute("id", "footer")
.startElement("p").characters("Generated by ")
.startElement("a").attribute("href", "http://www.gradle.org").characters(String.format("Gradle %s", GradleVersion.current().getVersion())).endElement()
.characters(String.format(" at %s", DateFormat.getDateTimeInstance().format(new Date())))
.endElement()
.endElement()
.endElement();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy