18
18
*/
19
19
20
20
/*
21
- * Copyright (c) 2005, 2017 , Oracle and/or its affiliates. All rights reserved.
21
+ * Copyright (c) 2005, 2018 , Oracle and/or its affiliates. All rights reserved.
22
22
* Portions Copyright 2011 Jens Elkner.
23
23
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected] >.
24
24
*/
@@ -171,6 +171,8 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
171
171
172
172
RuntimeEnvironment env = RuntimeEnvironment .getInstance ();
173
173
174
+ boolean evenRow = true ;
175
+ out .write ("<tbody class=\" search-result\" >" );
174
176
for (Map .Entry <String , ArrayList <Integer >> entry :
175
177
createMap (sh .searcher , sh .hits , start , end ).entrySet ()) {
176
178
String parent = entry .getKey ();
@@ -190,8 +192,7 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
190
192
&& (messages = Util .messagesToJson (p ,
191
193
RuntimeEnvironment .MESSAGES_MAIN_PAGE_TAG
192
194
)).size () > 0 ) {
193
- out .write (" <a " );
194
- out .write ("href=\" " + xrefPrefix + "/" + p .getName () + "\" >" );
195
+ out .write (" <a href=\" " + xrefPrefix + "/" + p .getName () + "\" >" );
195
196
out .write ("<span class=\" important-note important-note-rounded\" data-messages='" + messages + "'>!</span>" );
196
197
out .write ("</a>" );
197
198
}
@@ -205,26 +206,19 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
205
206
Document doc = sh .searcher .doc (docId );
206
207
String rpath = doc .get (QueryBuilder .PATH );
207
208
String rpathE = Util .URIEncodePath (rpath );
208
- DateFormat df ;
209
- out .write ("<tr>" );
209
+ if (evenRow ) {
210
+ out .write ("<tr class=\" search-result-even-row\" >" );
211
+ } else {
212
+ out .write ("<tr>" );
213
+ }
214
+ evenRow = !evenRow ;
210
215
Util .writeHAD (out , sh .contextPath , rpathE , false );
211
216
out .write ("<td class=\" f\" ><a href=\" " );
212
217
out .write (xrefPrefixE );
213
218
out .write (rpathE );
214
219
out .write ("\" " );
215
220
if (env .isLastEditedDisplayMode ()) {
216
- try {
217
- // insert last edited date if possible
218
- df = DateFormat .getDateTimeInstance (DateFormat .SHORT , DateFormat .SHORT );
219
- String dd = df .format (DateTools .stringToDate (doc .get ("date" )));
220
- out .write (" class=\" result-annotate\" title=\" " );
221
- out .write ("Last modified: " );
222
- out .write (dd );
223
- out .write ("\" " );
224
- } catch (ParseException ex ) {
225
- LOGGER .log (
226
- Level .WARNING , "An error parsing date information" , ex );
227
- }
221
+ printLastEditedDate (out , doc );
228
222
}
229
223
out .write (">" );
230
224
out .write (htmlize (rpath .substring (rpath .lastIndexOf ('/' ) + 1 )));
@@ -253,6 +247,20 @@ public static void prettyPrint(Writer out, SearchHelper sh, int start,
253
247
out .write ("</tt></td></tr>\n " );
254
248
}
255
249
}
250
+ out .write ("</tbody>" );
251
+ }
252
+
253
+ private static void printLastEditedDate (final Writer out , final Document doc ) throws IOException {
254
+ try {
255
+ DateFormat df = DateFormat .getDateTimeInstance (DateFormat .SHORT , DateFormat .SHORT );
256
+ String dd = df .format (DateTools .stringToDate (doc .get ("date" )));
257
+ out .write (" class=\" result-annotate\" title=\" " );
258
+ out .write ("Last modified: " );
259
+ out .write (dd );
260
+ out .write ("\" " );
261
+ } catch (ParseException ex ) {
262
+ LOGGER .log (Level .WARNING , "An error parsing date information" , ex );
263
+ }
256
264
}
257
265
258
266
private static void printPlain (PrintPlainFinalArgs fargs , Document doc ,
0 commit comments