<%
// Java Plug-in Framework (JPF)
// Copyright (C) 2004 - 2005 Dmitry Olshansky
// $Id$
%>
<%
import java.text.*;
import org.java.plugin.*;

function void printFooter() {
%>
<br><br>
<div class="footer">
	<span style="float:left;">Generated by JPF DocGen</span>
	<span style="float:right;"><%= new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US).format(new Date()) %></span>
</div>
<br>
<%
}

function void printDoc(DocGenerator.Tool tool, Documentable obj) {
	Documentation doc = obj.getDocumentation();
	if (doc == null) {
		return;
	}
	println("<h3>" + tool.processDocText(doc.getCaption()) + "</h3>");
	println("<p>" + tool.processDocText(doc.getText()) + "</p>");
	if (doc.getReferences().isEmpty()) {
		return;
	}
	println("<p>References</p><ul>");
	for (Documentation.Reference ref : doc.getReferences()) {
		println("<li><a  href=\"" + tool.getLink(ref) + "\" "
			+ (tool.isAbsoluteUrl(ref.getRef()) ? "target=\"_new\"" : "")
			+ ">" + tool.processDocText(ref.getCaption()) + "</a></li>");
	}
	println("</ul>");
}

function void printAttr(DocGenerator.Tool tool, PluginAttribute attr) {
	println(attr.getId() + " [" + attr.getValue() + "]");
	if (attr.getSubAttributes().isEmpty()) {
		return;
	}
	println("<ul>");
	for (PluginAttribute subAttr : attr.getSubAttributes()) {
		println("<li>");
		printAttr(tool, subAttr);
		println("</li>");
	}
	println("</ul>");
}

function void printParamTableRow(DocGenerator.Tool tool,
                                 ExtensionPoint.ParameterDefinition def, 
                                 int nestedLevel,
                                 boolean isOdd) {
    if(isOdd) {
      print("<tr class=\"odd\">");
    } else {
      print("<tr class=\"even\">");
    }
	print("<td>");
    for(int i =0; i < nestedLevel; i++) {
      print("&nbsp;&nbsp;&nbsp;");
    }
	
	print(def.getId() + "</td>"); 
	print("<td>" + def.getType() + "</td>");
	print("<td>" + def.getMultiplicity() + "</td>");
	print("<td>");
	printParamDoc(tool, def); 
	println("</tr>");
	
	for (ExtensionPoint.ParameterDefinition subDef : def.getSubDefinitions()) {
		printParamTableRow(tool, subDef, nestedLevel + 1, isOdd);
	}  
}
function void printParamDoc(DocGenerator.Tool tool,
        ExtensionPoint.ParameterDefinition def) {
	Documentation doc = def.getDocumentation();
	if (doc == null) {
		return;
	}
	print(tool.processDocText(doc.getText()));        
}

function void printParam(DocGenerator.Tool tool, Extension.Parameter param) {
	println(param.getId() + " [" + param.rawValue() + "]");
	if (param.getSubParameters().isEmpty()) {
		return;
	}
	println("<ul>");
	for (Extension.Parameter subParam : param.getSubParameters()) {
		println("<li>");
		printParam(tool, subParam);
		println("</li>");
	}
}
%>
