本文整理汇总了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);
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}