1 package org.apache.maven.doxia.book.services.renderer.xdoc;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.Writer;
23 import java.util.Locale;
24
25 import org.apache.maven.doxia.index.IndexEntry;
26 import org.codehaus.plexus.i18n.I18N;
27
28
29
30
31
32
33
34 public class ChapterXdocBookSink
35 extends AbstractXdocBookSink
36 {
37
38 private final IndexEntry chapterIndex;
39
40
41
42
43
44
45
46
47
48 public ChapterXdocBookSink( Writer out, IndexEntry chapterIndex, I18N i18n, Locale locale )
49 {
50 super( out, i18n, locale );
51
52 this.chapterIndex = chapterIndex;
53 }
54
55
56 protected void navigationPanel()
57 {
58 write( "<!--Navigation Panel-->" );
59
60 write( "<table width=\"100%\" align=\"center\">" );
61 write( "<tr>" );
62
63
64
65
66
67 IndexEntry prevChapter = chapterIndex.getPrevEntry();
68
69 write( "<td><div align=\"left\">" );
70
71 previous( prevChapter );
72
73 write( "</div></td>" );
74
75
76
77
78
79 write( "<td><div align=\"center\">" );
80 up();
81 write( "</div></td>" );
82
83
84
85
86
87 write( "<td><div align=\"right\">" );
88
89 next();
90
91 write( "</div></td>" );
92
93 write( "</tr>" );
94 write( "</table>" );
95
96 write( "<!--End of Navigation Panel-->" );
97 }
98
99
100
101
102
103
104 protected void previous( IndexEntry prevChapter )
105 {
106 if ( prevChapter != null )
107 {
108 IndexEntry lastEntry = prevChapter.getLastEntry();
109 if ( lastEntry == null )
110 {
111 write( "<i>Start of book</i>" );
112 }
113 else
114 {
115 write( getString( "previous" ) + ": <a href=\"" + lastEntry.getId() + ".html\">" );
116 content( lastEntry.getTitle() );
117 write( "</a>" );
118 }
119 }
120 else
121 {
122 write( getString( "previous" ) + ":<a href=\"index.html\">" + getString( "toc" ) + "</a>" );
123 }
124 }
125
126
127
128
129 protected void up()
130 {
131 write( getString( "up" ) + ": <a href=\"index.html\">" + getString( "toc" ) + "</a>" );
132 }
133
134
135
136
137 protected void next()
138 {
139 IndexEntry firstEntry = chapterIndex.getFirstEntry();
140 if ( firstEntry == null )
141 {
142 write( "<i>End of book</i>" );
143 }
144 else
145 {
146 write( getString( "next" ) + ": <a href=\"" + firstEntry.getId() + ".html\">" );
147 content( firstEntry.getTitle() );
148 write( "</a>" );
149 }
150 }
151 }