diff options
author | kmoore | 2010-03-31 20:39:01 +0000 |
---|---|---|
committer | kmoore | 2010-03-31 20:39:01 +0000 |
commit | 5d203572605cb69d1e8a6b192a9915d3f16c35ee (patch) | |
tree | 2cd43984797d3225c7cfc23395e508ce4d3ee67d /jpa | |
parent | ffa21d362700471abe4fdab6ea7870cfb2eb06b7 (diff) | |
download | webtools.dali-5d203572605cb69d1e8a6b192a9915d3f16c35ee.tar.gz webtools.dali-5d203572605cb69d1e8a6b192a9915d3f16c35ee.tar.xz webtools.dali-5d203572605cb69d1e8a6b192a9915d3f16c35ee.zip |
fixed entity gen which i broke with my packageFragmentRoot changes
Diffstat (limited to 'jpa')
-rw-r--r-- | jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java index 1aef2afede..90489abfa0 100644 --- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java +++ b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java @@ -38,6 +38,7 @@ import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; +import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jpt.core.JpaProject; import org.eclipse.jpt.core.context.persistence.ClassRef; import org.eclipse.jpt.core.context.persistence.Persistence; @@ -295,7 +296,7 @@ public class PackageGenerator { } public IFolder getJavaPackageFolder(ORMGenTable table, IProgressMonitor monitor) throws CoreException { - IPackageFragmentRoot root = getJavaSourceLocation(getJavaProject(), table.getSourceFolder()); + IPackageFragmentRoot root = getDefaultJavaSourceLocation(getJavaProject(), table.getSourceFolder()); String packageName = table.getPackage(); if( packageName==null ) packageName =""; IPackageFragment packageFragment = root.getPackageFragment(packageName); @@ -309,7 +310,26 @@ public class PackageGenerator { return this.jpaProject.getJavaProject(); } - private IPackageFragmentRoot getJavaSourceLocation(IJavaProject javaProject, String sourceFolder) { - return javaProject.getPackageFragmentRoot(javaProject.getProject().getFolder(sourceFolder)); + private IPackageFragmentRoot getDefaultJavaSourceLocation(IJavaProject jproject, String sourceFolder){ + IPackageFragmentRoot defaultSrcPath = null; + if (jproject != null && jproject.exists()) { + try { + IPackageFragmentRoot[] roots = jproject.getPackageFragmentRoots(); + for (int i = 0; i < roots.length; i++) { + if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE ){ + if (defaultSrcPath == null) { + defaultSrcPath = roots[i]; + } + String path = roots[i].getPath().toString(); + if (path.equals('/' + sourceFolder)) { + return roots[i] ; + } + } + } + } catch (JavaModelException e) { + JptGenPlugin.logException(e); + } + } + return defaultSrcPath; } } |