NodePage.java revision a6d2b043f09984e3f2fe77e9f7502564350055f6
1/*******************************************************************************
2 * Copyright (c) 2009, 2016 Mountainminds GmbH & Co. KG and Contributors
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 *    Marc R. Hoffmann - initial API and implementation
10 *
11 *******************************************************************************/
12package org.jacoco.report.internal.html.page;
13
14import org.jacoco.core.analysis.ICoverageNode;
15import org.jacoco.report.internal.ReportOutputFolder;
16import org.jacoco.report.internal.html.IHTMLReportContext;
17import org.jacoco.report.internal.html.resources.Resources;
18import org.jacoco.report.internal.html.resources.Styles;
19import org.jacoco.report.internal.html.table.ITableItem;
20
21/**
22 * Report page that represents a coverage node.
23 *
24 * @param 
25 *            type of the node represented by this page
26 */
27public abstract class NodePage<NodeType extends ICoverageNode> extends
28		ReportPage implements ITableItem {
29
30	private final NodeType node;
31
32	/**
33	 * Creates a new node page.
34	 *
35	 * @param node
36	 *            corresponding node
37	 * @param parent
38	 *            optional hierarchical parent
39	 * @param folder
40	 *            base folder to create this page in
41	 * @param context
42	 *            settings context
43	 */
44	protected NodePage(final NodeType node, final ReportPage parent,
45			final ReportOutputFolder folder, final IHTMLReportContext context) {
46		super(parent, folder, context);
47		this.node = node;
48	}
49
50	// === ILinkable ===
51
52	public String getLinkStyle() {
53		if (isRootPage()) {
54			return Styles.EL_REPORT;
55		} else {
56			return Resources.getElementStyle(node.getElementType());
57		}
58	}
59
60	public String getLinkLabel() {
61		return node.getName();
62	}
63
64	// === ICoverageTableItem ===
65
66	public NodeType getNode() {
67		return node;
68	}
69
70}
71