KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > cheatsheet > comp > CompCSDependency


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.pde.internal.core.cheatsheet.comp;
13
14 import java.io.PrintWriter JavaDoc;
15 import java.util.ArrayList JavaDoc;
16 import java.util.List JavaDoc;
17
18 import org.eclipse.pde.internal.core.XMLPrintHandler;
19 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSDependency;
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.PDETextHelper;
23 import org.w3c.dom.Element JavaDoc;
24 import org.w3c.dom.Text JavaDoc;
25
26 /**
27  * CompCSDependency
28  *
29  */

30 public class CompCSDependency extends CompCSObject implements ICompCSDependency {
31
32     private String JavaDoc fFieldTask;
33     
34     /**
35      *
36      */

37     private static final long serialVersionUID = 1L;
38
39     /**
40      * @param model
41      * @param parent
42      */

43     public CompCSDependency(ICompCSModel model, ICompCSObject parent) {
44         super(model, parent);
45         reset();
46     }
47
48     /* (non-Javadoc)
49      * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#getChildren()
50      */

51     public List JavaDoc getChildren() {
52         return new ArrayList JavaDoc();
53     }
54
55     /* (non-Javadoc)
56      * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#getElement()
57      */

58     public String JavaDoc getElement() {
59         return ELEMENT_DEPENDENCY;
60     }
61
62     /* (non-Javadoc)
63      * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#getName()
64      */

65     public String JavaDoc getName() {
66         return fFieldTask;
67     }
68
69     /* (non-Javadoc)
70      * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#getType()
71      */

72     public int getType() {
73         return TYPE_DEPENDENCY;
74     }
75
76     /* (non-Javadoc)
77      * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#parseAttributes(org.w3c.dom.Element)
78      */

79     protected void parseAttributes(Element JavaDoc element) {
80         // Process task attribute
81
// Trim leading and trailing whitespace
82
fFieldTask = element.getAttribute(ATTRIBUTE_TASK).trim();
83     }
84
85     /* (non-Javadoc)
86      * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#parseElement(org.w3c.dom.Element)
87      */

88     protected void parseElement(Element JavaDoc element) {
89         // NO-OP
90
}
91
92     /* (non-Javadoc)
93      * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#reset()
94      */

95     public void reset() {
96         fFieldTask = null;
97     }
98
99     /* (non-Javadoc)
100      * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#writeAttributes(java.lang.StringBuffer)
101      */

102     protected void writeAttributes(StringBuffer JavaDoc buffer) {
103         // Print task attribute
104
if ((fFieldTask != null) &&
105                 (fFieldTask.length() > 0)) {
106             // Trim leading and trailing whitespace
107
// Encode characters
108
buffer.append(XMLPrintHandler.wrapAttribute(
109                     ATTRIBUTE_TASK,
110                     PDETextHelper.translateWriteText(
111                             fFieldTask.trim(), DEFAULT_SUBSTITUTE_CHARS)));
112         }
113     }
114
115     /* (non-Javadoc)
116      * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#writeElements(java.lang.String, java.io.PrintWriter)
117      */

118     protected void writeElements(String JavaDoc indent, PrintWriter JavaDoc writer) {
119         // NO-OP
120
}
121
122     /* (non-Javadoc)
123      * @see org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSDependency#getFieldTask()
124      */

125     public String JavaDoc getFieldTask() {
126         return fFieldTask;
127     }
128
129     /* (non-Javadoc)
130      * @see org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSDependency#setFieldTask(java.lang.String)
131      */

132     public void setFieldTask(String JavaDoc task) {
133         String JavaDoc old = fFieldTask;
134         fFieldTask = task;
135         if (isEditable()) {
136             firePropertyChanged(ATTRIBUTE_TASK, old, fFieldTask);
137         }
138     }
139
140     /* (non-Javadoc)
141      * @see org.eclipse.pde.internal.core.cheatsheet.comp.CompCSObject#parseText(org.w3c.dom.Text)
142      */

143     protected void parseText(Text JavaDoc text) {
144         // NO-OP
145
}
146
147 }
148
Popular Tags