<%--
 * 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$
--%>
<meta name="decorator" content="main">
<meta name="module" content="sources">
<meta name="moduleCSSClass" content="sourceCodeModule">
<meta name="stylesheet" content="sources.css">


<%@ 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="charttaglib" prefix="chart" %>
<%@ taglib uri="uitaglib" prefix="ui" %>

<%
	final String headercolumnSeparator = "<TD WIDTH=\"1\"><IMG BORDER=\"0\" SRC=\""
		+ request.getContextPath()
		+ "/images/space.gif\" WIDTH=\"1\"></TD>";
	final String columnSeparator = "<TD WIDTH=\"1\" CLASS=\"colseparator\"></TD>";

	final int colSpan = 7;
	final String lineBreak = "<TR><TD>&nbsp;</TD></TR>";
	int counter = 0;
%>

<c:set var="whtd" value="600" />
<c:set var="hght" value="180" />

<c:set var="seriesPaint" value="#336633" />

<c:set var="screenTitle">
	Most Critical Functions
</c:set>

<c:set var="screenFilter" scope="request">
	<html:form action="/proj/sources/criticalFunctionsFilter" method="get">

		<c:set var="limit" value="${criticalSymbols.map.limit}" />
		<c:if test="${empty limit}">
			<c:set var="limit" value="25" />
		</c:if>

		<span class="titlenormal">Show only the top</span>
		<html:select property="limit" value="${limit}">
			<html:option value="25">&nbsp;25</html:option>
			<html:option value="50">&nbsp;50</html:option>
			<html:option value="100">100</html:option>
			<html:option value="500">500</html:option>
		</html:select>

		&nbsp;<html:submit styleClass="button" property="GO" value="GO" />

	</html:form>
</c:set>

<jsp:include page="includes/actionBar.jsp" >
	<jsp:param name="screenTitle" value="${screenTitle}"/>
	<jsp:param name="screenFilter" value="${screenFilter}" />
</jsp:include>

<c:set var="proj_id" value="${PROJECT_DTO.id}" />

<chart:query name="mostCriticalMethods" var="functions">
	<chart:param name="proj_id" value="${proj_id}" />
	<chart:param name="limit" value="${limit}" />
</chart:query>

<ui:title style="top-sub-headline-decoration" >
		Functions/Methods (top <fmt:formatNumber value="${fn:length(functions)}" />) with the Top number of Body Lines
	</ui:title>

<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
<%-- Create Chart --%>
<chart:create var="chart" type="stackedbar" width="${whtd}" height="${hght}"
	tooltips="false" yaxisLabel="# Lines">

	<chart:dataset type="category" value="${functions}"
		categoryProperties="body_lines"
		valueProperties="body_lines"
		seriesLabels="body_lines" />

	<chart:renderer series="0" paint="${seriesPaint}" />
	<chart:axis visible="false" />
</chart:create>

<TR>
	<%-- Display the Chart --%>
	<TD COLSPAN="<%=colSpan%>" WIDTH="<c:out value="${chart.width}" />"
		HEIGHT="<c:out value="${chart.height}" />"><html:img alt="Chart" border="0"
		width="${chart.width}" height="${chart.height}"
		page="/writeChart?id=${chart.id}" /></TD>
</TR>
<%= lineBreak %>

<TR CLASS="head">
	<TH ALIGN="center">&nbsp;# Body Lines&nbsp;</TH>
	<%=headercolumnSeparator%>

	<TH ALIGN="left">&nbsp;Function/Method</TH>
	<%=headercolumnSeparator%>

	<TH ALIGN="left">&nbsp;Class</TH>
	<%=headercolumnSeparator%>

	<TH ALIGN="left">&nbsp;Package</TH>

</TR>

<c:forEach items="${functions}" var="function">
	<TR CLASS="<%=((counter++ % 2) == 0 ? "even" : "odd")%>">

	<c:set var="symbol_name" value="${function.name}" />
	<c:set var="class_name" value="${function.class}" />
	<c:set var="package_name" value="${function.package}" />
	<c:set var="file_id" value="${function.file_id}" />
	<c:set var="high_start_offset" value="${function.high_start_offset}" />

	<c:url var="link" value="/proj/sources/searchAndViewSymbol.spr">
		<c:param name="file_id" value="${file_id}" />
		<c:param name="high_start_offset" value="${high_start_offset}" />
		<c:param name="symbolName" value="${symbol_name}" />
		<c:param name="className" value="${class_name}" />
		<c:param name="packageName" value="${package_name}" />
	</c:url>

	<TD NOWRAP ALIGN="right">&nbsp;<fmt:formatNumber value="${function.body_lines}" />&nbsp;</TD>
	<%=columnSeparator%>

	<TD NOWRAP ALIGN="left">&nbsp;<html:link href="${link}"
		anchor="${high_start_offset}">
		<c:out value="${symbol_name}" /></html:link>&nbsp;</TD>
	<%=columnSeparator%>

	<TD NOWRAP ALIGN="left">&nbsp;<c:out value="${class_name}" />&nbsp;</TD>
	<%=columnSeparator%>

	<TD NOWRAP ALIGN="left">&nbsp;<c:out value="${package_name}" />&nbsp;</TD>

	</TR>
</c:forEach>

</TABLE>

<%-- Deepest Compound statements --%>

<chart:query name="mostCriticalFunctionsDeepest" var="functions">
	<chart:param name="proj_id" value="${proj_id}" />
	<chart:param name="limit" value="${limit}" />
</chart:query>

<ui:title style="top-sub-headline-decoration" >
		Functions/Methods (top <fmt:formatNumber value="${fn:length(functions)}" />) with the Deepest
			Compound Statements
	</ui:title>

<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
<%-- Create Chart --%>
<chart:create var="chart" type="stackedbar" width="${whtd}" height="${hght}"
	tooltips="false" yaxisLabel="# Level">

	<chart:dataset type="category" value="${functions}"
		categoryProperties="deepest_compound_level"
		valueProperties="deepest_compound_level"
		seriesLabels="deepest_compound_level" />

	<chart:renderer series="0" paint="${seriesPaint}" />
	<chart:axis visible="false" />
</chart:create>

<TR>
	<%-- Display the Chart --%>
	<TD COLSPAN="<%=colSpan%>" WIDTH="<c:out value="${chart.width}" />"
		HEIGHT="<c:out value="${chart.height}" />"><html:img alt="Chart" border="0"
		width="${chart.width}" height="${chart.height}"
		page="/writeChart?id=${chart.id}" /></TD>
</TR>

<%= lineBreak %>

<TR CLASS="head">
	<TH ALIGN="center">&nbsp;# Level&nbsp;</TH>
	<%=headercolumnSeparator%>

	<TH ALIGN="left">&nbsp;Function/Method</TH>
	<%=headercolumnSeparator%>

	<TH ALIGN="left">&nbsp;Class</TH>
	<%=headercolumnSeparator%>

	<TH ALIGN="left">&nbsp;Package</TH>
</TR>

<%	counter = 0;	%>
<c:forEach items="${functions}" var="function">
	<TR CLASS="<%=((counter++ % 2) == 0 ? "even" : "odd")%>">

	<c:set var="symbol_name" value="${function.name}" />
	<c:set var="class_name" value="${function.class}" />
	<c:set var="package_name" value="${function.package}" />
	<c:set var="file_id" value="${function.file_id}" />
	<c:set var="high_start_offset" value="${function.high_start_offset}" />

	<c:url var="link" value="/proj/viewSource.do">
		<c:param name="file_id" value="${file_id}" />
		<c:param name="high_start_offset" value="${high_start_offset}" />
	</c:url>

	<TD NOWRAP ALIGN="right">&nbsp;<fmt:formatNumber
		value="${function.deepest_compound_level}" />&nbsp;</TD>
	<%=columnSeparator%>

	<TD NOWRAP ALIGN="left">&nbsp;<html:link href="${link}" anchor="${high_start_offset}">
		<c:out value="${symbol_name}" /></html:link>&nbsp;</TD>
	<%=columnSeparator%>

	<TD NOWRAP ALIGN="left">&nbsp;<c:out value="${class_name}" />&nbsp;</TD>
	<%=columnSeparator%>

	<TD NOWRAP ALIGN="left">&nbsp;<c:out value="${package_name}" />&nbsp;</TD>

	</TR>
</c:forEach>

</TABLE>

<%-- Most Statements-in-Bodies --%>

<chart:query name="mostCriticalFunctionsExecutable" var="functions">
	<chart:param name="proj_id" value="${proj_id}" />
	<chart:param name="limit" value="${limit}" />
</chart:query>

<ui:title style="top-sub-headline-decoration" >
		Functions/Methods (top <fmt:formatNumber value="${fn:length(functions)}" />) with the Top number of
			Executable Statements
	</ui:title>

<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
<%-- Create Chart --%>
<chart:create var="chart" type="stackedbar" width="${whtd}" height="${hght}"
	tooltips="false" yaxisLabel="# Statements">

	<chart:dataset type="category" value="${functions}"
		categoryProperties="statements_in_body"
		valueProperties="statements_in_body"
		seriesLabels="statements_in_body" />

	<chart:renderer series="0" paint="${seriesPaint}" />
	<chart:axis visible="false" />
</chart:create>

<TR>
	<%-- Display the Chart --%>
	<TD COLSPAN="<%=colSpan%>" WIDTH="<c:out value="${chart.width}" />"
		HEIGHT="<c:out value="${chart.height}" />"><html:img alt="Chart" border="0"
		width="${chart.width}" height="${chart.height}"
		page="/writeChart?id=${chart.id}" /></TD>
</TR>

<%= lineBreak %>

<TR CLASS="head">
	<TH ALIGN="center">&nbsp;# Statements&nbsp;</TH>
	<%=headercolumnSeparator%>

	<TH ALIGN="left">&nbsp;Function/Method</TH>
	<%=headercolumnSeparator%>

	<TH ALIGN="left">&nbsp;Class</TH>
	<%=headercolumnSeparator%>

	<TH ALIGN="left">&nbsp;Package</TH>

</TR>

<%	counter = 0;	%>
<c:forEach items="${functions}" var="function">
	<TR CLASS="<%=((counter++ % 2) == 0 ? "even" : "odd")%>">

	<c:set var="symbol_name" value="${function.name}" />
	<c:set var="class_name" value="${function.class}" />
	<c:set var="package_name" value="${function.package}" />
	<c:set var="file_id" value="${function.file_id}" />
	<c:set var="high_start_offset" value="${function.high_start_offset}" />

	<c:url var="link" value="/proj/viewSource.do">
		<c:param name="file_id" value="${file_id}" />
		<c:param name="high_start_offset" value="${high_start_offset}" />
	</c:url>

	<TD NOWRAP ALIGN="right">&nbsp;<fmt:formatNumber
		value="${function.statements_in_body}" />&nbsp;</TD>
	<%=columnSeparator%>

	<TD NOWRAP ALIGN="left">&nbsp;<html:link href="${link}" anchor="${high_start_offset}">
		<c:out value="${symbol_name}" /></html:link>&nbsp;</TD>
	<%=columnSeparator%>

	<TD NOWRAP ALIGN="left">&nbsp;<c:out value="${class_name}" />&nbsp;</TD>
	<%=columnSeparator%>

	<TD NOWRAP ALIGN="left">&nbsp;<c:out value="${package_name}" />&nbsp;</TD>

	</TR>
</c:forEach>

</TABLE>

<%-- Most Function Parameters --%>

<chart:query name="mostCriticalFunctionsParameters" var="functions">
	<chart:param name="proj_id" value="${proj_id}" />
	<chart:param name="limit" value="${limit}" />
</chart:query>

<ui:title style="top-sub-headline-decoration" header="Functions/Methods (top ${fn:length(functions)} ) with the Top number of Parameters" />

<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
<%-- Create Chart --%>
<chart:create var="chart" type="stackedbar" width="${whtd}" height="${hght}"
	tooltips="false" yaxisLabel="# Parameters">

	<chart:dataset type="category" value="${functions}"
		categoryProperties="argument_nr"
		valueProperties="argument_nr"
		seriesLabels="argument_nr" />

	<chart:renderer series="0" paint="${seriesPaint}" />
	<chart:axis visible="false" />
</chart:create>

<TR>
	<%-- Display the Chart --%>
	<TD COLSPAN="<%=colSpan%>" WIDTH="<c:out value="${chart.width}" />"
		HEIGHT="<c:out value="${chart.height}" />"><html:img alt="Chart" border="0"
		width="${chart.width}" height="${chart.height}"
		page="/writeChart?id=${chart.id}" /></TD>
</TR>

<%= lineBreak %>

<TR CLASS="head">
	<TH ALIGN="center">&nbsp;# Parameters&nbsp;</TH>
	<%=headercolumnSeparator%>

	<TH ALIGN="left">&nbsp;Function/Method</TH>
	<%=headercolumnSeparator%>

	<TH ALIGN="left">&nbsp;Class</TH>
	<%=headercolumnSeparator%>

	<TH ALIGN="left">&nbsp;Package</TH>

</TR>

<%	counter = 0;	%>
<c:forEach items="${functions}" var="function">
	<TR CLASS="<%=((counter++ % 2) == 0 ? "even" : "odd")%>">

	<c:set var="symbol_name" value="${function.name}" />
	<c:set var="class_name" value="${function.class}" />
	<c:set var="package_name" value="${function.package}" />
	<c:set var="file_id" value="${function.file_id}" />
	<c:set var="high_start_offset" value="${function.high_start_offset}" />

	<c:url var="link" value="/proj/viewSource.do">
		<c:param name="file_id" value="${file_id}" />
		<c:param name="high_start_offset" value="${high_start_offset}" />
	</c:url>

	<TD NOWRAP ALIGN="right">&nbsp;<fmt:formatNumber value="${function.argument_nr}" />&nbsp;</TD>
	<%=columnSeparator%>

	<TD NOWRAP ALIGN="left">&nbsp;<html:link href="${link}" anchor="${high_start_offset}">
		<c:out value="${symbol_name}" /></html:link>&nbsp;</TD>
	<%=columnSeparator%>

	<TD NOWRAP ALIGN="left">&nbsp;<c:out value="${class_name}" />&nbsp;</TD>
	<%=columnSeparator%>

	<TD NOWRAP ALIGN="left">&nbsp;<c:out value="${package_name}" />&nbsp;</TD>

	</TR>
</c:forEach>

</TABLE>
