]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.document.linking.ui/src/org/simantics/document/linking/report/html/HTMLTocElement.java
Externalize org.simantics.document.linking.ui
[simantics/platform.git] / bundles / org.simantics.document.linking.ui / src / org / simantics / document / linking / report / html / HTMLTocElement.java
1 package org.simantics.document.linking.report.html;
2
3 import org.simantics.document.linking.report.DocumentElement;
4 import org.simantics.document.linking.report.TableOfContents;
5
6
7 public class HTMLTocElement extends HTMLStreamElement implements TableOfContents {
8         
9         
10
11         HTMLTable tocTable;
12         
13         public HTMLTocElement(HTMLDocument writer) throws Exception{
14                 super(writer);
15                 this.os.println(Messages.HTMLTocElement_TocHeading);
16                 tocTable = new HTMLTable(writer, os, false);
17                 tocTable.setHeaderVisible(false);
18                 tocTable.setLinesVisible(false);
19                 tocTable.addColumn("Name", 1.0); //$NON-NLS-1$
20         }
21         
22         @Override
23         public void addTocElement(String label, DocumentElement element) throws Exception{
24                 HTMLElement e = (HTMLElement)element;
25                 if (e.getId() == null)
26                         throw new IllegalArgumentException("Element has no id " + element); //$NON-NLS-1$
27                 //os.println("<a href=\"#" + e.getId() + "\">" + label + "</a><br>");
28                 tocTable.writeRow("<a href=\"#" + e.getId() + "\">" + label + "</a><br>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
29         }
30         
31         public void close() throws Exception{
32                 tocTable.endTable();
33                 os.print("<br>"); //$NON-NLS-1$
34                 super.close();
35         }
36         
37         @Override
38         public String getId() {
39                 return "toc"; //$NON-NLS-1$
40         }
41
42 }