if (viewerId == null)
return;
/* Ask for sorted Elements */
ContentViewer viewer = fRegistry.get(viewerId);
ILabelProvider labelProvider = (ILabelProvider) viewer.getLabelProvider();
Object[] children = new Object[0];
if (viewer instanceof NewsBrowserViewer)
children = ((NewsBrowserViewer) viewer).getFlattendChildren(elements);
/* Write HTML to the Receiver */
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
/* Send Headers (Bug on Mac: Header printed in Browser) */
if (Application.IS_MAC)
writer.append("<!--").append(CRLF);
writer.append("HTTP/1.x 200 OK").append(CRLF);
writer.append("Date: ").append(RFC_1123_DATE.format(new Date())).append(CRLF);
writer.append("Server: RSSOwl Local Server").append(CRLF);
writer.append("Content-Type: text/html; charset=UTF-8").append(CRLF);
writer.append("Connection: close").append(CRLF);
writer.append("Expires: 0").append(CRLF);
if (Application.IS_MAC)
writer.append("-->").append(CRLF);
writer.write(CRLF);
/* Begin HTML */
writer.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n");
/* Windows only: Mark of the Web */
if (Application.IS_WINDOWS) {
writer.write(IE_MOTW);
writer.write("\n");
}
writer.write("<html>\n <head>\n");
/* Append Base URI if available */
String base = getBase(children);
if (base != null) {
writer.write(" <base href=\"");
writer.write(base);
writer.write("\">");
}
writer.write("\n <title></title>");
writer.write("\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n");
/* CSS */
if (labelProvider instanceof NewsBrowserLabelProvider)
((NewsBrowserLabelProvider) labelProvider).writeCSS(writer);
/* Open Body */
writer.write(" </head>\n <body>\n");
/* Output each Element as HTML */
for (Object el : children) {
String html = unicodeToEntities(labelProvider.getText(el));
writer.write(html);
}
/* End HTML */
writer.write("\n </body>\n</html>");