KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > snippeteditor > ScrapbookSourcepathProvider


1 /*******************************************************************************
2  * Copyright (c) 2004, 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 package org.eclipse.jdt.internal.debug.ui.snippeteditor;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.debug.core.ILaunchConfiguration;
15 import org.eclipse.jdt.core.IJavaProject;
16 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
17 import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
18 import org.eclipse.jdt.launching.JavaRuntime;
19 import org.eclipse.jdt.launching.StandardSourcePathProvider;
20
21 /**
22  * Sourcepath provider for a snippet editor
23  */

24 public class ScrapbookSourcepathProvider extends StandardSourcePathProvider {
25
26     public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException {
27         boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_SOURCE_PATH, true);
28         IRuntimeClasspathEntry[] entries = null;
29         if (useDefault) {
30             // the default source lookup path is the classpath of the associated project
31
IJavaProject project = JavaRuntime.getJavaProject(configuration);
32             entries = JavaRuntime.computeUnresolvedRuntimeClasspath(project);
33         } else {
34             // recover persisted source path
35
entries = recoverRuntimePath(configuration, IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH);
36         }
37         return entries;
38     }
39 }
40
Popular Tags