Source Code Cross Referenced for Site.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » core » site » 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.site 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 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.site;
011:
012:        import java.io.PrintWriter;
013:        import java.util.Locale;
014:        import java.util.Vector;
015:
016:        import org.eclipse.core.runtime.CoreException;
017:        import org.eclipse.pde.core.IModelChangedEvent;
018:        import org.eclipse.pde.core.IWritable;
019:        import org.eclipse.pde.internal.core.isite.ISite;
020:        import org.eclipse.pde.internal.core.isite.ISiteArchive;
021:        import org.eclipse.pde.internal.core.isite.ISiteCategoryDefinition;
022:        import org.eclipse.pde.internal.core.isite.ISiteDescription;
023:        import org.eclipse.pde.internal.core.isite.ISiteFeature;
024:        import org.w3c.dom.Node;
025:        import org.w3c.dom.NodeList;
026:
027:        public class Site extends SiteObject implements  ISite {
028:            private static final long serialVersionUID = 1L;
029:            final static String INDENT = "   "; //$NON-NLS-1$
030:            private Vector features = new Vector();
031:            private Vector archives = new Vector();
032:            private Vector categoryDefs = new Vector();
033:            private String type;
034:            private String url;
035:            private String mirrorsUrl;
036:            private ISiteDescription description;
037:
038:            /**
039:             * @see org.eclipse.pde.internal.core.isite.ISite#setType(java.lang.String)
040:             */
041:            public void setType(String type) throws CoreException {
042:                ensureModelEditable();
043:                Object oldValue = this .type;
044:                this .type = type;
045:                firePropertyChanged(P_TYPE, oldValue, type);
046:            }
047:
048:            /**
049:             * @see org.eclipse.pde.internal.core.isite.ISite#getType()
050:             */
051:            public String getType() {
052:                return type;
053:            }
054:
055:            /**
056:             * @see org.eclipse.pde.internal.core.isite.ISite#setURL(java.net.URL)
057:             */
058:            public void setURL(String url) throws CoreException {
059:                ensureModelEditable();
060:                Object oldValue = this .url;
061:                this .url = url;
062:                firePropertyChanged(P_URL, oldValue, url);
063:            }
064:
065:            /**
066:             * @see org.eclipse.pde.internal.core.isite.ISite#getURL()
067:             */
068:            public String getURL() {
069:                return url;
070:            }
071:
072:            /**
073:             * @see org.eclipse.pde.internal.core.isite.ISite#setMirrorsURL(String)
074:             */
075:            public void setMirrorsURL(String url) throws CoreException {
076:                ensureModelEditable();
077:                Object oldValue = this .mirrorsUrl;
078:                this .mirrorsUrl = url;
079:                firePropertyChanged(P_MIRRORS_URL, oldValue, url);
080:            }
081:
082:            /**
083:             * @see org.eclipse.pde.internal.core.isite.ISite#getMirrorsURL()
084:             */
085:            public String getMirrorsURL() {
086:                return mirrorsUrl;
087:            }
088:
089:            /**
090:             * @see org.eclipse.pde.internal.core.isite.ISite#getDescription()
091:             */
092:            public ISiteDescription getDescription() {
093:                return description;
094:            }
095:
096:            /**
097:             * @see org.eclipse.pde.internal.core.isite.ISite#setDescription(org.eclipse.pde.internal.core.isite.ISiteDescription)
098:             */
099:            public void setDescription(ISiteDescription description)
100:                    throws CoreException {
101:                ensureModelEditable();
102:                Object oldValue = this .description;
103:                this .description = description;
104:                firePropertyChanged(P_DESCRIPTION, oldValue, description);
105:            }
106:
107:            /**
108:             * @see org.eclipse.pde.internal.core.isite.ISite#addFeatures(org.eclipse.pde.internal.core.isite.ISiteFeature)
109:             */
110:            public void addFeatures(ISiteFeature[] newFeatures)
111:                    throws CoreException {
112:                ensureModelEditable();
113:                for (int i = 0; i < newFeatures.length; i++) {
114:                    ISiteFeature feature = newFeatures[i];
115:                    ((SiteFeature) feature).setInTheModel(true);
116:                    features.add(newFeatures[i]);
117:                }
118:                fireStructureChanged(newFeatures, IModelChangedEvent.INSERT);
119:            }
120:
121:            /**
122:             * @see org.eclipse.pde.internal.core.isite.ISite#addArchives(org.eclipse.pde.internal.core.isite.ISiteArchive)
123:             */
124:            public void addArchives(ISiteArchive[] archs) throws CoreException {
125:                ensureModelEditable();
126:                for (int i = 0; i < archs.length; i++) {
127:                    ISiteArchive archive = archs[i];
128:                    ((SiteArchive) archive).setInTheModel(true);
129:                    archives.add(archs[i]);
130:                }
131:                fireStructureChanged(archs, IModelChangedEvent.INSERT);
132:            }
133:
134:            /**
135:             * @see org.eclipse.pde.internal.core.isite.ISite#addCategoryDefinitions(org.eclipse.pde.internal.core.isite.ISiteCategoryDefinition)
136:             */
137:            public void addCategoryDefinitions(ISiteCategoryDefinition[] defs)
138:                    throws CoreException {
139:                ensureModelEditable();
140:                for (int i = 0; i < defs.length; i++) {
141:                    ISiteCategoryDefinition def = defs[i];
142:                    ((SiteCategoryDefinition) def).setInTheModel(true);
143:                    categoryDefs.add(defs[i]);
144:                }
145:                fireStructureChanged(defs, IModelChangedEvent.INSERT);
146:            }
147:
148:            /**
149:             * @see org.eclipse.pde.internal.core.isite.ISite#removeFeatures(org.eclipse.pde.internal.core.isite.ISiteFeature)
150:             */
151:            public void removeFeatures(ISiteFeature[] newFeatures)
152:                    throws CoreException {
153:                ensureModelEditable();
154:                for (int i = 0; i < newFeatures.length; i++) {
155:                    ISiteFeature feature = newFeatures[i];
156:                    ((SiteFeature) feature).setInTheModel(false);
157:                    features.remove(newFeatures[i]);
158:                }
159:                fireStructureChanged(newFeatures, IModelChangedEvent.REMOVE);
160:            }
161:
162:            /**
163:             * @see org.eclipse.pde.internal.core.isite.ISite#removeArchives(org.eclipse.pde.internal.core.isite.ISiteArchive)
164:             */
165:            public void removeArchives(ISiteArchive[] archs)
166:                    throws CoreException {
167:                ensureModelEditable();
168:                for (int i = 0; i < archs.length; i++) {
169:                    ISiteArchive archive = archs[i];
170:                    ((SiteArchive) archive).setInTheModel(false);
171:                    archives.remove(archs[i]);
172:                }
173:                fireStructureChanged(archs, IModelChangedEvent.REMOVE);
174:            }
175:
176:            /**
177:             * @see org.eclipse.pde.internal.core.isite.ISite#removeCategoryDefinitions(org.eclipse.pde.internal.core.isite.ISiteCategoryDefinition)
178:             */
179:            public void removeCategoryDefinitions(ISiteCategoryDefinition[] defs)
180:                    throws CoreException {
181:                ensureModelEditable();
182:                for (int i = 0; i < defs.length; i++) {
183:                    ISiteCategoryDefinition def = defs[i];
184:                    ((SiteCategoryDefinition) def).setInTheModel(false);
185:                    categoryDefs.remove(defs[i]);
186:                }
187:                fireStructureChanged(defs, IModelChangedEvent.REMOVE);
188:            }
189:
190:            /**
191:             * @see org.eclipse.pde.internal.core.isite.ISite#getFeatures()
192:             */
193:            public ISiteFeature[] getFeatures() {
194:                return (ISiteFeature[]) features
195:                        .toArray(new ISiteFeature[features.size()]);
196:            }
197:
198:            /**
199:             * @see org.eclipse.pde.internal.core.isite.ISite#getArchives()
200:             */
201:            public ISiteArchive[] getArchives() {
202:                return (ISiteArchive[]) archives
203:                        .toArray(new ISiteArchive[archives.size()]);
204:            }
205:
206:            /**
207:             * @see org.eclipse.pde.internal.core.isite.ISite#getCategoryDefinitions()
208:             */
209:            public ISiteCategoryDefinition[] getCategoryDefinitions() {
210:                return (ISiteCategoryDefinition[]) categoryDefs
211:                        .toArray(new ISiteCategoryDefinition[categoryDefs
212:                                .size()]);
213:            }
214:
215:            protected void reset() {
216:                archives.clear();
217:                categoryDefs.clear();
218:                features.clear();
219:                description = null;
220:                type = null;
221:                url = null;
222:                mirrorsUrl = null;
223:            }
224:
225:            protected void parse(Node node) {
226:                type = getNodeAttribute(node, "type"); //$NON-NLS-1$
227:                url = getNodeAttribute(node, "url"); //$NON-NLS-1$
228:                mirrorsUrl = getNodeAttribute(node, "mirrorsURL"); //$NON-NLS-1$
229:                NodeList children = node.getChildNodes();
230:                for (int i = 0; i < children.getLength(); i++) {
231:                    Node child = children.item(i);
232:                    if (child.getNodeType() == Node.ELEMENT_NODE) {
233:                        parseChild(child);
234:                    }
235:                }
236:            }
237:
238:            protected void parseChild(Node child) {
239:                String tag = child.getNodeName().toLowerCase(Locale.ENGLISH);
240:                if (tag.equals("feature")) { //$NON-NLS-1$
241:                    ISiteFeature feature = getModel().getFactory()
242:                            .createFeature();
243:                    ((SiteFeature) feature).parse(child);
244:                    ((SiteFeature) feature).setInTheModel(true);
245:                    features.add(feature);
246:                } else if (tag.equals("archive")) { //$NON-NLS-1$
247:                    ISiteArchive archive = getModel().getFactory()
248:                            .createArchive();
249:                    ((SiteArchive) archive).parse(child);
250:                    ((SiteArchive) archive).setInTheModel(true);
251:                    archives.add(archive);
252:                } else if (tag.equals("category-def")) { //$NON-NLS-1$
253:                    ISiteCategoryDefinition def = getModel().getFactory()
254:                            .createCategoryDefinition();
255:                    ((SiteCategoryDefinition) def).parse(child);
256:                    ((SiteCategoryDefinition) def).setInTheModel(true);
257:                    categoryDefs.add(def);
258:                } else if (tag.equals("description")) { //$NON-NLS-1$
259:                    if (description != null)
260:                        return;
261:                    description = getModel().getFactory().createDescription(
262:                            this );
263:                    ((SiteDescription) description).parse(child);
264:                    ((SiteDescription) description).setInTheModel(true);
265:                }
266:            }
267:
268:            public void restoreProperty(String name, Object oldValue,
269:                    Object newValue) throws CoreException {
270:                if (name.equals(P_TYPE)) {
271:                    setType(newValue != null ? newValue.toString() : null);
272:                } else if (name.equals(P_URL)) {
273:                    setURL(newValue != null ? newValue.toString() : null);
274:                } else if (name.equals(P_MIRRORS_URL)) {
275:                    setMirrorsURL(newValue != null ? newValue.toString() : null);
276:                } else if (name.equals(P_DESCRIPTION)
277:                        && newValue instanceof  ISiteDescription) {
278:                    setDescription((ISiteDescription) newValue);
279:                } else
280:                    super .restoreProperty(name, oldValue, newValue);
281:            }
282:
283:            public void write(String indent, PrintWriter writer) {
284:                writer.print(indent + "<site"); //$NON-NLS-1$
285:                String indent2 = indent + INDENT;
286:                String indenta = indent + INDENT + INDENT;
287:                writeIfDefined(indenta, writer, "type", getType()); //$NON-NLS-1$
288:                writeIfDefined(indenta, writer, "url", getURL()); //$NON-NLS-1$
289:                writeIfDefined(indenta, writer, "mirrorsURL", getMirrorsURL()); //$NON-NLS-1$
290:                writer.println(">"); //$NON-NLS-1$
291:
292:                if (description != null) {
293:                    description.write(indent2, writer);
294:                }
295:                writeChildren(indent2, features, writer);
296:                writeChildren(indent2, archives, writer);
297:                writeChildren(indent2, categoryDefs, writer);
298:                writer.println(indent + "</site>"); //$NON-NLS-1$
299:            }
300:
301:            public boolean isValid() {
302:                for (int i = 0; i < features.size(); i++) {
303:                    ISiteFeature feature = (ISiteFeature) features.get(i);
304:                    if (!feature.isValid())
305:                        return false;
306:                }
307:                for (int i = 0; i < archives.size(); i++) {
308:                    ISiteArchive archive = (ISiteArchive) archives.get(i);
309:                    if (!archive.isValid())
310:                        return false;
311:                }
312:                for (int i = 0; i < categoryDefs.size(); i++) {
313:                    ISiteCategoryDefinition def = (ISiteCategoryDefinition) categoryDefs
314:                            .get(i);
315:                    if (!def.isValid())
316:                        return false;
317:                }
318:                return true;
319:            }
320:
321:            private void writeChildren(String indent, Vector children,
322:                    PrintWriter writer) {
323:                for (int i = 0; i < children.size(); i++) {
324:                    IWritable writable = (IWritable) children.get(i);
325:                    writable.write(indent, writer);
326:                }
327:            }
328:
329:            private void writeIfDefined(String indent, PrintWriter writer,
330:                    String attName, String attValue) {
331:                if (attValue == null || attValue.length() <= 0)
332:                    return;
333:                writer.println();
334:                writer
335:                        .print(indent
336:                                + attName
337:                                + "=\"" + SiteObject.getWritableString(attValue) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
338:            }
339:
340:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.