當前位置: 首頁>>代碼示例>>Java>>正文


Java IJavaProject.getPackageFragmentRoot方法代碼示例

本文整理匯總了Java中org.eclipse.jdt.core.IJavaProject.getPackageFragmentRoot方法的典型用法代碼示例。如果您正苦於以下問題:Java IJavaProject.getPackageFragmentRoot方法的具體用法?Java IJavaProject.getPackageFragmentRoot怎麽用?Java IJavaProject.getPackageFragmentRoot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jdt.core.IJavaProject的用法示例。


在下文中一共展示了IJavaProject.getPackageFragmentRoot方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addFolderToClassPath

import org.eclipse.jdt.core.IJavaProject; //導入方法依賴的package包/類
public static IPackageFragmentRoot addFolderToClassPath(IJavaProject jproject, String containerName)
		throws CoreException {
	IProject project = jproject.getProject();

	IFolder folder = project.getFolder(containerName);
	if (!folder.exists()) {
		createFolder(folder, false, true, new NullProgressMonitor());
	}

	IClasspathEntry cpe = JavaCore.newLibraryEntry(folder.getFullPath(), null, null);
	addToClasspath(jproject, cpe);
	return jproject.getPackageFragmentRoot(folder);
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:14,代碼來源:ProjectHelper.java

示例2: createDummyClass

import org.eclipse.jdt.core.IJavaProject; //導入方法依賴的package包/類
public static IFile createDummyClass(IJavaProject project) throws CoreException, IOException {
	String clazz = "import org.graphwalker.core.machine.ExecutionContext ; public class Dummy extends org.gw4e.core.machine.ExecutionContext {}";
	IFolder folder = project.getProject().getFolder("src/test/java");
	IPackageFragmentRoot srcFolder = project.getPackageFragmentRoot(folder);
	IPackageFragment pkg = srcFolder.getPackageFragment("");
	ICompilationUnit cu = pkg.createCompilationUnit("Dummy.java", clazz, false, new NullProgressMonitor());
	cu.save(new NullProgressMonitor (), true);

	return (IFile) cu.getResource();
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:11,代碼來源:ProjectHelper.java

示例3: createDummyClassWitherror

import org.eclipse.jdt.core.IJavaProject; //導入方法依賴的package包/類
public static IFile createDummyClassWitherror(IJavaProject project) throws CoreException, IOException {
	String clazz = "import org.graphwalker.core.machine.ExecutionContext ; public class Dummy1 extends org.gw4e.core.machine.ExecutionContext {}";
	IFolder folder = project.getProject().getFolder("src/test/java");
	IPackageFragmentRoot srcFolder = project.getPackageFragmentRoot(folder);
	IPackageFragment pkg = srcFolder.getPackageFragment("");
	ICompilationUnit cu = pkg.createCompilationUnit("Dummy.java", clazz, false, new NullProgressMonitor());
	cu.save(new NullProgressMonitor (), true);
	return (IFile) cu.getResource();
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:10,代碼來源:ProjectHelper.java

示例4: setSourceFolderInClassPath

import org.eclipse.jdt.core.IJavaProject; //導入方法依賴的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

示例5: createProject

import org.eclipse.jdt.core.IJavaProject; //導入方法依賴的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


注:本文中的org.eclipse.jdt.core.IJavaProject.getPackageFragmentRoot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。