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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
003:         * This program and the accompanying materials are made available under the
004:         * terms of the Eclipse Public License v1.0 which accompanies this distribution,
005:         * and is available at http://www.eclipse.org/legal/epl-v10.html
006:         * 
007:         * Contributors: IBM - Initial API and implementation
008:         ******************************************************************************/package org.eclipse.pde.internal.build.site;
009:
010:        import java.io.File;
011:        import java.net.MalformedURLException;
012:        import java.net.URL;
013:        import java.util.*;
014:        import org.eclipse.core.runtime.*;
015:        import org.eclipse.osgi.util.NLS;
016:        import org.eclipse.pde.build.Constants;
017:        import org.eclipse.pde.internal.build.*;
018:        import org.eclipse.update.core.*;
019:        import org.eclipse.update.core.model.InvalidSiteTypeException;
020:        import org.eclipse.update.core.model.SiteModel;
021:
022:        public class BuildTimeSiteFactory extends BaseSiteFactory implements 
023:                ISiteFactory, IPDEBuildConstants {
024:            // The whole site : things to be compiled and the installedBase
025:            private Site site = null;
026:
027:            // Indicate if the content of the site changed
028:            private boolean urlsChanged = false;
029:
030:            // URLs from the the site will be built
031:            private String[] sitePaths;
032:
033:            //	address of the site used as a base
034:            private static String installedBaseLocation = null;
035:
036:            private boolean reportResolutionErrors;
037:
038:            private PDEUIStateWrapper pdeUIState;
039:
040:            //Support for filtering the state
041:            private List rootFeaturesForFilter;
042:            private List rootPluginsForFilter;
043:            private boolean filterState;
044:
045:            /** 
046:             * Create a build time site, using the sitePaths, and the installedBaseLocation.
047:             * Note that the site object is not recomputed if no change has been done.
048:             * 
049:             * @return ISite
050:             * @throws CoreException
051:             */
052:            public ISite createSite() throws CoreException {
053:                if (site != null && urlsChanged == false)
054:                    return site;
055:
056:                urlsChanged = false;
057:                site = (Site) createSiteMapModel();
058:
059:                // Here we find the features in the URLs
060:                Collection featureXMLs = findFeatureXMLs();
061:
062:                // If an installed base is provided we need to look at it
063:                String installedBaseURL = null;
064:                if (installedBaseLocation != null
065:                        && !installedBaseLocation.equals("")) { //$NON-NLS-1$
066:                    if (!new File(installedBaseLocation).exists()) {
067:                        String message = NLS.bind(
068:                                Messages.error_incorrectDirectoryEntry,
069:                                installedBaseLocation);
070:                        throw new CoreException(new Status(IStatus.ERROR,
071:                                PI_PDEBUILD, EXCEPTION_READ_DIRECTORY, message,
072:                                null));
073:                    }
074:
075:                    installedBaseURL = installedBaseLocation;
076:                    Collection installedFeatures = Utils.findFiles(new File(
077:                            installedBaseLocation), DEFAULT_FEATURE_LOCATION,
078:                            Constants.FEATURE_FILENAME_DESCRIPTOR);
079:                    if (installedFeatures != null)
080:                        featureXMLs.addAll(installedFeatures);
081:
082:                    // extract features from platform.xml
083:                    File[] featureDirectories = PluginPathFinder
084:                            .getFeaturePaths(installedBaseURL);
085:                    for (int i = 0; i < featureDirectories.length; i++) {
086:                        File featureXML = new File(featureDirectories[i],
087:                                Constants.FEATURE_FILENAME_DESCRIPTOR);
088:                        if (featureXML.exists())
089:                            featureXMLs.add(featureXML);
090:                    }
091:
092:                }
093:
094:                URL featureURL;
095:                SiteFeatureReferenceModel featureRef;
096:
097:                for (Iterator iter = featureXMLs.iterator(); iter.hasNext();) {
098:                    File featureXML = (File) iter.next();
099:                    if (featureXML.exists()) {
100:                        // Here we could not use toURL() on currentFeatureDir, because the URL has a slash after the colons (file:/c:/foo) whereas the plugins don't
101:                        // have it (file:d:/eclipse/plugins) and this causes problems later to compare URLs... and compute relative paths
102:                        try {
103:                            featureURL = new URL(
104:                                    "file:" + featureXML.getAbsolutePath()); //$NON-NLS-1$
105:                            featureRef = createFeatureReferenceModel();
106:                            featureRef.setSiteModel(site);
107:                            featureRef
108:                                    .setURLString(featureURL.toExternalForm());
109:                            featureRef
110:                                    .setType(BuildTimeFeatureFactory.BUILDTIME_FEATURE_FACTORY_ID);
111:                            site.addFeatureReferenceModel(featureRef);
112:                        } catch (MalformedURLException e) {
113:                            BundleHelper
114:                                    .getDefault()
115:                                    .getLog()
116:                                    .log(
117:                                            new Status(
118:                                                    IStatus.WARNING,
119:                                                    PI_PDEBUILD,
120:                                                    WARNING_MISSING_SOURCE,
121:                                                    NLS
122:                                                            .bind(
123:                                                                    Messages.warning_cannotLocateSource,
124:                                                                    featureXML
125:                                                                            .getAbsolutePath()),
126:                                                    e));
127:                        }
128:                    }
129:                }
130:                ISiteContentProvider contentProvider = new BuildTimeSiteContentProvider(
131:                        sitePaths, installedBaseURL, pdeUIState);
132:                site.setSiteContentProvider(contentProvider);
133:                contentProvider.setSite(site);
134:                return site;
135:            }
136:
137:            /** 
138:             * This method MUST not be called. The given URL is a pointer to the location
139:             * of a site.xml file which describes our site, and we don't have this file.
140:             */
141:            public ISite createSite(URL url) throws CoreException,
142:                    InvalidSiteTypeException {
143:                throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD,
144:                        EXCEPTION_READ_DIRECTORY,
145:                        Messages.error_incorrectDirectoryEntry, null));
146:            }
147:
148:            public SiteModel createSiteMapModel() {
149:                BuildTimeSite model = new BuildTimeSite();
150:                model.setReportResolutionErrors(reportResolutionErrors);
151:                model.setFilter(filterState);
152:                model.setRootFeaturesForFilter(rootFeaturesForFilter);
153:                model.setRootPluginsForFiler(rootPluginsForFilter);
154:                return model;
155:            }
156:
157:            public static void setInstalledBaseSite(String installedBaseSite) {
158:                BuildTimeSiteFactory.installedBaseLocation = installedBaseSite;
159:            }
160:
161:            public void setSitePaths(String[] urls) {
162:                if (sitePaths == null) {
163:                    sitePaths = urls;
164:                    urlsChanged = true;
165:                    return;
166:                }
167:
168:                //Check if urls are not the same than sitePaths.  
169:                int i = 0;
170:                boolean found = true;
171:                while (found && i < sitePaths.length) {
172:                    found = false;
173:                    for (int j = 0; j < urls.length; j++) {
174:                        if (sitePaths[i].equals(urls[j])) {
175:                            found = true;
176:                            break;
177:                        }
178:                    }
179:                    i++;
180:                }
181:                if (!found) {
182:                    sitePaths = urls;
183:                    urlsChanged = true;
184:                }
185:            }
186:
187:            /**
188:             * Look for the feature.xml files and return a collection of java.io.File objects
189:             * which point to their locations. Only look in directories which are direct descendants
190:             * of the /features directory. (do not do an infinite depth look-up)
191:             */
192:            private Collection findFeatureXMLs() {
193:                Collection features = new ArrayList();
194:                for (int i = 0; i < sitePaths.length; i++) {
195:                    Collection foundFeatures = Utils.findFiles(new File(
196:                            sitePaths[i]), DEFAULT_FEATURE_LOCATION,
197:                            Constants.FEATURE_FILENAME_DESCRIPTOR);
198:                    if (foundFeatures != null)
199:                        features.addAll(foundFeatures);
200:                }
201:                return features;
202:            }
203:
204:            public void setReportResolutionErrors(boolean value) {
205:                reportResolutionErrors = value;
206:            }
207:
208:            public void setInitialState(PDEUIStateWrapper uiState) {
209:                this .pdeUIState = uiState;
210:            }
211:
212:            public void setFilterState(boolean b) {
213:                this .filterState = b;
214:            }
215:
216:            public void setFilterRoots(List featuresForFilterRoots,
217:                    List pluginsForFilterRoots) {
218:                this.rootFeaturesForFilter = featuresForFilterRoots;
219:                this.rootPluginsForFilter = pluginsForFilterRoots;
220:            }
221:
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.