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.ICompCSModel; 20 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject; 21 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSParam; 22 import org.eclipse.pde.internal.core.util.PDETextHelper; 23 import org.w3c.dom.Element ; 24 import org.w3c.dom.Text ; 25 26 30 public class CompCSParam extends CompCSObject implements ICompCSParam { 31 32 private String fFieldName; 33 34 private String fFieldValue; 35 36 39 private static final long serialVersionUID = 1L; 40 41 45 public CompCSParam(ICompCSModel model, ICompCSObject parent) { 46 super(model, parent); 47 reset(); 48 } 49 50 53 public List getChildren() { 54 return new ArrayList (); 55 } 56 57 60 public String getElement() { 61 return ELEMENT_PARAM; 62 } 63 64 67 public String getName() { 68 return fFieldName; 69 } 70 71 74 public int getType() { 75 return TYPE_PARAM; 76 } 77 78 81 protected void parseAttributes(Element element) { 82 fFieldName = element.getAttribute(ATTRIBUTE_NAME).trim(); 85 fFieldValue = element.getAttribute(ATTRIBUTE_VALUE).trim(); 88 } 89 90 93 protected void parseElement(Element element) { 94 } 96 97 100 public void reset() { 101 fFieldName = null; 102 fFieldValue = null; 103 } 104 105 108 protected void writeAttributes(StringBuffer buffer) { 109 if ((fFieldName != null) && 111 (fFieldName.length() > 0)) { 112 buffer.append(XMLPrintHandler.wrapAttribute( 115 ATTRIBUTE_NAME, fFieldName)); 116 } 117 if ((fFieldValue != null) && 119 (fFieldValue.length() > 0)) { 120 buffer.append(XMLPrintHandler.wrapAttribute( 123 ATTRIBUTE_VALUE, 124 PDETextHelper.translateWriteText( 125 fFieldValue.trim(), DEFAULT_SUBSTITUTE_CHARS))); 126 } 127 } 128 129 132 protected void writeElements(String indent, PrintWriter writer) { 133 } 135 136 139 public String getFieldName() { 140 return fFieldName; 141 } 142 143 146 public String getFieldValue() { 147 return fFieldValue; 148 } 149 150 153 public void setFieldName(String name) { 154 String old = fFieldName; 155 fFieldName = name; 156 if (isEditable()) { 157 firePropertyChanged(ATTRIBUTE_NAME, old, fFieldName); 158 } 159 } 160 161 164 public void setFieldValue(String value) { 165 String old = fFieldValue; 166 fFieldValue = value; 167 if (isEditable()) { 168 firePropertyChanged(ATTRIBUTE_VALUE, old, fFieldValue); 169 } 170 } 171 172 175 protected void parseText(Text text) { 176 } 178 179 } 180 | Popular Tags |