Author: scabanovich
Date: 2008-02-18 11:18:22 -0500 (Mon, 18 Feb 2008)
New Revision: 6386
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
Log:
JBIDE-1197
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2008-02-18
15:36:26 UTC (rev 6385)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2008-02-18
16:18:22 UTC (rev 6386)
@@ -475,9 +475,16 @@
try {
String s = null;
String path = es[i].getPath().toString();
- if(path.startsWith("/" + project.getName() + "/")) {
+ if(path.startsWith("/") && path.indexOf("/", 1) > 1)
{
+ IResource findMember =
ResourcesPlugin.getWorkspace().getRoot().findMember(es[i].getPath());
+ if(findMember != null) {
+ s = findMember.getLocation().toString();
+ } else {
+ s = null;
+ }
+ } else if(path.startsWith("/" + project.getName() + "/")) {
IResource findMember = project.findMember(es[i].getPath().removeFirstSegments(1));
- if(findMember!=null) {
+ if(findMember != null) {
s = findMember.getLocation().toString();
} else {
s = null;
@@ -495,6 +502,40 @@
return l;
}
+ public static List<String> getJREClassPath(IProject project) throws CoreException
{
+ if(!project.hasNature(JavaCore.NATURE_ID)) return null;
+ ArrayList<String> l = new ArrayList<String>();
+ IJavaProject javaProject = JavaCore.create(project);
+ IClasspathEntry[] es0 = javaProject.getRawClasspath();
+ IClasspathEntry[] es = null;
+ for (int i = 0; i < es0.length && es == null; i++) {
+ if(es0[i].getEntryKind() == IClasspathEntry.CPE_CONTAINER &&
+ es0[i].getPath().toString().equals("org.eclipse.jdt.launching.JRE_CONTAINER"))
{ //$NON-NLS-1$
+ IClasspathContainer container = JavaCore.getClasspathContainer(es0[i].getPath(),
javaProject);
+ if(container == null) continue;
+ es = container.getClasspathEntries();
+ }
+ }
+ if(es == null) return l;
+ for (int i = 0; i < es.length; i++) {
+ try {
+ String s = null;
+ String path = es[i].getPath().toString();
+ if(path.startsWith("/" + project.getName() + "/")) {
//$NON-NLS-1$ //$NON-NLS-2$
+ s =
project.findMember(es[i].getPath().removeFirstSegments(1)).getLocation().toString();
+ } else if(new java.io.File(path).isFile()) {
+ s = path;
+ }
+ if(s != null) {
+ l.add(new java.io.File(s).getCanonicalPath());
+ }
+ } catch (IOException e) {
+ //ignore - we do not care about malformed URLs in class path here.
+ }
+ }
+ return l;
+ }
+
public static IJavaElement findJavaElement(XModelObject object) {
int type = object.getFileType();
IResource resource = getResource(object);
Show replies by date