KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > RequiredPluginsInitializer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.pde.internal.core;
12
13 import org.eclipse.core.resources.IProject;
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.core.runtime.IPath;
16 import org.eclipse.jdt.core.ClasspathContainerInitializer;
17 import org.eclipse.jdt.core.IClasspathContainer;
18 import org.eclipse.jdt.core.IJavaProject;
19 import org.eclipse.jdt.core.JavaCore;
20 import org.eclipse.pde.core.plugin.IPluginModelBase;
21 import org.eclipse.pde.core.plugin.PluginRegistry;
22
23 public class RequiredPluginsInitializer extends 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.setClasspathContainer(
34                 PDECore.REQUIRED_PLUGINS_CONTAINER_PATH,
35                 new IJavaProject[] { javaProject },
36                 new IClasspathContainer[] {new RequiredPluginsClasspathContainer(model)},
37                 null);
38     }
39     
40     /*
41      * (non-Javadoc)
42      * @see org.eclipse.jdt.core.ClasspathContainerInitializer#getComparisonID(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject)
43      */

44     public Object JavaDoc getComparisonID(IPath containerPath, IJavaProject project) {
45         if (containerPath == null || project == null)
46             return null;
47             
48         return containerPath.segment(0) + "/" + project.getPath().segment(0); //$NON-NLS-1$
49
}
50
51     /*
52      * (non-Javadoc)
53      * @see org.eclipse.jdt.core.ClasspathContainerInitializer#getDescription(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject)
54      */

55     public String JavaDoc getDescription(IPath containerPath, IJavaProject project) {
56         return PDECoreMessages.RequiredPluginsClasspathContainer_description;
57     }
58 }
59
Popular Tags