|
|
Re: How to access project properties like the source and output folders on build path [message #82376 is a reply to message #82120] |
Wed, 25 June 2003 15:48 |
Eclipse User |
|
|
|
Originally posted by: dtomsu.hotmail.com
sometimes I got it as a IFolder and sometimes as a String. But it is
exchangeable.
Both versions here would be interesting.
Thanks Daniel
I have also seen, that the getParent on an IFile is giving me an unexpected
result. I would expect the folder where the file is in, but I get the
workspace root. So how do I get the IFolder from a file?
"Richard L. Kulp" <richkulp@NOSPAM.us.ibm.com> schrieb im Newsbeitrag
news:bdcbk7$5o2$2@rogue.oti.com...
> In what way do you know the package? As just a package name as a string
> (i.e. "com.something.somethingelse")? As an IPackageFragment? As an
> IFolder? Each one results in a different answer.
>
> Thanks,
> Rich
>
|
|
|
Re: How to access project properties like the source and output folders on build path [message #82651 is a reply to message #82376] |
Wed, 25 June 2003 22:28 |
Eclipse User |
|
|
|
Originally posted by: richkulp.NOSPAM.us.ibm.com
How are you creating the IFile? Because I don't see how you could get
workspace root. You should get a folder back that is at least your
project. You should never be getting workspace root.
As for if you have the IFolder that represents the final package
fragment, i.e. You want to put out a class com.something.MyClass.java
then your IFolder should be to
"/projectname/srcfolderifyouhaveone/com/something"
IFile jfile = folder.getFile("MyClass.java");
jfile.create(inputstream, true, pm);
Where:
- folder must exist (i.e. it must of been created already)
- inputstream returns the entire contents of the java class
you are creating.
- pm is a progress monitor, if you have one, null if you don't.
If all you have is the string to the package (i.e. "com.something") and
that package does exist:
IJavaProject jproject = JavaCore.create(IProject);
IPackageFragment pkg = (IPackageFragment) jproject.findElement(new
Path("com/something"));
if (pkg != null && pkg.getJavaProject() == jproject && !pkg.isReadOnly()
&& pkg.getKind() == IPackageFragmentRoot.K_SOURCE) {
// We find a package and it is in this project
// It could of returned one from a required project
// It is also changable (i.e. not within a jar)
// It is also in source folder and not in a class folder
IFolder pkgFolder = (IFolder) pkg.getResource();
... Then do the above now that you have an IFolder.
}
This should do it.
Rich
|
|
|
Powered by
FUDForum. Page generated in 0.02798 seconds