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 SectionXdocBookSink
35 extends AbstractXdocBookSink
36 {
37
38 private final IndexEntry indexEntry;
39
40
41
42
43
44
45
46
47
48 public SectionXdocBookSink( Writer out, IndexEntry indexEntry, I18N i18n, Locale locale )
49 {
50 super( out, i18n, locale );
51
52 this.indexEntry = indexEntry;
53 }
54
55
56 protected void navigationPanel()
57 {
58 write( "<!--Navigation Panel-->" );
59
60 write( "<table width=\"100%\" align=\"center\" border=\"0\">" );
61 write( "<tr>" );
62
63 IndexEntry parent = indexEntry.getParent();
64
65
66
67
68
69 IndexEntry prevEntry = indexEntry.getPrevEntry();
70
71 write( "<td align=\"left\">" );
72
73 previous( parent, prevEntry );
74
75 write( "</td>" );
76
77
78
79
80
81 write( "<td align=\"center\">" );
82 up( parent );
83 write( "</td>" );
84
85
86
87
88
89 IndexEntry nextEntry = indexEntry.getNextEntry();
90
91 write( "<td align=\"right\">" );
92
93 next( parent, nextEntry );
94
95 write( "</td>" );
96
97 write( "</tr>" );
98 write( "</table>" );
99
100 write( "<!--End of Navigation Panel-->" );
101 }
102
103
104
105
106
107
108
109 protected void previous( IndexEntry parent, IndexEntry prevEntry )
110 {
111 if ( prevEntry != null )
112 {
113 write( getString( "previous" ) + ": <a href=\"" + prevEntry.getId() + ".html\">" );
114 content( prevEntry.getTitle() );
115 write( "</a>" );
116 }
117 else
118 {
119 write( getString( "previous" ) + ": <a href=\"" + parent.getId() + ".html\">" );
120 content( parent.getTitle() );
121 write( "</a>" );
122 }
123 }
124
125
126
127
128
129
130
131 protected void up( IndexEntry parent )
132 {
133 write( getString( "up" ) + ": <a href=\"" + parent.getId() + ".html\">" + parent.getTitle() + "</a>" );
134 }
135
136
137
138
139
140
141
142 protected void next( IndexEntry parent, IndexEntry nextEntry )
143 {
144 if ( nextEntry != null )
145 {
146 write( getString( "next" ) + ": <a href=\"" + nextEntry.getId() + ".html\">" );
147 content( nextEntry.getTitle() );
148 write( "</a>" );
149 }
150 else
151 {
152 IndexEntry nextChapter = parent.getNextEntry();
153
154 if ( nextChapter == null )
155 {
156 write( "<i>End of book</i>" );
157 }
158 else
159 {
160 write( getString( "next" ) + ": <a href=\"" + nextChapter.getId() + ".html\">" );
161 content( nextChapter.getTitle() );
162 write( "</a>" );
163 }
164 }
165 }
166 }