KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > launchConfigurations > AntClasspathProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ant.internal.ui.launchConfigurations;
13
14 import java.util.ArrayList JavaDoc;
15 import java.util.List JavaDoc;
16
17 import org.eclipse.core.runtime.CoreException;
18 import org.eclipse.debug.core.ILaunchConfiguration;
19 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
20 import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
21 import org.eclipse.jdt.launching.JavaRuntime;
22 import org.eclipse.jdt.launching.StandardClasspathProvider;
23
24 public class AntClasspathProvider extends StandardClasspathProvider {
25
26     /* (non-Javadoc)
27      * @see org.eclipse.jdt.launching.IRuntimeClasspathProvider#computeUnresolvedClasspath(org.eclipse.debug.core.ILaunchConfiguration)
28      */

29     public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException {
30         boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
31         if (useDefault) {
32             List JavaDoc rtes = new ArrayList JavaDoc(10);
33             IRuntimeClasspathEntry jreEntry = null;
34             try {
35                 jreEntry = JavaRuntime.computeJREEntry(configuration);
36             } catch (CoreException e) {
37                 // not a java project
38
}
39             if (jreEntry == null) {
40                 jreEntry = JavaRuntime.newRuntimeContainerClasspathEntry(
41                         JavaRuntime.newDefaultJREContainerPath(), IRuntimeClasspathEntry.STANDARD_CLASSES);
42             }
43             rtes.add(jreEntry);
44             rtes.add(new AntHomeClasspathEntry());
45             rtes.add(new ContributedClasspathEntriesEntry());
46             return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]);
47         }
48         return super.computeUnresolvedClasspath(configuration);
49     }
50 }
51
Popular Tags