01: /*******************************************************************************
02: * Copyright (c) 2000, 2007 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.pde.internal.core;
11:
12: import org.eclipse.core.resources.IProject;
13: import org.eclipse.core.runtime.CoreException;
14: import org.eclipse.core.runtime.IPath;
15: import org.eclipse.jdt.core.ClasspathContainerInitializer;
16: import org.eclipse.jdt.core.IClasspathContainer;
17: import org.eclipse.jdt.core.IJavaProject;
18: import org.eclipse.jdt.core.JavaCore;
19: import org.eclipse.pde.core.plugin.IPluginModelBase;
20: import org.eclipse.pde.core.plugin.PluginRegistry;
21:
22: public class RequiredPluginsInitializer extends
23: ClasspathContainerInitializer {
24:
25: /*
26: * (non-Javadoc)
27: * @see org.eclipse.jdt.core.ClasspathContainerInitializer#initialize(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject)
28: */
29: public void initialize(IPath containerPath, IJavaProject javaProject)
30: throws CoreException {
31: IProject project = javaProject.getProject();
32: IPluginModelBase model = PluginRegistry.findModel(project);
33: JavaCore
34: .setClasspathContainer(
35: PDECore.REQUIRED_PLUGINS_CONTAINER_PATH,
36: new IJavaProject[] { javaProject },
37: new IClasspathContainer[] { new RequiredPluginsClasspathContainer(
38: model) }, null);
39: }
40:
41: /*
42: * (non-Javadoc)
43: * @see org.eclipse.jdt.core.ClasspathContainerInitializer#getComparisonID(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject)
44: */
45: public Object getComparisonID(IPath containerPath,
46: IJavaProject project) {
47: if (containerPath == null || project == null)
48: return null;
49:
50: return containerPath.segment(0)
51: + "/" + project.getPath().segment(0); //$NON-NLS-1$
52: }
53:
54: /*
55: * (non-Javadoc)
56: * @see org.eclipse.jdt.core.ClasspathContainerInitializer#getDescription(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject)
57: */
58: public String getDescription(IPath containerPath,
59: IJavaProject project) {
60: return PDECoreMessages.RequiredPluginsClasspathContainer_description;
61: }
62: }
|