public String [] getHtmlContent() {
// create an empty string buffer. this buffer contains the html-string
// which is being display in the main window's "entry textfield"
StringBuffer retval = new StringBuffer("");
// the return value consists of two parts: the first part contains the html string
// of the main content. the second part consists of the autho information
String [] complete = new String[2];
// first of all, prepare the header and style information of the main content
retval.append("<style>\n");
retval.append("body{font-family:Helvetica,sans-serif;font-size:11px;}\n");
retval.append("h1{font-weight:normal;font-size:12px;color:#800000;}\n");
retval.append(".content{padding:3px;}\n");
retval.append(".links h1{font-size:11px;}\n");
retval.append(".links ul{color:#0000cc;font-size:9px;}\n");
retval.append(".links ul a{text-decoration:none;}\n");
retval.append("</style>\n");
// now start with the html content itself
retval.append("<html><div class=\"content\">");
// if the entry has a title, add it surrounded by <h1>-tags
if (!title.isEmpty()) {
retval.append("<h1>");
retval.append(title);
retval.append("</h1>\n");
}
// now copy the content of the entry to a dummy string. here we convert
// the format codes into html-tags. the format codes are simplified tags
// for the user to enable simple format editing
String dummy;
dummy = content.replaceAll("/\\[f\\](.*)\\[\\/f\\]/Usi", "[b]\\1[/b]");
dummy = dummy.replaceAll("/\\[k\\](.*)\\[\\/k\\]/Usi", "[i]\\1[/i]");
dummy = dummy.replaceAll("/\\[u\\](.*)\\[\\/u\\]/Usi", "<u>\\1</u>");
dummy = dummy.replaceAll("/\\[color (.*)\\](.*)\\[\\/color\\]/Usi", "<span color=\"\\1\">\\2</span>");
// after the conversion is done, append the content to the resulting return string
retval.append(dummy);
// and close properly the html tags
retval.append("</div>\n
</p>\n");
// now look for hyperlinks
if (hyperlinks.size()>0) {
// we need a temporary buffer again
StringBuffer dummylink = new StringBuffer("");
// iterare the child elements of the hyperlinks. these were
// passed as parameter as a List-type
Iterator<?> iterator = hyperlinks.iterator();
// TODO fragen, wie hyperlink aus JEditorPane ausführbar
while (iterator.hasNext()) {
// first, copy the element of the list to an own variable
Element link = (Element) iterator.next();
// if it's not an empty element, surround it with html-list-tags
if (!link.getText().isEmpty()) {
dummylink.append("[*]<a href=\""+link.getText()+"\">");
dummylink.append(link.getText());
dummylink.append("</a>\n");
}
}
// if there have been hyperlinks, they must be stored in the stringbuffer now
// so, if the string buffer has content, append it to the resulting return string
if (dummylink.length()>0) {
// apply a class attribute to the hyperlinks, so we can have certain styles
// and formatting for the links as well
retval.append("<div class=\"links\"><h1>"+resourceMap.getString("HyperlinksHeader")+"</h1>\n<ul>");
retval.append(dummylink.toString());
retval.append("[/list]</div>\n");
}
}
// close all tags properly
retval.append("</div>\n</html>");
// and put the first complete string into the return array
complete[0] = retval.toString();
// reset the temporary string buffer
retval.setLength(0);
// append new style information for the next "html-page"
// these author information are set to the second textpanel in the main window
retval.append("<style>\n");
retval.append("body{font-family:Helvetica,sans-serif;font-size:10px;}\n");
retval.append("</style>\n");
retval.append("<html>");
// if there is no author information, tell this the user
if (author.isEmpty()) {
retval.append("[i]"+resourceMap.getString("NoAuthor")+"[/i]");
}
else {
retval.append(author);
}
// finish everything and...
retval.append("</html>");
// ...copy the information to the array
complete[1] = retval.toString();
return complete;
}