Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to access project properties like the source and output folders on build path
How to access project properties like the source and output folders on build path [message #81812] Tue, 24 June 2003 18:41 Go to next message
Eclipse User
Originally posted by: dtomsu.hotmail.com

Hi,

how can I access the properties of a project?

I need to know the exact path for a resource I'm about to create from where
I only know the package it should be in.

Thanks in advance,

Daniel
Re: How to access project properties like the source and output folders on build path [message #82120 is a reply to message #81812] Wed, 25 June 2003 14:28 Go to previous messageGo to next message
Eclipse User
Originally posted by: richkulp.NOSPAM.us.ibm.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 #82376 is a reply to message #82120] Wed, 25 June 2003 15:48 Go to previous messageGo to next message
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 Go to previous message
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
Previous Topic:i18n support for properties file
Next Topic:Possible Ant bug in M1?
Goto Forum:
  


Current Time: Fri Sep 19 15:57:52 GMT 2014

Powered by FUDForum. Page generated in 0.02594 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software