Connecting Editor to Nature (or IWorkspace)? [message #148468] |
Thu, 23 October 2003 11:03  |
Eclipse User |
|
|
|
Originally posted by: Lamont_Gilbert.Rigidsoftware.com
What is the best way to connect my Editor to the Project Nature? It seems
as if my only connection is through the IEditorInput? And only when that
IEditorInput contains an IResource? (The IResource gets me the IWorkspace
which then gets me eventually to the IProjectNature)
This being true, is it OK to then store a reference to my Project nature
that I retrieve through the IResource, in my Editor for later use?
I noticed that the logic example hinted that the workspace for an editor
is never changed!? If this is true, is their another way to get at the
workspace? Perhaps the Editor already knows its workspace?
thanks for the tips!
CL
|
|
|
Re: Connecting Editor to Nature (or IWorkspace)? [message #148661 is a reply to message #148468] |
Thu, 23 October 2003 14:09   |
Eclipse User |
|
|
|
Originally posted by: John_Arthorne.oti.com_
A nature instance is valid until the project is closed, deleted, or the
nature is removed from the project. So, you can maintain a reference to
a nature, and assume it is valid if none of the above events occur. As
for accessing the workspace, there is only ever one workspace, and you
can access it using ResourcesPlugin.getWorkspace(). Not much need to
cache it yourself.
--
CL [dnoyeB] Gilbert wrote:
> What is the best way to connect my Editor to the Project Nature? It seems
> as if my only connection is through the IEditorInput? And only when that
> IEditorInput contains an IResource? (The IResource gets me the IWorkspace
> which then gets me eventually to the IProjectNature)
>
> This being true, is it OK to then store a reference to my Project nature
> that I retrieve through the IResource, in my Editor for later use?
>
> I noticed that the logic example hinted that the workspace for an editor
> is never changed!? If this is true, is their another way to get at the
> workspace? Perhaps the Editor already knows its workspace?
>
>
> thanks for the tips!
>
>
> CL
|
|
|
Re: Connecting Editor to Nature (or IWorkspace)? [message #148848 is a reply to message #148661] |
Thu, 23 October 2003 18:40   |
Eclipse User |
|
|
|
Originally posted by: Lamont_Gilbert.Rigidsoftware.com
On Thu, 23 Oct 2003 14:09:00 -0400, John Arthorne wrote:
> A nature instance is valid until the project is closed, deleted, or the
> nature is removed from the project. So, you can maintain a reference to a
> nature, and assume it is valid if none of the above events occur. As for
> accessing the workspace, there is only ever one workspace, and you can
> access it using ResourcesPlugin.getWorkspace(). Not much need to cache it
> yourself.
> --
>
> CL [dnoyeB] Gilbert wrote:
>> What is the best way to connect my Editor to the Project Nature? It
>> seems as if my only connection is through the IEditorInput? And only
>> when that IEditorInput contains an IResource? (The IResource gets me the
>> IWorkspace which then gets me eventually to the IProjectNature)
>>
>> This being true, is it OK to then store a reference to my Project nature
>> that I retrieve through the IResource, in my Editor for later use?
>>
>> I noticed that the logic example hinted that the workspace for an editor
>> is never changed!? If this is true, is their another way to get at the
>> workspace? Perhaps the Editor already knows its workspace?
>>
>>
>> thanks for the tips!
>>
>>
>> CL
Great! I assume that the views close when the project is closed? or do I
have to listen and close them myself?
CL
|
|
|
Re: Connecting Editor to Nature (or IWorkspace)? [message #148856 is a reply to message #148661] |
Thu, 23 October 2003 19:40  |
Eclipse User |
|
|
|
Originally posted by: Lamont_Gilbert.Rigidsoftware.com
On Thu, 23 Oct 2003 14:09:00 -0400, John Arthorne wrote:
> A nature instance is valid until the project is closed, deleted, or the
> nature is removed from the project. So, you can maintain a reference to
> a nature, and assume it is valid if none of the above events occur. As
> for accessing the workspace, there is only ever one workspace, and you
> can access it using ResourcesPlugin.getWorkspace(). Not much need to
> cache it yourself.
> --
>
>
Unfortunately since I am trying to get at my nature, I will need a
resource from the actual project. Using the static method the only
resource I can get is the workspaceroot, and that will always return null
for the project.
So I have to use the IEditorInput and grab the file from it, and using
that file I can get at the project.
So Im good now!
Thanks!
CL
|
|
|
Powered by
FUDForum. Page generated in 0.03336 seconds