/** * Copyright 1999-2009 The Pegadi Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.pegadi.storysketch.cells; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.pegadi.storysketch.XMLUtil; public class NoteCell extends StorySketchCell { public NoteCell() { this(new Note()); } public NoteCell(Object userObject) { super(userObject); } public String getClassDescription() { return "Notater"; } public Element getCellElement(Document doc) { Element element = doc.createElement("notecell"); Note n = (Note) userObject; element.appendChild(XMLUtil.createParagraphElement("note", n.getNotes(), doc)); return element; } public void setCellElement(Element e) { Element note = (Element)e.getElementsByTagName("note").item(0); Note n = new Note(); n.setNotes(XMLUtil.getStringFromParagraphElement(note)); userObject = n; } public String toHTML() { Note n = (Note)userObject; StringBuffer html = new StringBuffer(); html.append("<html><body bgcolor=\"#ffffaa\">"); if(n.getNotes().length() > 0) { html.append("<b>Notat: </b>").append(n.getNotes()); } else { html.append("<b>Tomt notat</b><p><i>Tips: </i>Du kan dobbeltklikke på notatet for å legge til tekst</p>"); } html.append("</body></html>"); return html.toString(); } }