/**
* 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 QuoteCell extends StorySketchCell {
public QuoteCell() {
this(new Quote());
}
public QuoteCell(Object userObject) {
super(userObject);
}
public String getClassDescription() {
return "Sitater";
}
public String toHTML() {
Quote q = (Quote) userObject;
StringBuffer html = new StringBuffer();
html.append("<html><body>");
if(q.getQuote().length() > 0) {
html.append("<b>Sitat: </b><i>").append(q.getQuote()).append("</i>");
} else {
html.append("<b>Tomt sitat</b><p><i>Tips: </i>Du kan dobbeltklikke på sitatet for å legge til tekst</p>");
}
html.append("</body></html>");
return html.toString();
}
public Element getCellElement(Document doc) {
Element element = doc.createElement("quotecell");
Quote q = (Quote)userObject;
element.appendChild(XMLUtil.createParagraphElement("quote", q.getQuote(), doc));
return element;
}
public void setCellElement(Element e) {
Element quote = (Element)e.getElementsByTagName("quote").item(0);
Quote n = new Quote();
n.setQuote(XMLUtil.getStringFromParagraphElement(quote));
userObject = n;
}
}