KickJava   Java API By Example, From Geeks To Geeks.

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


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.ISimpleCSModel;
21 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSObject;
22 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSOnCompletion;
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  * SimpleCSOnCompletion
29  *
30  */

31 public class SimpleCSOnCompletion extends SimpleCSObject implements
32         ISimpleCSOnCompletion {
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 SimpleCSOnCompletion(ISimpleCSModel model, ISimpleCSObject parent) {
49         super(model, parent);
50         reset();
51     }
52
53     /* (non-Javadoc)
54      * @see org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSObject#parse(org.w3c.dom.Node)
55      */

56     public void parse(Element JavaDoc element) {
57         fContent = CheatSheetUtil.parseElementText(element).trim();
58     }
59
60     /* (non-Javadoc)
61      * @see org.eclipse.pde.core.IWritable#write(java.lang.String, java.io.PrintWriter)
62      */

63     public void write(String JavaDoc indent, PrintWriter JavaDoc writer) {
64
65         String JavaDoc newIndent = indent + XMLPrintHandler.XML_INDENT;
66         
67         try {
68             // Start element
69
XMLPrintHandler.printBeginElement(writer, ELEMENT_ONCOMPLETION,
70                     indent, false);
71             // Print contents
72
if ((fContent != null) &&
73                     (fContent.length() > 0)) {
74                 writer.write(newIndent
75                         + PDETextHelper.translateWriteText(fContent.trim(),
76                                 TAG_EXCEPTIONS, SUBSTITUTE_CHARS) + "\n"); //$NON-NLS-1$
77
}
78             // End element
79
XMLPrintHandler.printEndElement(writer, ELEMENT_ONCOMPLETION, indent);
80         } catch (IOException JavaDoc e) {
81             // Suppress
82
//e.printStackTrace();
83
}
84     }
85
86     /* (non-Javadoc)
87      * @see org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSObject#reset()
88      */

89     public void reset() {
90         fContent = null;
91     }
92
93     /**
94      * Content (element)
95      * @return
96      */

97     public String JavaDoc getContent() {
98         return fContent;
99     }
100
101     /**
102      * Content (element)
103      * @param content
104      */

105     public void setContent(String JavaDoc content) {
106         String JavaDoc old = fContent;
107         fContent = content;
108         if (isEditable()) {
109             firePropertyChanged(ELEMENT_DESCRIPTION, old, fContent);
110         }
111     }
112
113     /* (non-Javadoc)
114      * @see org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSObject#getType()
115      */

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

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

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