<%@ jet package="org.eclipse.emf.exporter.html" imports="java.util.* org.eclipse.emf.common.util.URI org.eclipse.emf.ecore.* org.eclipse.emf.ecore.util.EcoreUtil org.eclipse.emf.codegen.ecore.genmodel.GenPackage" class="PackageHTML"%>
<%
/**
 * Copyright (c) 2006-2009 IBM Corporation and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v20.html
 * 
 * Contributors: 
 *   IBM - Initial API and implementation
 */
%>
<%HTMLExporter htmlExporter = (HTMLExporter)argument;%>
<%GenPackage genPackage = htmlExporter.getCurrentGenPackage();%>
<%EPackage ePackage = genPackage.getEcorePackage();%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title><%=genPackage.getQualifiedPackageName()%></title>
		
		<style>
		<!--
			body {font-size: 10pt; clip: rect(); margin-top: 5mm; margin-left: 3mm}
			h1 {font-size: 22px; font-weight: bold; color:white; background-color:#595791}
			h2 {font-size: 16pt; font-weight: bold ; line-height: 20px; background-color:#FFFFCF}
			h3 {font-size: 12pt}
			p, table, td, th {font-size: 10pt}
			code {font-size: 10pt}
			li {font-size: 10pt; line-height: 20px}
			
			table.details {font: 11px/24px Verdana, Arial, Helvetica, sans-serif; border-collapse: collapse; width: 480px;}
			table.details td.left  {order-bottom: 1px solid #CCC;	padding: 0 0.5em; vertical-align: text-top;}
			table.details td.right {order-bottom: 1px solid #CCC;	padding: 0 0.5em; text-align: right; vertical-align: text-top;}
			table.details tr.documentation {background: #f9fff9;}
			table.details tr.odd           {background: #e3f0f7;}
			table.details tr.even          {background: #f7f7f7;}
		-->
		</style>
		
		<script language="JavaScript" type="text/javascript">
		<!--
			function openSection(sectionId, open)
			{
				var section = document.getElementById(sectionId);
				section.style.display = open ? 'block' : 'none';
			}
			
			function selectAllChechboxes(elements, select)
			{
				for (var i = 0; i < elements.length; i++)
				{
					elements[i].checked = select;
					openSection(elements[i].value, select);
				}
			}
		// -->
		</script>
	</head>

	<body lang="EN-US"><form name="packform" method="post">
		<h1>Package: <i><%=genPackage.getQualifiedPackageName()%></i></h1>
			<table border="1" cellpadding="2" cellspacing="0" summary="Package details.">
			<%GenPackage superGenPackage = genPackage.getSuperGenPackage(); if (superGenPackage != null) { URI packageArtifactURI = htmlExporter.getPackageArtifacttURI(superGenPackage.getEcorePackage());%>
				<tr>
					<td>Super Package</td>
			<%if (packageArtifactURI != null) {%>
					<td><a href="<%=packageArtifactURI.toString()%>"><%=superGenPackage.getQualifiedPackageName()%></a></td>
			<%} else {%>
					<td><%=superGenPackage.getQualifiedPackageName()%></td>
			<%}%>
				</tr>
			<%}%>
				<tr>
					<td>Ecore URI</td>
					<td><%=ePackage.eResource().getURI().toString()%></td>
				</tr>
				<tr>
					<td>GenModel URI</td>
					<td><%=genPackage.getGenModel().eResource().getURI().toString()%></td>
				</tr>
				<tr>
					<td>Namespace URI</td>
					<td><%=ePackage.getNsURI()%></td>
				</tr>
				<tr>
					<td>Namespace Prefix</td>
					<td><%=ePackage.getNsPrefix()%></td>
				</tr>
		<%String packageDocumentation = EcoreUtil.getDocumentation(ePackage); if (packageDocumentation != null) {%>
				<tr>
					<td>Documentation</td>
					<td><%=htmlExporter.getLongText(packageDocumentation)%></td>
				</tr>
		<%}%>
			</table>

			<p><input type="checkbox" onclick="javascript:selectAllChechboxes(document.packform.detailCheckbox, this.checked)"/>expand all details</p>

<%int detailsCounter=0; Collection<EClass> eClasses = EcoreUtil.getObjectsByType(ePackage.getEClassifiers(), EcorePackage.Literals.ECLASS);%>
<%if (!eClasses.isEmpty()) {%>
		<h1>Classes</h1><%for (EClass eClass : eClasses) { %>
			<h2><%=htmlExporter.computeClassifierLabel(eClass)%></h2>
		<%String classDocumentation = EcoreUtil.getDocumentation(eClass); if (classDocumentation != null) {%>
				<h3>Documentation</h3>
					<%=htmlExporter.getLongText(classDocumentation)%>
		<%}%>
				<h3>Details</h3>
				<dt>
					<dd><table class="details"><%int row=0; String classConstraints = htmlExporter.computeConstraints(eClass); if (classConstraints != null) {%>
						<tr class="<%=(++row)%2 == 0 ? "even" : "odd"%>"><td class="left">constraints</td><td class="right"><%=classConstraints%></td></tr><%} for (EStructuralFeature detail : htmlExporter.getDetails(eClass)) {%>
						<tr class="<%=(++row)%2 == 0 ? "even" : "odd"%>"><td class="left"><%=detail.getName()%></td><td class="right"><tt><%=HTMLExporter.escape(eClass.eGet(detail).toString())%></tt></td></tr><%}%>
					</table></dd>
				</dt>
		<%if (!eClass.getEGenericSuperTypes().isEmpty()) {%>
				<h3>Super Classes</h3>
					<ul><%for (EGenericType eSuperType : eClass.getEGenericSuperTypes()) {%>
						<li><tt><%=htmlExporter.computeLabel(eSuperType)%></tt></li><%}%>
					</ul>
		<%}%>
		<%if (!eClass.getEAttributes().isEmpty()) {%>
				<h3>Attributes</h3>
					<ul><%for (EAttribute eAttribute : eClass.getEAttributes()) {%>
						<li>
							<input type="checkbox" name="detailCheckbox" value="detail<%=++detailsCounter%>" onclick="javascript:openSection(this.value, this.checked)"/> <%=htmlExporter.computeTypedElementLabel(eAttribute)%>
							<div id="detail<%=detailsCounter%>" name="detail<%=detailsCounter%>" style="overflow:hidden;display:none">
								<table class="details"><%String attributeDocumentation = EcoreUtil.getDocumentation(eAttribute); if (attributeDocumentation != null) {%>
									<tr class="documentation"><td class="left" colspan="2"><%=attributeDocumentation%></td></tr><%} row=0; String attributeConstraints = htmlExporter.computeConstraints(eAttribute); if (attributeConstraints != null) {%>
									<tr class="<%=(++row)%2 == 0 ? "even" : "odd"%>"><td class="left">constraints</td><td class="right"><%=attributeConstraints%></td></tr><%} for (EStructuralFeature detail : htmlExporter.getDetails(eAttribute)) {%>
									<tr class="<%=(++row)%2 == 0 ? "even" : "odd"%>"><td class="left"><%=detail.getName()%></td><td class="right"><tt><%=eAttribute.eGet(detail)%></tt></td></tr><%}%>
								</table><br />
							</div>
						</li><%}%>
					</ul>
		<%}%>
		<%if (!eClass.getEReferences().isEmpty()) {%>
				<h3>References</h3>
					<ul><%for (EReference eReference : eClass.getEReferences()) {%>
						<li>
							<input type="checkbox" name="detailCheckbox" value="detail<%=++detailsCounter%>" onclick="javascript:openSection(this.value, this.checked)"/> <%=htmlExporter.computeTypedElementLabel(eReference)%>
							<div id="detail<%=detailsCounter%>" name="detail<%=detailsCounter%>" style="overflow:hidden;display:none">
								<table class="details"><%String referenceDocumentation = EcoreUtil.getDocumentation(eReference); if (referenceDocumentation != null) {%>
									<tr class="documentation"><td class="left" colspan="2"><%=referenceDocumentation%></td></tr><%} row=0; String referenceConstraints = htmlExporter.computeConstraints(eReference); if (referenceConstraints != null) {%>
									<tr class="<%=(++row)%2 == 0 ? "even" : "odd"%>"><td class="left">constraints</td><td class="right"><%=referenceConstraints%></td></tr><%} if (eReference.getEOpposite() != null) {%>
									<tr class="<%=(++row)%2 == 0 ? "even" : "odd"%>"><td class="left">opposite</td><td class="right"><%=htmlExporter.computeLabel(eReference.getEOpposite())%></td></tr> <%} if (!eReference.getEKeys().isEmpty()) {%>
									<tr class="<%=(++row)%2 == 0 ? "even" : "odd"%>"><td class="left">key(s)</td><td class="right"><%=htmlExporter.computeEKeys(eReference)%></td></tr> <%} for (EStructuralFeature detail : htmlExporter.getDetails(eReference)) {%>
									<tr class="<%=(++row)%2 == 0 ? "even" : "odd"%>"><td class="left"><%=detail.getName()%></td><td class="right"><tt><%=eReference.eGet(detail)%></tt></td></tr><%}%>
								</table><br />
							</div>
						</li><%}%>
					</ul>
		<%}%>
		<%if (!eClass.getEOperations().isEmpty()) {%>
				<h3>Operations</h3>
					<ul><%for (EOperation eOperation : eClass.getEOperations()) {%>
						<li>
							<input type="checkbox" name="detailCheckbox" value="detail<%=++detailsCounter%>" onclick="javascript:openSection(this.value, this.checked)"/> <%=htmlExporter.computeLabel(eOperation)%>
							<div id="detail<%=detailsCounter%>" name="detail<%=detailsCounter%>" style="overflow:hidden;display:none">
								<table class="details"><%String operationDocumentation = EcoreUtil.getDocumentation(eOperation); if (operationDocumentation != null) {%>
									<tr class="documentation"><td class="left" colspan="2"><%=operationDocumentation%></td></tr><%} row=0; String operationConstraints = htmlExporter.computeConstraints(eOperation); if (operationConstraints != null) {%>
									<tr class="<%=(++row)%2 == 0 ? "even" : "odd"%>"><td class="left">constraints</td><td class="right"><%=operationConstraints%></td></tr><%} for (EStructuralFeature detail : htmlExporter.getDetails(eOperation)) {%>
									<tr class="<%=(++row)%2 == 0 ? "even" : "odd"%>"><td class="left"><%=detail.getName()%></td><td class="right"><tt><%=eOperation.eGet(detail)%></tt></td></tr><%}%>
								</table><br />
							</div>
						</li><%}%>
					</ul>
		<%}%>
	<%}%>
<%}%>

<%Collection<EEnum> eEnums = EcoreUtil.getObjectsByType(ePackage.getEClassifiers(), EcorePackage.Literals.EENUM);%>
<%if (!eEnums.isEmpty()) {%>		
		<h1>Enumerations</h1><%for (EEnum eEnum : eEnums) {%>
			<h2><a name="<%=eEnum.getName()%>"><%=eEnum.getName()%></a></h2><%if (!eEnum.getELiterals().isEmpty()) {%>
		<%String enumDocumentation = EcoreUtil.getDocumentation(eEnum); if (enumDocumentation != null) {%>
				<h3>Documentation</h3>
					<%=htmlExporter.getLongText(enumDocumentation)%>
		<%}%>
				<h3>Literals</h3>
					<ul><%for (EEnumLiteral eEnumLiteral : eEnum.getELiterals()) {%>
						<li>
							<input type="checkbox" name="detailCheckbox" value="detail<%=++detailsCounter%>" onclick="javascript:openSection(this.value, this.checked)"/> <%=htmlExporter.computeLabel(eEnumLiteral)%>
							<div id="detail<%=detailsCounter%>" name="detail<%=detailsCounter%>" style="overflow:hidden;display:none">
								<table class="details"><%String enumLiteralDocumentation = EcoreUtil.getDocumentation(eEnumLiteral); if (enumLiteralDocumentation != null) {%>
									<tr class="documentation"><td class="left" colspan="2"><%=enumLiteralDocumentation%></td></tr><%} int row = 0; for (EStructuralFeature detail : htmlExporter.getDetails(eEnumLiteral)) {%>
									<tr class="<%=(++row)%2 == 0 ? "even" : "odd"%>"><td class="left"><%=detail.getName()%></td><td class="right"><tt><%=eEnumLiteral.eGet(detail)%></tt></td></tr><%}%>
								</table><br />
							</div>
						</li><%}%>
					</ul><%}%><%}%>
<%}%>

<%Collection<EDataType> eDataTypes = EcoreUtil.getObjectsByType(ePackage.getEClassifiers(), EcorePackage.Literals.EDATA_TYPE); eDataTypes.removeAll(eEnums);%>
<%if (!eDataTypes.isEmpty()) {%>		
		<h1>Data Types</h1><%for (EDataType eDataType : eDataTypes) {%>
			<h2><%=htmlExporter.computeClassifierLabel(eDataType)%></h2>
		<%String dataTypeDocumentation = EcoreUtil.getDocumentation(eDataType); if (dataTypeDocumentation != null) {%>
				<h3>Documentation</h3>
					<%=htmlExporter.getLongText(dataTypeDocumentation)%>
		<%}%>
				<h3>Details</h3>
				<dt>
					<dd>
						<table class="details"><%int row = 0; for (EStructuralFeature detail : htmlExporter.getDetails(eDataType)) {%>
							<tr class="<%=(++row)%2 == 0 ? "even" : "odd"%>"><td class="left"><%=detail.getName()%></td><td class="right"><tt><%=HTMLExporter.escape(eDataType.eGet(detail).toString())%></tt></td></tr><%}%>
						</table>
					</dd><%}%>
				</dt>
<%}%>
	</form></body>
</html>
