當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。