Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Project.getNature vs. Nature.setProject
Project.getNature vs. Nature.setProject [message #39420] Tue, 20 May 2003 05:55 Go to next message
Eclipse UserFriend
Originally posted by: simon.fortytwo.uni-oldenburg.de

Hi,

Is it correct that you may not call Project.getNature for a nature x from
that nature's method setProject ?

I'd like to do some initialization of nature parameters from setProject
which itself calls Project.getNature because it doesn't get passed the
nature as parameter.

Is there a better place to do this initialization that ensures it is
called before the workbench is available?

I tried to call it from the associated builder's startupOnInitialize
method. That works, but it is only called timely if automatic building is
enabled.

Regards,
Simon
Re: Project.getNature vs. Nature.setProject [message #40385 is a reply to message #39420] Tue, 20 May 2003 11:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.NOSPAM.us.ibm.com

I don't understand. When a nature is created, it is called with a
setProject. In that case "this" is the nature, there is no reason to
have the nature sent in. And no reason to call Project.getNature() to
get the nature that is being initialized.

Initialization of a nature should only be done in the setProject method
of the nature. setNature is called once per session, the first time the
nature is needed during that session.

The configure method of a nature is only called once ever for a project.
It is called when the nature is first added to the project. It allows
some configuration to be done, like adding a builder, or changing the
buildpath.

The deconfigure method is called when a nature is removed from a
project. It is for removing any configuration done in the configure method.

Rich Kulp
Re: Project.getNature vs. Nature.setProject [message #41639 is a reply to message #40385] Wed, 21 May 2003 08:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: simon.fortytwo.uni-oldenburg.de

On Tue, 20 May 2003 11:36:44 -0400, Richard L. Kulp wrote:

> I don't understand. When a nature is created, it is called with a
> setProject. In that case "this" is the nature, there is no reason to
> have the nature sent in. And no reason to call Project.getNature() to
> get the nature that is being initialized.

I can access the nature object from the INature.setProject() method
itself, of course. But I have no access to the nature object in methods
I call from setProject in other classes unless I pass the nature as
parameter or I call Project.getNature in those methods. OF course I could
change those methods such that the nature object is passed to them, but
I didn't know if the behavior I described is intentional.

> [... information about nature life cycle]

Regards,
Simon
Re: Project.getNature vs. Nature.setProject [message #41971 is a reply to message #41639] Wed, 21 May 2003 10:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.NOSPAM.us.ibm.com

Oh, in that case you need to change your methods to accept the nature
being passed into them. The nature is not officially registered until it
returns from the ORIGINAL getNature call. If you called getNature again,
it will currently create a new one. That's the current implementation.
However, these is nothing in the API contract that says one or the
other, so this is an undefined behavior that you cannot rely upon.

Rich
Re: Project.getNature vs. Nature.setProject [message #42092 is a reply to message #41639] Wed, 21 May 2003 10:46 Go to previous message
Eclipse UserFriend
Originally posted by: John_Arthorne.oti.com_

You shouldn't be using setProject as a hook for doing other
initialization work. It is intended just to give your nature instance
access to the project handle. How often do you need this initialization
work to happen? Once per session? What are you trying to accomplish
with it?
--


Simon Giesecke wrote:
>
> I can access the nature object from the INature.setProject() method
> itself, of course. But I have no access to the nature object in methods
> I call from setProject in other classes unless I pass the nature as
> parameter or I call Project.getNature in those methods. OF course I could
> change those methods such that the nature object is passed to them, but
> I didn't know if the behavior I described is intentional.
>
>
>>[... information about nature life cycle]
>
>
> Regards,
> Simon
Previous Topic:How to get current project from a plugin
Next Topic:[Howto] actually get Drag-and-Drop to work on a Viewer?
Goto Forum:
  


Current Time: Thu Jul 17 20:41:48 EDT 2025

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

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

Back to the top