1 11 12 package org.eclipse.pde.internal.core.cheatsheet.comp; 13 14 import java.io.PrintWriter ; 15 import java.util.ArrayList ; 16 import java.util.List ; 17 18 import org.eclipse.pde.internal.core.XMLPrintHandler; 19 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSDataObject; 20 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSModel; 21 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject; 22 import org.eclipse.pde.internal.core.util.CheatSheetUtil; 23 import org.eclipse.pde.internal.core.util.PDETextHelper; 24 import org.w3c.dom.Element ; 25 import org.w3c.dom.Text ; 26 27 31 public abstract class CompCSDataObject extends CompCSObject implements 32 ICompCSDataObject { 33 34 private String fFieldContent; 35 36 40 public CompCSDataObject(ICompCSModel model, ICompCSObject parent) { 41 super(model, parent); 42 } 44 45 48 public List getChildren() { 49 return new ArrayList (); 50 } 51 52 55 public abstract String getElement(); 56 57 60 public String getName() { 61 return fFieldContent; 62 } 63 64 67 public abstract int getType(); 68 69 72 protected void parseContent(Element element) { 73 fFieldContent = CheatSheetUtil.parseElementText(element).trim(); 76 } 77 78 81 protected void parseAttributes(Element element) { 82 } 84 85 88 protected void parseElement(Element element) { 89 } 91 92 95 protected void parseText(Text text) { 96 } 98 99 102 public void reset() { 103 fFieldContent = null; 104 } 105 106 109 protected void writeAttributes(StringBuffer buffer) { 110 } 112 113 116 protected void writeElements(String indent, PrintWriter writer) { 117 String newIndent = indent + XMLPrintHandler.XML_INDENT; 118 if ((fFieldContent != null) && 120 (fFieldContent.length() > 0)) { 121 writer.write(newIndent 125 + PDETextHelper.translateWriteText(fFieldContent.trim(), 126 DEFAULT_TAG_EXCEPTIONS, DEFAULT_SUBSTITUTE_CHARS) + "\n"); } 128 } 129 130 133 public String getFieldContent() { 134 return fFieldContent; 135 } 136 137 140 public void setFieldContent(String content) { 141 String old = fFieldContent; 142 fFieldContent = content; 143 if (isEditable()) { 144 firePropertyChanged(getElement(), old, fFieldContent); 145 } 146 } 147 148 } 149 | Popular Tags |