当前位置: 首页>>代码示例>>Java>>正文


Java IJavaProject.getRawClasspath方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.IJavaProject.getRawClasspath方法的典型用法代码示例。如果您正苦于以下问题:Java IJavaProject.getRawClasspath方法的具体用法?Java IJavaProject.getRawClasspath怎么用?Java IJavaProject.getRawClasspath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.IJavaProject的用法示例。


在下文中一共展示了IJavaProject.getRawClasspath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addJunit4Libraries

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
 * Add JUnit libraries to the passed project
 * 
 * @param project
 * @throws JavaModelException
 */
private static void addJunit4Libraries(IProject project) throws JavaModelException {
	IClasspathEntry entry = JavaCore.newContainerEntry(JUnitCore.JUNIT4_CONTAINER_PATH);
	IJavaProject javaProject = JavaCore.create(project);
	IClasspathEntry[] entries = javaProject.getRawClasspath();
	boolean junitFound = false;
	String s = entry.getPath().toString();
	for (int i = 0; i < entries.length; i++) {
		if (entries[i].getPath().toString().indexOf(s) != -1) {
			junitFound = true;
			break;
		}
	}
	if (!junitFound) {
		IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
		System.arraycopy(entries, 0, newEntries, 0, entries.length);
		newEntries[entries.length] = entry;
		javaProject.setRawClasspath(newEntries, null);
	}
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:26,代码来源:ClasspathManager.java

示例2: addGW4EClassPathContainer

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
 * Add GraphWalker libraries to the passed project
 * 
 * @param project
 * @throws JavaModelException
 */
public static void addGW4EClassPathContainer(IProject project) throws JavaModelException {
	if (hasGW4EClassPathContainer(project)) {
		return;
	}
	IJavaProject javaProject = JavaCore.create(project); 
	IClasspathEntry[] entries = javaProject.getRawClasspath();
	IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
	System.arraycopy(entries, 0, newEntries, 0, entries.length);
	Path lcp = new Path(GW4ELibrariesContainer.ID);
	IClasspathEntry libEntry = JavaCore.newContainerEntry(lcp, true);
	newEntries[entries.length] = JavaCore.newContainerEntry(libEntry.getPath(), true);
	javaProject.setRawClasspath(newEntries, null);
	 
  	addJunit4Libraries(project);
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:22,代码来源:ClasspathManager.java

示例3: removeFolderFromClasspath

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
 * Remove the passed folder from ClassPath
 * 
 * @param project
 * @param folderPath
 * @param monitor
 * @throws JavaModelException
 */
public static void removeFolderFromClasspath(IProject project, String folderPath, IProgressMonitor monitor)
		throws JavaModelException {
	IJavaProject javaProject = JavaCore.create(project);
	IClasspathEntry[] entries = javaProject.getRawClasspath();
	List<IClasspathEntry> newEntries = new ArrayList<IClasspathEntry>();
	IPath folder = project.getFolder(folderPath).getFullPath();
	for (int i = 0; i < entries.length; i++) {
		if (!entries[i].getPath().equals(folder)) {
			newEntries.add(entries[i]);
		}
	}
	entries = new IClasspathEntry[newEntries.size()];
	newEntries.toArray(entries);
	javaProject.setRawClasspath(entries, monitor);

}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:25,代码来源:ClasspathManager.java

示例4: getFilteredSourceFolders

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
 * @param projectName
 * @return the direct child folders of the project
 * @throws CoreException
 */
public static List<String> getFilteredSourceFolders(String projectName, String[] excludes) throws CoreException {
	List<String> ret = new ArrayList<String>();
	IJavaProject javaProject = (IJavaProject) JavaCore.create(getProject(projectName));
	IClasspathEntry[] entries = javaProject.getRawClasspath();
	for (int i = 0; i < entries.length; i++) {
		IClasspathEntry entry = entries[i];
		if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
			IPath path = entry.getPath().makeRelativeTo(new Path(projectName));
			boolean isExcluded = false;
			for (int j = 0; j < excludes.length; j++) {

				if (excludes[j].equalsIgnoreCase(path.toString())) {
					isExcluded = true;
					break;
				}
			}
			if (!isExcluded) {
				String p = path.toString();
				ret.add(p);
			}
		}
	}

	return ret;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:31,代码来源:ResourceManager.java

示例5: hasGW4EClassPathContainer

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
 * 
 * @param project
 * @return whether the project has the GW4E ClassPathContainer
 * @throws JavaModelException
 */
public static boolean hasGW4EClassPathContainer(IProject project) throws JavaModelException {
	IJavaProject javaProject = JavaCore.create(project);
	IClasspathEntry[] entries = javaProject.getRawClasspath();
	for (int i = 0; i < entries.length; i++) {
		if (entries[i].getPath().toString().startsWith(GW4ELibrariesContainer.ID)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:17,代码来源:ClasspathManager.java

示例6: ensureExcludedPath

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
 * Manage source folders exclusion
 * 
 * @param project
 * @param rootSrcEntry
 * @param relative
 * @return
 * @throws JavaModelException
 */
private static IClasspathEntry ensureExcludedPath(IProject project, IClasspathEntry rootSrcEntry,
		String relative) throws JavaModelException {
	if (rootSrcEntry == null)
		return rootSrcEntry;
	IJavaProject javaProject = JavaCore.create(project);
	IClasspathEntry[] entries = javaProject.getRawClasspath();
	IPath[] excluded = rootSrcEntry.getExclusionPatterns();
	boolean entryFound = false;
	for (int i = 0; i < excluded.length; i++) {
		if (excluded[i].toString().equalsIgnoreCase(relative)) {
			entryFound = true;
			break;
		}
	}
	if (!entryFound) {
		IPath rootSrcPath = javaProject.getPath().append("src");
		IPath[] newEntries = new IPath[excluded.length + 1];
		System.arraycopy(excluded, 0, newEntries, 0, excluded.length);
		newEntries[excluded.length] = new Path(relative);
		rootSrcEntry = JavaCore.newSourceEntry(rootSrcPath, newEntries);
		entries = javaProject.getRawClasspath();
		List<IClasspathEntry> temp = new ArrayList<IClasspathEntry>();
		temp.add(rootSrcEntry);
		for (int i = 0; i < entries.length; i++) {
			if (!(entries[i].getPath().equals(rootSrcPath))) {
				temp.add(entries[i]);
			}
		}
		IClasspathEntry[] array = new IClasspathEntry[temp.size()];
		temp.toArray(array);
		javaProject.setRawClasspath(array, null);
	}
	return rootSrcEntry;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:44,代码来源:ClasspathManager.java

示例7: childrenExistInClasspath

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
 * Return whether folderPath has children in the classpath
 * 
 * @param project
 * @param folderPath
 * @param monitor
 * @return
 * @throws JavaModelException
 */
public static IResource childrenExistInClasspath(IProject project, String folderPath, IProgressMonitor monitor)
		throws JavaModelException {
	IJavaProject javaProject = JavaCore.create(project);
	IClasspathEntry[] entries = javaProject.getRawClasspath();
	IPath folder = project.getFolder(folderPath).getFullPath();
	for (int i = 0; i < entries.length; i++) {
		if (folder.isPrefixOf(entries[i].getPath())) {
			IPath path = entries[i].getPath();
			IResource resource = ResourceManager.getResource(path.toString());
			return resource;
		}
	}
	return null;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:24,代码来源:ClasspathManager.java

示例8: ensureFolderInClasspath

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
 * Make sure the passed folder is in the classpath
 * 
 * @param project
 * @param folderPath
 * @param monitor
 * @return
 * @throws JavaModelException
 */
public static IClasspathEntry ensureFolderInClasspath(IProject project, String folderPath,
		IProgressMonitor monitor) throws JavaModelException {
	IJavaProject javaProject = JavaCore.create(project);

	if (folderPath.startsWith("src")) {
		handleFolderExclusion(project, folderPath);
	}

	IClasspathEntry[] entries = javaProject.getRawClasspath();

	boolean classpathentryFound = false;
	IPath folder = project.getFolder(folderPath).getFullPath();
	for (int i = 0; i < entries.length; i++) {

		if (entries[i].getPath().equals(folder)) {
			classpathentryFound = true;
			return entries[i];
		}
	}
	if (!classpathentryFound) {
		IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
		System.arraycopy(entries, 0, newEntries, 0, entries.length);
		IPath srcPath = javaProject.getPath().append(folderPath);
		IClasspathEntry srcEntry = JavaCore.newSourceEntry(srcPath, null);
		newEntries[entries.length] = JavaCore.newSourceEntry(srcEntry.getPath());
		javaProject.setRawClasspath(newEntries, monitor);
		return srcEntry;
	}
	return null;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:40,代码来源:ClasspathManager.java

示例9: handleFolderExclusion

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
 * Manage source folders exclusion
 * 
 * @param project
 * @param folderPath
 * @throws JavaModelException
 */
private static void handleFolderExclusion(IProject project, String folderPath) throws JavaModelException {
	IJavaProject javaProject = JavaCore.create(project);
	IClasspathEntry[] entries = javaProject.getRawClasspath();
	IClasspathEntry rootSrcEntry = null;
	IPath srcPath = javaProject.getPath().append("src");
	for (int i = 0; i < entries.length; i++) {
		if ((entries[i].getPath().equals(srcPath))) {
			rootSrcEntry = entries[i];
			break;
		}
	}

	// 'src' folder by itslef is not in the build path ...
	if (rootSrcEntry == null)
		return;

	String relative = folderPath.substring("src/".length()).concat("/");

	StringTokenizer st = new StringTokenizer(relative, "/");
	StringBuffer sb = new StringBuffer();
	while (st.hasMoreTokens()) {
		String temp = st.nextToken();
		sb.append(temp).append("/");
		rootSrcEntry = ClasspathManager.ensureExcludedPath(project, rootSrcEntry, sb.toString());
	}

}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:35,代码来源:ClasspathManager.java

示例10: removeGW4EClassPathContainer

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
 * Remove GW4E ClassPath Container
 * 
 * @param project
 * @param monitor
 * @throws JavaModelException
 */
public static void removeGW4EClassPathContainer(IProject project, IProgressMonitor monitor)
		throws JavaModelException {
	IJavaProject javaProject = JavaCore.create(project);
	IClasspathEntry[] entries = javaProject.getRawClasspath();
	List<IClasspathEntry> newEntries = new ArrayList<IClasspathEntry>();
	for (int i = 0; i < entries.length; i++) {
		if (!GW4ELibrariesContainer.isMe(entries[i])) {
			newEntries.add(entries[i]);
		}
	}
	entries = new IClasspathEntry[newEntries.size()];
	newEntries.toArray(entries);
	javaProject.setRawClasspath(entries, monitor);
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:22,代码来源:ClasspathManager.java

示例11: addGWClassPathEntry

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
public static void addGWClassPathEntry(IJavaProject javaProject) throws JavaModelException {
	IClasspathEntry[] entries = javaProject.getRawClasspath();
	IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
	System.arraycopy(entries, 0, newEntries, 0, entries.length);
	Path lcp = new Path(GW4ELibrariesContainer.ID);
	IClasspathEntry libEntry = JavaCore.newContainerEntry(lcp, true);
	newEntries[entries.length] = JavaCore.newContainerEntry(libEntry.getPath(), true);
	javaProject.setRawClasspath(newEntries, new NullProgressMonitor());
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:10,代码来源:ProjectHelper.java

示例12: addToClasspath

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
public static void addToClasspath(IJavaProject jproject, IClasspathEntry cpe) throws JavaModelException {
	IClasspathEntry[] oldEntries = jproject.getRawClasspath();
	for (int i = 0; i < oldEntries.length; i++) {
		if (oldEntries[i].equals(cpe)) {
			return;
		}
	}
	int nEntries = oldEntries.length;
	IClasspathEntry[] newEntries = new IClasspathEntry[nEntries + 1];
	System.arraycopy(oldEntries, 0, newEntries, 0, nEntries);
	newEntries[nEntries] = cpe;
	jproject.setRawClasspath(newEntries, new NullProgressMonitor());
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:14,代码来源:ProjectHelper.java

示例13: isFolderInClassPath

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
public static boolean isFolderInClassPath(IJavaProject jproject, String f) throws CoreException {
	IClasspathEntry[] entries = jproject.getRawClasspath();
	IPath folder = jproject.getPath().append(f);
	for (int i = 0; i < entries.length; i++) {
		if (entries[i].getPath().equals(folder)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:11,代码来源:ProjectHelper.java

示例14: addEntry

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
 * Add a new entry to the existing java project
 * 	you can use JavaCore factory to create the entry itself
 * 	ex : JavaCore.newProjectEntry(ecoreIFile.getProject().getFullPath())
 * If the entry is already there, the method will do nothing.
 */
public static void addEntry(IProject project, IClasspathEntry newEntry, IProgressMonitor monitor) throws CoreException{
	IJavaProject javaProject = (IJavaProject)project.getNature(JavaCore.NATURE_ID);
	ArrayList<IClasspathEntry> newClassPathArrayList = new ArrayList<IClasspathEntry>();
	IClasspathEntry[] previousentries = javaProject.getRawClasspath();
	for(IClasspathEntry previousentry : previousentries){
		newClassPathArrayList.add(previousentry);
	}
	if(!newClassPathArrayList.contains(newEntry)){
		newClassPathArrayList.add(newEntry);
		IClasspathEntry[] newClassPath = new IClasspathEntry[newClassPathArrayList.size()];
		javaProject.setRawClasspath(newClassPathArrayList.toArray(newClassPath), monitor);
	}
}
 
开发者ID:eclipse,项目名称:gemoc-studio,代码行数:20,代码来源:ClasspathHelper.java

示例15: addClassPathEntry

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
private void addClassPathEntry(IPath tempSrcFolder) throws JavaModelException {
	IJavaProject javaProject=JavaCore.create(BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject());
	oldClasspathEntry=javaProject.getRawClasspath();
	IClasspathEntry[] newClasspathEntry=new IClasspathEntry[oldClasspathEntry.length+1];
	for(int index=0;index<newClasspathEntry.length-1;index++){
		if(oldClasspathEntry[index].getPath().equals(tempSrcFolder))
			return ;
		newClasspathEntry[index]=javaProject.getRawClasspath()[index];
	}
	newClasspathEntry[newClasspathEntry.length-1]=JavaCore.newSourceEntry(tempSrcFolder);
	javaProject.setRawClasspath(newClasspathEntry, new NullProgressMonitor());
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:13,代码来源:LaunchExpressionEditor.java


注:本文中的org.eclipse.jdt.core.IJavaProject.getRawClasspath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。