<%--
 * Copyright by Intland Software
 *
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Intland Software. ("Confidential Information"). You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Intland.
 *
 * $Revision$ $Date$
--%>

<%@ taglib uri="jstl-c" prefix="c" %>
<%@ taglib uri="jstl-fmt" prefix="fmt" %>
<%@ taglib uri="jstl-fn" prefix="fn" %>

<%@ taglib uri="struts-html" prefix="html" %>


<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<%@ taglib uri="uitaglib" prefix="ui" %>

<ui:title style="top-sub-headline-decoration" >
		<c:choose>
			<c:when test="${!empty param.ruleFilter}">
				Rule: <c:out value="${param.ruleFilter}" />
			</c:when>

			<c:when test="${!empty param.fileFilter}">
				Violations by Rules
			</c:when>
		</c:choose>
	</ui:title>

<TABLE CLASS="displaytag" cellpadding="0">

<c:set var="previousFileName" value="" />

<%
	int counter = 0;
%>
<c:forEach var="ruleViolations" items="${violations.fileViolationValues}">
	<c:forEach var="violation" items="${ruleViolations}">
		<c:set var="filename" value="${violation.fileName}" />
		<c:set var="lineNumber" value="${violation.lineNumber}" />

		<c:url var="viewerLink" value="/proj/popupViewSource.do">
			<c:param name="filename" value="${filename}" />
			<c:param name="windowTitle" value="${filename}" />
			<c:param name="gotoline" value="${lineNumber}" />
		</c:url>

		<c:set var="onclick" value="launch_url('${viewerLink}#line_${lineNumber}','null'); return false;" />

		<c:if test="${filename != previousFileName}">
	<%
			counter = 0;
	%>
			<c:if test="${!empty previousFileName}">
				<%-- Just a gap --%>
				<TR>
					<TD HEIGHT="10"></TD>
				</TR>
			</c:if>

			<c:set var="fileViolations" value="${violations.fileViolations[filename]}" />

			<TR>
				<TH CLASS="textData"><c:out value="${filename}" /> (<fmt:formatNumber value="${fn:length(fileViolations)}" />)</TH>

				<TH CLASS="numberData">Line</TH>
			</TR>

			<c:set var="previousFileName" value="${filename}" />
		</c:if>

		<TR CLASS="<%=((counter++ % 2) == 0 ? "even" : "odd")%>">
			<TD CLASS="textData"><c:out value="${violation.message}" /></TD>

			<TD CLASS="numberData"><html:link onclick="${onclick}" href="${viewerLink}">
					<c:out value="${lineNumber}" />
				</html:link></TD>
		</TR>
	</c:forEach>
</c:forEach>

</TABLE>
