List of usage examples for org.eclipse.jdt.core IJavaProject setRawClasspath
void setRawClasspath(IClasspathEntry[] entries, IProgressMonitor monitor) throws JavaModelException;
From source file:org.jboss.ide.eclipse.as.test.classpath.JEEClasspathContainerTest.java
License:Open Source License
protected void removeContainer(IJavaProject jproject, IPath path) throws JavaModelException { ArrayList tmp = new ArrayList(); tmp.addAll(Arrays.asList(jproject.getRawClasspath())); tmp.remove(JavaCore.newContainerEntry(path)); jproject.setRawClasspath((IClasspathEntry[]) tmp.toArray(new IClasspathEntry[tmp.size()]), null); }
From source file:org.jboss.ide.eclipse.as.wtp.core.vcf.VCFClasspathCommand.java
License:Open Source License
/** * This can add any container path to a project * @param project The project to add the path to * @param path A container classpath path * @return// ww w. ja v a 2 s.c om */ public static IStatus addContainerClasspathEntry(IProject project, IPath path) { IStatus status = Status.OK_STATUS; try { IClasspathEntry newClasspath = JavaCore.newContainerEntry(path); IJavaProject javaProject = JavaCore.create(project); IClasspathEntry[] oldClasspathEntries = javaProject.readRawClasspath(); boolean isContainerInClassPathAlready = false; for (int i = 0; i < oldClasspathEntries.length && !isContainerInClassPathAlready; i++) { if (oldClasspathEntries[i].getPath().equals(newClasspath.getPath())) { isContainerInClassPathAlready = true; break; } } if (!isContainerInClassPathAlready) { IClasspathEntry[] newClasspathEntries = new IClasspathEntry[oldClasspathEntries.length + 1]; for (int i = 0; i < oldClasspathEntries.length; i++) { newClasspathEntries[i] = oldClasspathEntries[i]; } newClasspathEntries[oldClasspathEntries.length] = newClasspath; javaProject.setRawClasspath(newClasspathEntries, new NullProgressMonitor()); } } catch (JavaModelException e) { status = new Status(IStatus.ERROR, ASWTPToolsPlugin.PLUGIN_ID, e.getLocalizedMessage(), e); return status; } return status; }