Source Code Cross Referenced for CompCSObject.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » core » cheatsheet » comp » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » Eclipse plug in development » org.eclipse.pde.internal.core.cheatsheet.comp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.IOException;
013:        import java.io.PrintWriter;
014:        import java.util.HashMap;
015:        import java.util.HashSet;
016:        import java.util.List;
017:
018:        import org.eclipse.core.runtime.PlatformObject;
019:        import org.eclipse.pde.core.IModelChangeProvider;
020:        import org.eclipse.pde.core.IModelChangedEvent;
021:        import org.eclipse.pde.core.ModelChangedEvent;
022:        import org.eclipse.pde.internal.core.XMLPrintHandler;
023:        import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCS;
024:        import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSModel;
025:        import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject;
026:        import org.w3c.dom.Element;
027:        import org.w3c.dom.Node;
028:        import org.w3c.dom.NodeList;
029:        import org.w3c.dom.Text;
030:
031:        /**
032:         * CompCSObject
033:         *
034:         */
035:        public abstract class CompCSObject extends PlatformObject implements 
036:                ICompCSObject {
037:
038:            private transient ICompCSModel fModel;
039:
040:            private transient ICompCSObject fParent;
041:
042:            protected static final HashSet DEFAULT_TAG_EXCEPTIONS = new HashSet(
043:                    12);
044:
045:            protected static final HashMap DEFAULT_SUBSTITUTE_CHARS = new HashMap(
046:                    5);
047:
048:            static {
049:                DEFAULT_TAG_EXCEPTIONS.add("b"); //$NON-NLS-1$
050:                DEFAULT_TAG_EXCEPTIONS.add("/b"); //$NON-NLS-1$
051:                DEFAULT_TAG_EXCEPTIONS.add("br/"); //$NON-NLS-1$
052:                DEFAULT_TAG_EXCEPTIONS.add("p"); //$NON-NLS-1$
053:                DEFAULT_TAG_EXCEPTIONS.add("/p"); //$NON-NLS-1$
054:                DEFAULT_TAG_EXCEPTIONS.add("li"); //$NON-NLS-1$
055:                DEFAULT_TAG_EXCEPTIONS.add("/li"); //$NON-NLS-1$		
056:                DEFAULT_TAG_EXCEPTIONS.add("a"); //$NON-NLS-1$
057:                DEFAULT_TAG_EXCEPTIONS.add("/a"); //$NON-NLS-1$	
058:                DEFAULT_TAG_EXCEPTIONS.add("span"); //$NON-NLS-1$
059:                DEFAULT_TAG_EXCEPTIONS.add("/span"); //$NON-NLS-1$			
060:                DEFAULT_TAG_EXCEPTIONS.add("img"); //$NON-NLS-1$	
061:
062:                DEFAULT_SUBSTITUTE_CHARS.put(new Character('&'), "&"); //$NON-NLS-1$
063:                DEFAULT_SUBSTITUTE_CHARS.put(new Character('<'), "&lt;"); //$NON-NLS-1$
064:                DEFAULT_SUBSTITUTE_CHARS.put(new Character('>'), "&gt;"); //$NON-NLS-1$
065:                DEFAULT_SUBSTITUTE_CHARS.put(new Character('\''), "&apos;"); //$NON-NLS-1$
066:                DEFAULT_SUBSTITUTE_CHARS.put(new Character('\"'), "&quot;"); //$NON-NLS-1$
067:            }
068:
069:            /**
070:             * @param model
071:             * @param parent
072:             */
073:            public CompCSObject(ICompCSModel model, ICompCSObject parent) {
074:                fModel = model;
075:                fParent = parent;
076:            }
077:
078:            /* (non-Javadoc)
079:             * @see org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject#getChildren()
080:             */
081:            public abstract List getChildren();
082:
083:            /* (non-Javadoc)
084:             * @see org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject#getCompCS()
085:             */
086:            public ICompCS getCompCS() {
087:                return fModel.getCompCS();
088:            }
089:
090:            /* (non-Javadoc)
091:             * @see org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject#getModel()
092:             */
093:            public ICompCSModel getModel() {
094:                return fModel;
095:            }
096:
097:            /* (non-Javadoc)
098:             * @see org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject#getName()
099:             */
100:            public abstract String getName();
101:
102:            /* (non-Javadoc)
103:             * @see org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject#getParent()
104:             */
105:            public ICompCSObject getParent() {
106:                return fParent;
107:            }
108:
109:            /* (non-Javadoc)
110:             * @see org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject#getType()
111:             */
112:            public abstract int getType();
113:
114:            /* (non-Javadoc)
115:             * @see org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject#parse(org.w3c.dom.Element)
116:             */
117:            public void parse(Element element) {
118:                if (element.getNodeName().equals(getElement())) {
119:                    parseAttributes(element);
120:                    parseContent(element);
121:                }
122:            }
123:
124:            /* (non-Javadoc)
125:             * @see org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject#reset()
126:             */
127:            public abstract void reset();
128:
129:            /* (non-Javadoc)
130:             * @see org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject#setModel(org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSModel)
131:             */
132:            public void setModel(ICompCSModel model) {
133:                fModel = model;
134:            }
135:
136:            /* (non-Javadoc)
137:             * @see org.eclipse.pde.core.IWritable#write(java.lang.String, java.io.PrintWriter)
138:             */
139:            public void write(String indent, PrintWriter writer) {
140:
141:                StringBuffer buffer = new StringBuffer();
142:                try {
143:                    // Assemble start element
144:                    buffer.append(getElement());
145:                    // Assemble attributes
146:                    writeAttributes(buffer);
147:                    // Print start element and attributes
148:                    XMLPrintHandler.printBeginElement(writer,
149:                            buffer.toString(), indent, false);
150:                    // Print elements
151:                    writeElements(indent, writer);
152:                    // Print end element
153:                    XMLPrintHandler.printEndElement(writer, getElement(),
154:                            indent);
155:                } catch (IOException e) {
156:                    // Suppress
157:                    //e.printStackTrace();
158:                }
159:            }
160:
161:            /**
162:             * @param property
163:             * @param oldValue
164:             * @param newValue
165:             */
166:            protected void firePropertyChanged(String property,
167:                    Object oldValue, Object newValue) {
168:                firePropertyChanged(this , property, oldValue, newValue);
169:            }
170:
171:            /**
172:             * @param object
173:             * @param property
174:             * @param oldValue
175:             * @param newValue
176:             */
177:            private void firePropertyChanged(ICompCSObject object,
178:                    String property, Object oldValue, Object newValue) {
179:                if (fModel.isEditable()) {
180:                    IModelChangeProvider provider = fModel;
181:                    provider.fireModelObjectChanged(object, property, oldValue,
182:                            newValue);
183:                }
184:            }
185:
186:            /**
187:             * @param child
188:             * @param changeType
189:             */
190:            protected void fireStructureChanged(ICompCSObject child,
191:                    int changeType) {
192:                fireStructureChanged(new ICompCSObject[] { child }, changeType);
193:            }
194:
195:            /**
196:             * @param newValue
197:             * @param oldValue
198:             * @param changeType
199:             */
200:            protected void fireStructureChanged(ICompCSObject newValue,
201:                    ICompCSObject oldValue) {
202:
203:                int changeType = -1;
204:                ICompCSObject object = null;
205:                if (newValue == null) {
206:                    changeType = IModelChangedEvent.REMOVE;
207:                    object = oldValue;
208:                } else {
209:                    changeType = IModelChangedEvent.INSERT;
210:                    object = newValue;
211:                }
212:                fireStructureChanged(object, changeType);
213:            }
214:
215:            /**
216:             * @param children
217:             * @param changeType
218:             */
219:            private void fireStructureChanged(ICompCSObject[] children,
220:                    int changeType) {
221:                if (fModel.isEditable()) {
222:                    IModelChangeProvider provider = fModel;
223:                    provider.fireModelChanged(new ModelChangedEvent(provider,
224:                            changeType, children, null));
225:                }
226:            }
227:
228:            /**
229:             * @return
230:             */
231:            protected boolean isEditable() {
232:                return getModel().isEditable();
233:            }
234:
235:            /**
236:             * @param element
237:             */
238:            protected abstract void parseAttributes(Element element);
239:
240:            /**
241:             * @param element
242:             */
243:            protected void parseContent(Element element) {
244:                // Process children
245:                NodeList children = element.getChildNodes();
246:                for (int i = 0; i < children.getLength(); i++) {
247:                    Node child = children.item(i);
248:                    if (child.getNodeType() == Node.ELEMENT_NODE) {
249:                        parseElement((Element) child);
250:                    } else if (child.getNodeType() == Node.TEXT_NODE) {
251:                        parseText((Text) child);
252:                    }
253:                }
254:            }
255:
256:            /**
257:             * @param element
258:             */
259:            protected abstract void parseElement(Element element);
260:
261:            /**
262:             * @param element
263:             */
264:            protected abstract void parseText(Text text);
265:
266:            /**
267:             * @param buffer
268:             */
269:            protected abstract void writeAttributes(StringBuffer buffer);
270:
271:            /**
272:             * Writes child elements or child content
273:             * @param indent
274:             * @param writer
275:             */
276:            protected abstract void writeElements(String indent,
277:                    PrintWriter writer);
278:
279:            /* (non-Javadoc)
280:             * @see org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject#getElement()
281:             */
282:            public abstract String getElement();
283:        }
w__w_w.ja__va__2___s_.__c___o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.