Java tutorial
/******************************************************************************* * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package com.siteview.mde.internal.core; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.*; import org.eclipse.jdt.core.*; import com.siteview.mde.core.monitor.IMonitorModelBase; import com.siteview.mde.core.monitor.MonitorRegistry; public class RequiredMonitorsInitializer extends ClasspathContainerInitializer { /* * (non-Javadoc) * @see org.eclipse.jdt.core.ClasspathContainerInitializer#initialize(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) */ public void initialize(IPath containerPath, IJavaProject javaProject) throws CoreException { IProject project = javaProject.getProject(); IMonitorModelBase model = MonitorRegistry.findModel(project); JavaCore.setClasspathContainer(MDECore.REQUIRED_PLUGINS_CONTAINER_PATH, new IJavaProject[] { javaProject }, new IClasspathContainer[] { new RequiredMonitorsClasspathContainer(model) }, null); } /* * (non-Javadoc) * @see org.eclipse.jdt.core.ClasspathContainerInitializer#getComparisonID(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) */ public Object getComparisonID(IPath containerPath, IJavaProject project) { if (containerPath == null || project == null) return null; return containerPath.segment(0) + "/" + project.getPath().segment(0); //$NON-NLS-1$ } /* * (non-Javadoc) * @see org.eclipse.jdt.core.ClasspathContainerInitializer#getDescription(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) */ public String getDescription(IPath containerPath, IJavaProject project) { return MDECoreMessages.RequiredPluginsClasspathContainer_description; } /* (non-Javadoc) * @see org.eclipse.jdt.core.ClasspathContainerInitializer#getSourceAttachmentStatus(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) */ public IStatus getSourceAttachmentStatus(IPath containerPath, IJavaProject project) { // Allow custom source attachments for PDE classpath containers (Bug 338182) return Status.OK_STATUS; } /* (non-Javadoc) * @see org.eclipse.jdt.core.ClasspathContainerInitializer#canUpdateClasspathContainer(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) */ public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project) { // The only supported update is to modify the source attachment return true; } /* (non-Javadoc) * @see org.eclipse.jdt.core.ClasspathContainerInitializer#requestClasspathContainerUpdate(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject, org.eclipse.jdt.core.IClasspathContainer) */ public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException { // The only supported update is to modify the source attachment JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { project }, new IClasspathContainer[] { containerSuggestion }, null); } }