Sample JDT code - [message #242782] |
Thu, 12 April 2007 11:15  |
Eclipse User |
|
|
|
Hi All,
I want to be able to programmatically generate equals and hash code methods
for all classes in our domain object model preferably without having to
create a plug in.
Can someone show me an example of getting the workspace root ? The
following snippet fails with "workspace is closed" exception.
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject("axTest");
IJavaProject javaProject = JavaCore.create(project);
IFolder folder = project.getFolder("src");
//folder.create(true, true, null);
IPackageFragmentRoot srcFolder = javaProject
..getPackageFragmentRoot(folder);
//Assert.assertTrue(srcFolder.exists()); // resource exists and is on
// build
IPackageFragment fragment = srcFolder.createPackageFragment("x.y",
true, null);
String str = "package x.y;" + "\n" + "public class E {" + "\n"
+ "String first;" + "\n" + "}";
ICompilationUnit cu = fragment.createCompilationUnit("E.java", str,
false, null);
IType type = cu.getType("E");
type.createField("String name;", null, true, null);
|
|
|
Re: Sample JDT code - [message #242828 is a reply to message #242782] |
Thu, 12 April 2007 20:49  |
Eclipse User |
|
|
|
Jess Singh a écrit :
> I want to be able to programmatically generate equals and hash code methods
> for all classes in our domain object model preferably without having to
> create a plug in.
> Can someone show me an example of getting the workspace root ? The
> following snippet fails with "workspace is closed" exception.
Are you running in a headless Eclipse?
--
Olivier
|
|
|
Powered by
FUDForum. Page generated in 0.04169 seconds