Changeset 3560
- Timestamp:
- Mar 21, 2008, 4:18:15 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/launching/RfpContainerInitializerAndResolver.java
r3558 r3560 2 2 3 3 import java.io.IOException; 4 import java.net.URL; 4 5 5 6 import org.eclipse.core.runtime.CoreException; … … 28 29 private final IClasspathEntry[] entries; 29 30 30 private RfpContainer (IPath containerPath ) {31 private RfpContainer (IPath containerPath, IClasspathEntry entry) { 31 32 this.containerPath = containerPath; 32 IPath path = RfpContainerInitializerAndResolver.getPath(); 33 IPath srcPath = RfpContainerInitializerAndResolver.getSrcPath(); 34 this.entries = path == null ? new IClasspathEntry[0] : new IClasspathEntry[] { JavaCore.newLibraryEntry( 35 path, srcPath, null) }; 33 this.entries = new IClasspathEntry[] { entry }; 36 34 } 37 35 … … 53 51 } 54 52 55 private static IPath getPath () { 56 Bundle b = Platform.getBundle("org.refal.rfpdt.runtime"); 57 if (b != null) 58 try { 59 return new Path(FileLocator.resolve(b.getEntry("/rfprt.jar")).getPath()); 60 } catch (IOException e) { 61 RfpCore.log(e); 62 } 63 return null; 53 /** May return <code>null</code>. */ 54 private static IPath getEntryPath (String bundleName, String entry) { 55 Bundle bundle = Platform.getBundle(bundleName); 56 if (bundle == null) 57 return null; 58 URL entryUrl = bundle.getEntry(entry); 59 if (entryUrl == null) 60 return null; 61 try { 62 return new Path(FileLocator.resolve(entryUrl).getPath()); 63 } catch (IOException e) { 64 return null; 65 } 64 66 } 65 67 68 /** May return <code>null</code>. */ 69 private static IPath getBinPath () { 70 return getEntryPath("org.refal.rfpdt.runtime", "rfprt.jar"); 71 } 72 73 /** May return <code>null</code>. */ 66 74 private static IPath getSrcPath () { 67 Bundle b = Platform.getBundle("org.refal.rfpdt.runtime"); 68 if (b != null) 69 try { 70 return new Path(FileLocator.resolve(b.getEntry("/rfprt-src.jar")).getPath()); 71 } catch (IOException e) { 72 RfpCore.log(e); 73 } 74 return null; 75 return getEntryPath("org.refal.rfpdt.runtime", "rfprt-src.jar"); 76 } 77 78 private static IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry () { 79 IPath path = getBinPath(); 80 if (path == null) 81 return new IRuntimeClasspathEntry[] {}; 82 else 83 return new IRuntimeClasspathEntry[] { JavaRuntime.newArchiveRuntimeClasspathEntry(path) }; 75 84 } 76 85 77 86 @Override 78 87 public void initialize (IPath containerPath, IJavaProject project) throws CoreException { 79 if (containerPath.segmentCount() > 0 && containerPath.segment(0).equals(RfpCore.RFP_CONTAINER)) { 88 IPath path = getBinPath(); 89 if (path == null) 90 RfpCore.log("Refal Plus Library can not be found", IStatus.ERROR); 91 else 80 92 JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { project }, 81 new IClasspathContainer[] { new RfpContainer(containerPath) }, null); 82 } else 83 RfpCore.log("Invalid RfpContainer path", IStatus.ERROR); 93 new IClasspathContainer[] { new RfpContainer(containerPath, JavaCore.newLibraryEntry(path, 94 getSrcPath(), null)) }, null); 84 95 } 85 96 86 97 public IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry (IRuntimeClasspathEntry entry, 87 98 ILaunchConfiguration configuration) { 88 return new IRuntimeClasspathEntry[] { JavaRuntime.newArchiveRuntimeClasspathEntry(getPath()) };99 return resolveRuntimeClasspathEntry(); 89 100 } 90 101 91 102 public IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry (IRuntimeClasspathEntry entry, IJavaProject project) { 92 return new IRuntimeClasspathEntry[] { JavaRuntime.newArchiveRuntimeClasspathEntry(getPath()) };103 return resolveRuntimeClasspathEntry(); 93 104 } 94 105
Note: See TracChangeset
for help on using the changeset viewer.