KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > cheatsheet > simple > SimpleCSDescription


1 /*******************************************************************************
2  * Copyright (c) 2006 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.simple;
13
14 import java.io.IOException JavaDoc;
15 import java.io.PrintWriter JavaDoc;
16 import java.util.ArrayList JavaDoc;
17 import java.util.List JavaDoc;
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 JavaDoc;
26
27 /**
28  * SimpleCSDescription
29  *
30  */

31 public class SimpleCSDescription extends SimpleCSObject implements
32         ISimpleCSDescription {
33     
34     /**
35      * Content (Element)
36      */

37     private String JavaDoc fContent;
38     
39     /**
40      *
41      */

42     private static final long serialVersionUID = 1L;
43
44     /**
45      * @param model
46      * @param parent
47      */

48     public SimpleCSDescription(ISimpleCSModel model, ISimpleCSObject parent) {
49         super(model, parent);
50         reset();
51     }
52
53     /* (non-Javadoc)
54      * @see org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSDescription#getContent()
55      */

56     public String JavaDoc getContent() {
57         return fContent;
58     }
59
60     /* (non-Javadoc)
61      * @see org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSDescription#setContent(java.lang.String)
62      */

63     public void setContent(String JavaDoc content) {
64         String JavaDoc old = fContent;
65         fContent = content;
66         if (isEditable()) {
67             firePropertyChanged(ELEMENT_DESCRIPTION, old, fContent);
68         }
69     }
70
71     /* (non-Javadoc)
72      * @see org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSObject#parse(org.w3c.dom.Node)
73      */

74     public void parse(Element JavaDoc element) {
75         fContent = CheatSheetUtil.parseElementText(element).trim();
76     }
77     
78     /* (non-Javadoc)
79      * @see org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSObject#reset()
80      */

81     public void reset() {
82         fContent = null;
83     }
84
85     /* (non-Javadoc)
86      * @see org.eclipse.pde.core.IWritable#write(java.lang.String, java.io.PrintWriter)
87      */

88     public void write(String JavaDoc indent, PrintWriter JavaDoc writer) {
89         
90         String JavaDoc newIndent = indent + XMLPrintHandler.XML_INDENT;
91         
92         try {
93             // Start element
94
XMLPrintHandler.printBeginElement(writer, ELEMENT_DESCRIPTION,
95                     indent, false);
96             // Print contents
97
if ((fContent != null) &&
98                     (fContent.length() > 0)) {
99                 writer.write(newIndent
100                         + PDETextHelper.translateWriteText(fContent.trim(),
101                                 TAG_EXCEPTIONS, SUBSTITUTE_CHARS) + "\n"); //$NON-NLS-1$
102
}
103             // End element
104
XMLPrintHandler.printEndElement(writer, ELEMENT_DESCRIPTION, indent);
105         } catch (IOException JavaDoc e) {
106             // Suppress
107
//e.printStackTrace();
108
}
109     }
110
111     /* (non-Javadoc)
112      * @see org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSObject#getType()
113      */

114     public int getType() {
115         return TYPE_DESCRIPTION;
116     }
117
118     /* (non-Javadoc)
119      * @see org.eclipse.pde.internal.core.cheatsheet.simple.SimpleCSObject#getName()
120      */

121     public String JavaDoc getName() {
122         return fContent;
123     }
124
125     /* (non-Javadoc)
126      * @see org.eclipse.pde.internal.core.cheatsheet.simple.SimpleCSObject#getChildren()
127      */

128     public List JavaDoc getChildren() {
129         return new ArrayList JavaDoc();
130     }
131
132 }
133
Popular Tags