Source Code Cross Referenced for PDESourcePathProvider.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » ui » launcher » 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.ui.launcher 
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.ui.launcher;
011:
012:        import java.util.ArrayList;
013:        import java.util.List;
014:
015:        import org.eclipse.core.resources.IProject;
016:        import org.eclipse.core.resources.IResource;
017:        import org.eclipse.core.runtime.CoreException;
018:        import org.eclipse.core.runtime.IPath;
019:        import org.eclipse.core.runtime.Path;
020:        import org.eclipse.debug.core.ILaunchConfiguration;
021:        import org.eclipse.jdt.core.IJavaProject;
022:        import org.eclipse.jdt.core.IPackageFragmentRoot;
023:        import org.eclipse.jdt.core.JavaCore;
024:        import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
025:        import org.eclipse.jdt.launching.IVMInstall;
026:        import org.eclipse.jdt.launching.JavaRuntime;
027:        import org.eclipse.jdt.launching.StandardSourcePathProvider;
028:        import org.eclipse.pde.internal.core.util.PDEJavaHelper;
029:        import org.eclipse.pde.internal.ui.PDEPlugin;
030:        import org.eclipse.pde.internal.ui.launcher.LaunchPluginValidator;
031:        import org.eclipse.pde.internal.ui.launcher.VMHelper;
032:
033:        /**
034:         * Generates a source lookup path for all PDE-based launch configurations
035:         * <p>
036:         * Clients may subclass this class.
037:         * </p>
038:         * @since 3.3
039:         */
040:        public class PDESourcePathProvider extends StandardSourcePathProvider {
041:
042:            public static final String ID = "org.eclipse.pde.ui.workbenchClasspathProvider"; //$NON-NLS-1$
043:
044:            /*
045:             * (non-Javadoc)
046:             * @see org.eclipse.jdt.launching.StandardSourcePathProvider#computeUnresolvedClasspath(org.eclipse.debug.core.ILaunchConfiguration)
047:             */
048:            public IRuntimeClasspathEntry[] computeUnresolvedClasspath(
049:                    ILaunchConfiguration configuration) throws CoreException {
050:                List sourcePath = new ArrayList();
051:                sourcePath.add(getJREEntry(configuration));
052:                IProject[] projects = getJavaProjects(configuration);
053:                for (int i = 0; i < projects.length; i++) {
054:                    sourcePath.add(JavaRuntime
055:                            .newProjectRuntimeClasspathEntry(JavaCore
056:                                    .create(projects[i])));
057:                }
058:                return (IRuntimeClasspathEntry[]) sourcePath
059:                        .toArray(new IRuntimeClasspathEntry[sourcePath.size()]);
060:            }
061:
062:            /**
063:             * Returns a JRE runtime classpath entry
064:             * 
065:             * @param configuration
066:             * 			the launch configuration
067:             * @return a JRE runtime classpath entry
068:             * @throws CoreException
069:             * 			if the JRE associated with the launch configuration cannot be found
070:             * 			or if unable to retrieve the launch configuration attributes
071:             */
072:            private IRuntimeClasspathEntry getJREEntry(
073:                    ILaunchConfiguration configuration) throws CoreException {
074:                IVMInstall jre = VMHelper.createLauncher(configuration);
075:                IPath containerPath = new Path(JavaRuntime.JRE_CONTAINER);
076:                containerPath = containerPath.append(jre.getVMInstallType()
077:                        .getId());
078:                containerPath = containerPath.append(jre.getName());
079:                return JavaRuntime
080:                        .newRuntimeContainerClasspathEntry(containerPath,
081:                                IRuntimeClasspathEntry.BOOTSTRAP_CLASSES);
082:            }
083:
084:            /**
085:             * Returns an array of sorted plug-in projects that represent plug-ins participating
086:             * in the launch
087:             * 
088:             * @param configuration
089:             * 			the launch configuration
090:             * @return an array of ordered projects
091:             * @throws CoreException
092:             * 			if unable to retrieve attributes from the launch configuration or if 
093:             * 			an error occurs when checking the nature of the project
094:             * 			
095:             */
096:            private IProject[] getJavaProjects(
097:                    ILaunchConfiguration configuration) throws CoreException {
098:                IProject[] projects = LaunchPluginValidator
099:                        .getAffectedProjects(configuration);
100:                return PDEPlugin.getWorkspace().computeProjectOrder(projects).projects;
101:            }
102:
103:            /*
104:             * (non-Javadoc)
105:             * @see org.eclipse.jdt.launching.StandardSourcePathProvider#resolveClasspath(org.eclipse.jdt.launching.IRuntimeClasspathEntry[], org.eclipse.debug.core.ILaunchConfiguration)
106:             */
107:            public IRuntimeClasspathEntry[] resolveClasspath(
108:                    IRuntimeClasspathEntry[] entries,
109:                    ILaunchConfiguration configuration) throws CoreException {
110:                List all = new ArrayList(entries.length);
111:                for (int i = 0; i < entries.length; i++) {
112:                    if (entries[i].getType() == IRuntimeClasspathEntry.PROJECT) {
113:                        // a project resolves to itself for source lookup (rather than
114:                        // the class file output locations)
115:                        all.add(entries[i]);
116:                        // also add non-JRE libraries
117:                        IResource resource = entries[i].getResource();
118:                        if (resource instanceof  IProject) {
119:                            addBinaryPackageFragmentRoots(JavaCore
120:                                    .create((IProject) resource), all);
121:                        }
122:                    } else {
123:                        IRuntimeClasspathEntry[] resolved = JavaRuntime
124:                                .resolveRuntimeClasspathEntry(entries[i],
125:                                        configuration);
126:                        for (int j = 0; j < resolved.length; j++) {
127:                            all.add(resolved[j]);
128:                        }
129:                    }
130:                }
131:                return (IRuntimeClasspathEntry[]) all
132:                        .toArray(new IRuntimeClasspathEntry[all.size()]);
133:            }
134:
135:            /**
136:             * Adds runtime classpath entries for binary package fragment roots contained within
137:             * the project
138:             * 
139:             * @param jProject
140:             * 			the Java project whose roots are to be enumerated
141:             * @param all
142:             * 			a list of accumulated runtime classpath entries
143:             * @throws CoreException
144:             * 			if unable to evaluate the package fragment roots
145:             */
146:            private void addBinaryPackageFragmentRoots(IJavaProject jProject,
147:                    List all) throws CoreException {
148:                IPackageFragmentRoot[] roots = jProject
149:                        .getPackageFragmentRoots();
150:                for (int j = 0; j < roots.length; j++) {
151:                    if (roots[j].getKind() == IPackageFragmentRoot.K_BINARY
152:                            && !PDEJavaHelper.isJRELibrary(roots[j])) {
153:                        IRuntimeClasspathEntry rte = JavaRuntime
154:                                .newArchiveRuntimeClasspathEntry(roots[j]
155:                                        .getPath());
156:                        IPath path = roots[j].getSourceAttachmentPath();
157:                        if (path != null) {
158:                            rte.setSourceAttachmentPath(path);
159:                            rte.setSourceAttachmentRootPath(roots[j]
160:                                    .getSourceAttachmentRootPath());
161:                        }
162:                        if (!all.contains(rte))
163:                            all.add(rte);
164:                    }
165:                }
166:
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.