001: /*******************************************************************************
002: * Copyright (c) 2006, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.pde.internal.core.cheatsheet.comp;
011:
012: import java.io.PrintWriter;
013: import java.util.ArrayList;
014: import java.util.List;
015:
016: import org.eclipse.pde.internal.core.XMLPrintHandler;
017: import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSDependency;
018: import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSModel;
019: import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject;
020: import org.eclipse.pde.internal.core.util.PDETextHelper;
021: import org.w3c.dom.Element;
022: import org.w3c.dom.Text;
023:
024: /**
025: * CompCSDependency
026: *
027: */
028: public class CompCSDependency extends CompCSObject implements
029: ICompCSDependency {
030:
031: private String fFieldTask;
032:
033: /**
034: *
035: */
036: private static final long serialVersionUID = 1L;
037:
038: /**
039: * @param model
040: * @param parent
041: */
042: public CompCSDependency(ICompCSModel model, ICompCSObject parent) {
043: super (model, parent);
044: reset();
045: }
046:
047: /* (non-Javadoc)
048: * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#getChildren()
049: */
050: public List getChildren() {
051: return new ArrayList();
052: }
053:
054: /* (non-Javadoc)
055: * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#getElement()
056: */
057: public String getElement() {
058: return ELEMENT_DEPENDENCY;
059: }
060:
061: /* (non-Javadoc)
062: * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#getName()
063: */
064: public String getName() {
065: return fFieldTask;
066: }
067:
068: /* (non-Javadoc)
069: * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#getType()
070: */
071: public int getType() {
072: return TYPE_DEPENDENCY;
073: }
074:
075: /* (non-Javadoc)
076: * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#parseAttributes(org.w3c.dom.Element)
077: */
078: protected void parseAttributes(Element element) {
079: // Process task attribute
080: // Trim leading and trailing whitespace
081: fFieldTask = element.getAttribute(ATTRIBUTE_TASK).trim();
082: }
083:
084: /* (non-Javadoc)
085: * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#parseElement(org.w3c.dom.Element)
086: */
087: protected void parseElement(Element element) {
088: // NO-OP
089: }
090:
091: /* (non-Javadoc)
092: * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#reset()
093: */
094: public void reset() {
095: fFieldTask = null;
096: }
097:
098: /* (non-Javadoc)
099: * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#writeAttributes(java.lang.StringBuffer)
100: */
101: protected void writeAttributes(StringBuffer buffer) {
102: // Print task attribute
103: if ((fFieldTask != null) && (fFieldTask.length() > 0)) {
104: // Trim leading and trailing whitespace
105: // Encode characters
106: buffer.append(XMLPrintHandler.wrapAttribute(ATTRIBUTE_TASK,
107: PDETextHelper.translateWriteText(fFieldTask.trim(),
108: DEFAULT_SUBSTITUTE_CHARS)));
109: }
110: }
111:
112: /* (non-Javadoc)
113: * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#writeElements(java.lang.String, java.io.PrintWriter)
114: */
115: protected void writeElements(String indent, PrintWriter writer) {
116: // NO-OP
117: }
118:
119: /* (non-Javadoc)
120: * @see org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSDependency#getFieldTask()
121: */
122: public String getFieldTask() {
123: return fFieldTask;
124: }
125:
126: /* (non-Javadoc)
127: * @see org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSDependency#setFieldTask(java.lang.String)
128: */
129: public void setFieldTask(String task) {
130: String old = fFieldTask;
131: fFieldTask = task;
132: if (isEditable()) {
133: firePropertyChanged(ATTRIBUTE_TASK, old, fFieldTask);
134: }
135: }
136:
137: /* (non-Javadoc)
138: * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#parseText(org.w3c.dom.Text)
139: */
140: protected void parseText(Text text) {
141: // NO-OP
142: }
143:
144: }
|