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


Java JavaCore.newSourceEntry方法代码示例

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


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

示例1: getSourceClasspathEntries

import org.eclipse.jdt.core.JavaCore; //导入方法依赖的package包/类
public static IClasspathEntry[] getSourceClasspathEntries(String project) {
	IPath path1 = new Path(project).append(Constant.SOURCE_MAIN_JAVA).makeAbsolute();
	IPath path2 = new Path(project).append(Constant.SOURCE_MAIN_RESOURCES).makeAbsolute();
	IPath path3 = new Path(project).append(Constant.SOURCE_TEST_JAVA).makeAbsolute();
	IPath path4 = new Path(project).append(Constant.SOURCE_TEST_RESOURCES).makeAbsolute();
	IPath path5 = new Path(project).append(Constant.SOURCE_GENERATED_INTERFACE).makeAbsolute();
	IPath path6 = new Path(project).append(Constant.TEST_GENERATED_INTERFACE).makeAbsolute();
	return new IClasspathEntry[] { JavaCore.newSourceEntry(path1), JavaCore.newSourceEntry(path2),
			JavaCore.newSourceEntry(path3), JavaCore.newSourceEntry(path4),
			JavaCore.newSourceEntry(path5) , JavaCore.newSourceEntry(path6)};
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:12,代码来源:GW4ENature.java

示例2: ensureExcludedPath

import org.eclipse.jdt.core.JavaCore; //导入方法依赖的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

示例3: ensureFolderInClasspath

import org.eclipse.jdt.core.JavaCore; //导入方法依赖的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

示例4: addClassPathEntry

import org.eclipse.jdt.core.JavaCore; //导入方法依赖的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

示例5: setSourceFolderInClassPath

import org.eclipse.jdt.core.JavaCore; //导入方法依赖的package包/类
/**
 * Sets the <b>src</b> folder as the source folder in project
 * @param project
 * @param javaProject
 * @return IClasspathEntry[]
 * @throws JavaModelException
 */
private IClasspathEntry[] setSourceFolderInClassPath(IProject project,	IJavaProject javaProject) throws JavaModelException {
	IFolder sourceFolder = project.getFolder(Constants.ProjectSupport_SRC); //$NON-NLS-1$
	IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(sourceFolder);
	IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
	IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
	System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
	newEntries[oldEntries.length] = JavaCore.newSourceEntry(root.getPath());
	return newEntries;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:17,代码来源:ProjectStructureCreator.java

示例6: createProject

import org.eclipse.jdt.core.JavaCore; //导入方法依赖的package包/类
/**
 * This method creates a new java project based on the user inputs, captured in WizardInput object.
 * The new project is created in the current workspace.
 * @param wizardInput
 * @return IJavaProject
 * @throws CoreException
 * @throws IOException
 **/
public IJavaProject createProject(WizardInput wizardInput) throws CoreException, IOException
{
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = root.getProject(wizardInput.getProjectName());
	project.create(null);
	project.open(null);		
	IProjectDescription description = project.getDescription();
	description.setNatureIds(new String[] { JavaCore.NATURE_ID });
	project.setDescription(description, null);
	IJavaProject javaProject = JavaCore.create(project); 
	IFolder binFolder = project.getFolder("bin");
	binFolder.create(false, true, null);
	javaProject.setOutputLocation(binFolder.getFullPath(), null);
	List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
	IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
	LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
	for (LibraryLocation element : locations) {
	 entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null));
	}
	InputStream is = new BufferedInputStream(new FileInputStream(wizardInput.getSootPath().toOSString()));
    IFile jarFile = project.getFile("soot-trunk.jar");
    jarFile.create(is, false, null);
    IPath path = jarFile.getFullPath();
    entries.add(JavaCore.newLibraryEntry(path, null, null));
	javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);		
	IFolder sourceFolder = project.getFolder("src");
	sourceFolder.create(false, true, null);
	IPackageFragmentRoot root1 = javaProject.getPackageFragmentRoot(sourceFolder);
	IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
	IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
	System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
	newEntries[oldEntries.length] = JavaCore.newSourceEntry(root1.getPath());
	javaProject.setRawClasspath(newEntries, null);
	String filepath = sourceFolder.getLocation().toOSString();
	File file = new File(filepath);
	wizardInput.setFile(file);
	try {
		CodeGenerator.generateSource(wizardInput);
	} catch (JClassAlreadyExistsException e) {
		e.printStackTrace();
	}
	sourceFolder.refreshLocal(1, null);
	javaProject.open(null);
	return javaProject;
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:54,代码来源:ProjectGenerator.java

示例7: addSourceEntry

import org.eclipse.jdt.core.JavaCore; //导入方法依赖的package包/类
/**
 * Add a new Source entry (as String) to the existing java project
 * The project must have the java nature
 * If the entry is already there, the method will do nothing.
 */
public static void addSourceEntry(IProject project, String newEntryFolder, IProgressMonitor monitor) throws CoreException{
	IJavaProject javaProject = (IJavaProject) project.getNature(JavaCore.NATURE_ID);
	IClasspathEntry entry = JavaCore.newSourceEntry(javaProject.getPackageFragmentRoot(project.getFolder(newEntryFolder)).getPath());
	addEntry(project, entry, monitor);
}
 
开发者ID:eclipse,项目名称:gemoc-studio,代码行数:11,代码来源:ClasspathHelper.java


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