List of usage examples for org.eclipse.jdt.core IClasspathEntry CPE_CONTAINER
int CPE_CONTAINER
To view the source code for org.eclipse.jdt.core IClasspathEntry CPE_CONTAINER.
Click Source Link
From source file:org.springsource.ide.eclipse.gradle.core.ClassPath.java
License:Open Source License
/** * Find class path container entry with given container ID. If more than one entry * exists the first one found will be returned. If no entry is found null will be * returned.//from w w w. j ava 2s. c o m * * @param containerID * @return First matching classpath entry or null if no match. */ public IClasspathEntry getContainer(String containerID) { for (IClasspathEntry e : getEntries(IClasspathEntry.CPE_CONTAINER)) { Assert.isLegal(e.getEntryKind() == IClasspathEntry.CPE_CONTAINER); if (containerID.equals(e.getPath().segment(0))) { return e; } } return null; }
From source file:org.springsource.ide.eclipse.gradle.core.ClassPath.java
License:Open Source License
public void removeContainer(String containerID) { Collection<IClasspathEntry> containers = getEntries(IClasspathEntry.CPE_CONTAINER); Iterator<IClasspathEntry> iter = containers.iterator(); while (iter.hasNext()) { IClasspathEntry el = iter.next(); if (el.getPath().segment(0).equals(containerID)) { iter.remove();// ww w .j av a 2 s . c o m } } }
From source file:org.springsource.ide.eclipse.gradle.core.ClassPath.java
License:Open Source License
private boolean isContainer(IClasspathEntry e, String containerID) { return e.getEntryKind() == IClasspathEntry.CPE_CONTAINER && containerID.equals(e.getPath().segment(0)); }
From source file:org.springsource.ide.eclipse.gradle.core.classpathcontainer.GradleClassPathContainer.java
License:Open Source License
public static boolean isGradleContainerEntry(IClasspathEntry e) { return e != null && e.getEntryKind() == IClasspathEntry.CPE_CONTAINER && e.getPath().segment(0).equals(ID); }
From source file:org.springsource.ide.eclipse.gradle.core.dsld.GradleDSLDClasspathContainer.java
License:Open Source License
private static boolean isGradleDSLDContainerEntry(IClasspathEntry e) { return e != null && e.getEntryKind() == IClasspathEntry.CPE_CONTAINER && e.getPath().segment(0).equals(ID); }
From source file:org.springsource.ide.eclipse.gradle.core.test.GradleImportTests.java
License:Open Source License
private void assertNoClasspathContainer(IClasspathEntry[] rawClasspath, String pathStr) { IPath path = new Path(pathStr); StringBuilder msg = new StringBuilder(); for (IClasspathEntry e : rawClasspath) { if (e.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { if (path.equals(e.getPath())) { fail("Found classpath container but shouldn't '" + pathStr + "':\n" + msg.toString()); }//from w w w.j a v a 2s .com } msg.append(e + "\n"); } }
From source file:org.springsource.ide.eclipse.gradle.core.test.GradleTest.java
License:Open Source License
/** * @param rawClasspath/* w w w. j av a 2 s .c o m*/ */ public static void assertClasspathContainer(IClasspathEntry[] rawClasspath, String pathStr) { IPath path = new Path(pathStr); StringBuilder msg = new StringBuilder(); for (IClasspathEntry e : rawClasspath) { if (e.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { if (path.equals(e.getPath())) { return; //found it } } msg.append(e + "\n"); } fail("Not found classpath container '" + pathStr + "':\n" + msg.toString()); }
From source file:org.springsource.ide.eclipse.gradle.core.wizards.GradleImportOperation.java
License:Open Source License
private void importProject(HierarchicalEclipseProject projectModel, ErrorHandler eh, IProgressMonitor monitor) { final boolean haveWorkingSets = workingSets.length > 0 || quickWorkingSetName != null; //This provisional implementation just creates a linked project pointing to wherever the root folder // is pointing to. int totalWork = 8; if (addResourceFilters) { totalWork++; //9 }//w w w . j a v a 2 s.co m if (haveWorkingSets) { totalWork++; //10 } monitor.beginTask("Import " + projectModel.getName(), totalWork); try { //1 IWorkspace ws = ResourcesPlugin.getWorkspace(); String projectName = getEclipseName(projectModel); File projectDir = projectModel.getProjectDirectory().getCanonicalFile(); //TODO: is this right for subfolders (locations maybe better relative to ws somehow) IProjectDescription projectDescription = ws.newProjectDescription(projectName); if (!isDefaultProjectLocation(projectName, projectDir)) { projectDescription.setLocation(new Path(projectDir.getAbsolutePath())); } monitor.worked(1); //2 IProject project = ws.getRoot().getProject(projectName); if (isReimport) { Assert.isLegal(project.exists()); } else { project.create(projectDescription, new SubProgressMonitor(monitor, 1)); } //3 GradleProject gProj = GradleCore.create(projectModel); GradleRefreshPreferences refreshPrefs = gProj.getRefreshPreferences(); refreshPrefs.copyFrom(this); //4 if (addResourceFilters) { createResourceFilters(project, projectModel, new SubProgressMonitor(monitor, 1)); } //5 if (isReimport) { project.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 1)); } else { project.open(new SubProgressMonitor(monitor, 1)); } //6..7 if (project.hasNature(GradleNature.OLD_NATURE_ID)) { // project needs migration (i.e. remove old nature and classpath container entries) NatureUtils.remove(project, GradleNature.OLD_NATURE_ID, new SubProgressMonitor(monitor, 1)); IJavaProject javaproject = gProj.getJavaProject(); IClasspathEntry[] oldEntries = javaproject.getRawClasspath(); List<IClasspathEntry> newEntries = new ArrayList<IClasspathEntry>(oldEntries.length); for (IClasspathEntry e : oldEntries) { boolean remove = e.getEntryKind() == IClasspathEntry.CPE_CONTAINER && e.getPath().toString().startsWith("com.springsource.sts.gradle"); if (!remove) { newEntries.add(e); } } javaproject.setRawClasspath(newEntries.toArray(new IClasspathEntry[newEntries.size()]), true, new SubProgressMonitor(monitor, 1)); } else { monitor.worked(2); } //8..9 boolean generateOnly = !getEnableDependencyManagement(); if (generateOnly) { try { NatureUtils.ensure(project, new SubProgressMonitor(monitor, 1), GradleNature.NATURE_ID, //Must be first to make gradle project icon have gradle nature showing JavaCore.NATURE_ID); DSLDSupport.maybeAdd(gProj, eh, new SubProgressMonitor(monitor, 1)); } catch (CoreException e) { eh.handleError(e); } } else { gProj.convertToGradleProject(projectMapper, eh, new SubProgressMonitor(monitor, 2)); } //10 if (haveWorkingSets) { addToWorkingSets(project, new SubProgressMonitor(monitor, 1)); } } catch (Exception e) { eh.handleError(e); } finally { monitor.done(); } }
From source file:org.summer.ss.ide.buildpath.SsLibClasspathAdder.java
License:Open Source License
protected boolean addToClasspath(IJavaProject javaProject, IProgressMonitor monitor) throws JavaModelException { IClasspathEntry xtendContainerEntry = JavaCore.newContainerEntry(SsContainerInitializer.XTEND_LIBRARY_PATH); IClasspathEntry[] rawClasspath = javaProject.getRawClasspath(); IClasspathEntry[] newRawClasspath = new IClasspathEntry[rawClasspath.length + 1]; for (int i = 0; i < rawClasspath.length; ++i) { IClasspathEntry entry = rawClasspath[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER && entry.getPath().equals(xtendContainerEntry.getPath())) { return false; }/*from w ww . j a v a 2s .com*/ newRawClasspath[i + 1] = entry; } newRawClasspath[0] = xtendContainerEntry; javaProject.setRawClasspath(newRawClasspath, monitor); return true; }
From source file:org.talend.designer.maven.project.CreateMavenCodeProject.java
License:Open Source License
private void changeClasspath(IProgressMonitor monitor, IProject p) { try {//from ww w. j av a2s .c om IJavaProject javaProject = JavaCore.create(p); IClasspathEntry[] rawClasspathEntries = javaProject.getRawClasspath(); boolean changed = false; for (int index = 0; index < rawClasspathEntries.length; index++) { IClasspathEntry entry = rawClasspathEntries[index]; IClasspathEntry newEntry = null; if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath path = entry.getPath(); if (p.getFullPath().isPrefixOf(path)) { path = path.removeFirstSegments(1); } // src/main/resources, in order to removing the 'excluding="**"'. if (MavenSystemFolders.RESOURCES.getPath().equals(path.toString())) { newEntry = JavaCore.newSourceEntry(entry.getPath(), new IPath[0], new IPath[0], // entry.getOutputLocation(), entry.getExtraAttributes()); } } else if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { // remove the special version of jre in container. IPath defaultJREContainerPath = JavaRuntime.newDefaultJREContainerPath(); if (defaultJREContainerPath.isPrefixOf(entry.getPath())) { // JavaRuntime.getDefaultJREContainerEntry(); //missing properties // newEntry = JavaCore.newContainerEntry(defaultJREContainerPath, entry.getAccessRules(), // entry.getExtraAttributes(), entry.isExported()); } } if (newEntry != null) { rawClasspathEntries[index] = newEntry; changed = true; } } if (changed) { javaProject.setRawClasspath(rawClasspathEntries, monitor); } } catch (CoreException e) { ExceptionHandler.process(e); } }