1 11 12 package org.eclipse.pde.internal.core.cheatsheet.simple; 13 14 import java.io.IOException ; 15 import java.io.PrintWriter ; 16 import java.util.ArrayList ; 17 import java.util.List ; 18 19 import org.eclipse.pde.internal.core.XMLPrintHandler; 20 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSDescription; 21 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSModel; 22 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSObject; 23 import org.eclipse.pde.internal.core.util.CheatSheetUtil; 24 import org.eclipse.pde.internal.core.util.PDETextHelper; 25 import org.w3c.dom.Element ; 26 27 31 public class SimpleCSDescription extends SimpleCSObject implements 32 ISimpleCSDescription { 33 34 37 private String fContent; 38 39 42 private static final long serialVersionUID = 1L; 43 44 48 public SimpleCSDescription(ISimpleCSModel model, ISimpleCSObject parent) { 49 super(model, parent); 50 reset(); 51 } 52 53 56 public String getContent() { 57 return fContent; 58 } 59 60 63 public void setContent(String content) { 64 String old = fContent; 65 fContent = content; 66 if (isEditable()) { 67 firePropertyChanged(ELEMENT_DESCRIPTION, old, fContent); 68 } 69 } 70 71 74 public void parse(Element element) { 75 fContent = CheatSheetUtil.parseElementText(element).trim(); 76 } 77 78 81 public void reset() { 82 fContent = null; 83 } 84 85 88 public void write(String indent, PrintWriter writer) { 89 90 String newIndent = indent + XMLPrintHandler.XML_INDENT; 91 92 try { 93 XMLPrintHandler.printBeginElement(writer, ELEMENT_DESCRIPTION, 95 indent, false); 96 if ((fContent != null) && 98 (fContent.length() > 0)) { 99 writer.write(newIndent 100 + PDETextHelper.translateWriteText(fContent.trim(), 101 TAG_EXCEPTIONS, SUBSTITUTE_CHARS) + "\n"); } 103 XMLPrintHandler.printEndElement(writer, ELEMENT_DESCRIPTION, indent); 105 } catch (IOException e) { 106 } 109 } 110 111 114 public int getType() { 115 return TYPE_DESCRIPTION; 116 } 117 118 121 public String getName() { 122 return fContent; 123 } 124 125 128 public List getChildren() { 129 return new ArrayList (); 130 } 131 132 } 133 | Popular Tags |