01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.ui.examples;
11:
12: import org.eclipse.core.runtime.CoreException;
13: import org.eclipse.core.runtime.IPath;
14: import org.eclipse.core.runtime.Path;
15:
16: import org.eclipse.jdt.core.ClasspathContainerInitializer;
17: import org.eclipse.jdt.core.IClasspathContainer;
18: import org.eclipse.jdt.core.IClasspathEntry;
19: import org.eclipse.jdt.core.IJavaProject;
20: import org.eclipse.jdt.core.JavaCore;
21:
22: /**
23: *
24: */
25: public class MyClasspathContainerInitializer extends
26: ClasspathContainerInitializer {
27:
28: public static class MyClasspathContainer implements
29: IClasspathContainer {
30:
31: private final IPath fPath;
32: private static final IPath MY_ARCHIVE = new Path("C:\\xy.jar");
33:
34: public MyClasspathContainer(IPath path) {
35: fPath = path;
36: }
37:
38: public IClasspathEntry[] getClasspathEntries() {
39: return new IClasspathEntry[] { JavaCore.newLibraryEntry(
40: MY_ARCHIVE, null, null) };
41: }
42:
43: public String getDescription() {
44: return "My example";
45: }
46:
47: public int getKind() {
48: return IClasspathContainer.K_APPLICATION;
49: }
50:
51: public IPath getPath() {
52: return fPath;
53: }
54:
55: }
56:
57: public void initialize(IPath containerPath, IJavaProject project)
58: throws CoreException {
59: IClasspathContainer[] containers = { new MyClasspathContainer(
60: containerPath) };
61: JavaCore.setClasspathContainer(containerPath,
62: new IJavaProject[] { project }, containers, null);
63: }
64:
65: }
|