Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2008 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 org.eclipse.jdt.internal.core;
import  org.eclipse.core.runtime.CoreException;
import  org.eclipse.core.runtime.IPath;
	/* (non-Javadoc)
	 * @see org.eclipse.jdt.core.ClasspathContainerInitializer#canUpdateClasspathContainer(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject)
	 */
	public boolean canUpdateClasspathContainer(IPath containerPathIJavaProject project) {
		return isUserLibraryContainer(containerPath);
	}
	/* (non-Javadoc)
	 * @see org.eclipse.jdt.core.ClasspathContainerInitializer#getComparisonID(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject)
	 */
	public Object getComparisonID(IPath containerPathIJavaProject project) {
		return containerPath;
	}

See also:
org.eclipse.jdt.core.ClasspathContainerInitializer.getDescription(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject)
	public String getDescription(IPath containerPathIJavaProject project) {
		if (isUserLibraryContainer(containerPath)) {
			return containerPath.segment(1);
		}
		return super.getDescription(containerPathproject);
	}
	public void initialize(IPath containerPathIJavaProject projectthrows CoreException {
		if (isUserLibraryContainer(containerPath)) {
			String userLibName = containerPath.segment(1);
			UserLibrary userLibrary = JavaModelManager.getUserLibraryManager().getUserLibrary(userLibName);
			if (userLibrary != null) {
				JavaCore.setClasspathContainer(containerPathnew IJavaProject[] { project }, new IClasspathContainer[] { container }, null);
				verbose_no_user_library_found(projectuserLibName);
			}
			verbose_not_a_user_library(projectcontainerPath);
		}
	}
	private boolean isUserLibraryContainer(IPath path) {
		return path != null && path.segmentCount() == 2 && ..equals(path.segment(0));
	}

See also:
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 containerPathIJavaProject projectIClasspathContainer containerSuggestionthrows CoreException {
		if (isUserLibraryContainer(containerPath)) {
			String name = containerPath.segment(1);
			if (containerSuggestion != null) {
				JavaModelManager.getUserLibraryManager().setUserLibrary(namecontainerSuggestion.getClasspathEntries(), containerSuggestion.getKind() == .);
else {
				JavaModelManager.getUserLibraryManager().removeUserLibrary(name);
			}
			// update of affected projects was done as a consequence of setUserLibrary() or removeUserLibrary()
		}
	}
	private void verbose_no_user_library_found(IJavaProject projectString userLibraryName) {
		Util.verbose(
			"UserLibrary INIT - FAILED (no user library found)\n" + //$NON-NLS-1$
			"	project: " + project.getElementName() + '\n' + //$NON-NLS-1$
			"	userLibraryName: " + userLibraryName); //$NON-NLS-1$
	}
	private void verbose_not_a_user_library(IJavaProject project, IPath containerPath) {
		Util.verbose(
			"UserLibrary INIT - FAILED (not a user library)\n" + //$NON-NLS-1$
			"	project: " + project.getElementName() + '\n' + //$NON-NLS-1$
			"	container path: " + containerPath); //$NON-NLS-1$
	}
New to GrepCode? Check out our FAQ X