Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » How does eclipse know
How does eclipse know [message #281150] Tue, 15 February 2005 19:06 Go to next message
Eclipse UserFriend
How does eclipse determine that a file is already open in an editor? Is
there a way that I can "plug-in" to that process to have some of my code
executed at that point?

Thanks,
Keith
Re: How does eclipse know [message #281153 is a reply to message #281150] Tue, 15 February 2005 19:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Keith McQueen wrote:
> How does eclipse determine that a file is already open in an editor? Is
> there a way that I can "plug-in" to that process to have some of my code
> executed at that point?
>
> Thanks,
> Keith
>

I compares the IEditorInputs, and if they match it concludes the file is
already open. create your own ieditorInput and put in a equals method,
and set a breakpoint in it. Then you can follow the process.


CL
Re: How does eclipse know [message #281155 is a reply to message #281153] Tue, 15 February 2005 19:56 Go to previous messageGo to next message
Eclipse UserFriend
CL [dnoyeb] Gilbert wrote:
> Keith McQueen wrote:
>
>> How does eclipse determine that a file is already open in an editor?
>> Is there a way that I can "plug-in" to that process to have some of my
>> code executed at that point?
>>
>> Thanks,
>> Keith
>>
>
> I compares the IEditorInputs, and if they match it concludes the file is
> already open. create your own ieditorInput and put in a equals method,
> and set a breakpoint in it. Then you can follow the process.
>
>
> CL

That sort of sounds okay, but when I double-click a file in the
navigator view, it launches the OpenFileAction#openFile() method which
in turn invokes the IDE#openEditor() method. (I've done some more
digging since my original post). The problem is that the
IDE#openEditor() method just constructs a new FileEditorInput object. I
have looked at the extension points in the help, but I didn't see
anything that would allow me to specify which IEditorInput to use for a
certain file name/extension (there was something for the documentSetup,
documentCreation, and documentProvider, but nothing for the editor
input). Anyway, I need a way to "intercept" the detection of whether a
file is already open or not.

I appreciate you help,
Keith
Re: How does eclipse know [message #281156 is a reply to message #281155] Tue, 15 February 2005 21:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pascal.ibm.canada

Take a look at the extension point org.eclipse.ui.editors. It allows to
register a new editor with a given file extension.

PaScaL


Keith McQueen wrote:
> CL [dnoyeb] Gilbert wrote:
>
>> Keith McQueen wrote:
>>
>>> How does eclipse determine that a file is already open in an editor?
>>> Is there a way that I can "plug-in" to that process to have some of
>>> my code executed at that point?
>>>
>>> Thanks,
>>> Keith
>>>
>>
>> I compares the IEditorInputs, and if they match it concludes the file
>> is already open. create your own ieditorInput and put in a equals
>> method, and set a breakpoint in it. Then you can follow the process.
>>
>>
>> CL
>
>
> That sort of sounds okay, but when I double-click a file in the
> navigator view, it launches the OpenFileAction#openFile() method which
> in turn invokes the IDE#openEditor() method. (I've done some more
> digging since my original post). The problem is that the
> IDE#openEditor() method just constructs a new FileEditorInput object. I
> have looked at the extension points in the help, but I didn't see
> anything that would allow me to specify which IEditorInput to use for a
> certain file name/extension (there was something for the documentSetup,
> documentCreation, and documentProvider, but nothing for the editor
> input). Anyway, I need a way to "intercept" the detection of whether a
> file is already open or not.
>
> I appreciate you help,
> Keith
Re: How does eclipse know [message #281157 is a reply to message #281156] Tue, 15 February 2005 22:39 Go to previous messageGo to next message
Eclipse UserFriend
Pascal Rapicault wrote:
> Take a look at the extension point org.eclipse.ui.editors. It allows to
> register a new editor with a given file extension.
>
> PaScaL
>
>
> Keith McQueen wrote:
>
>> CL [dnoyeb] Gilbert wrote:
>>
>>> Keith McQueen wrote:
>>>
>>>> How does eclipse determine that a file is already open in an
>>>> editor? Is there a way that I can "plug-in" to that process to have
>>>> some of my code executed at that point?
>>>>
>>>> Thanks,
>>>> Keith
>>>>
>>>
>>> I compares the IEditorInputs, and if they match it concludes the file
>>> is already open. create your own ieditorInput and put in a equals
>>> method, and set a breakpoint in it. Then you can follow the process.
>>>
>>>
>>> CL
>>
>>
>>
>> That sort of sounds okay, but when I double-click a file in the
>> navigator view, it launches the OpenFileAction#openFile() method which
>> in turn invokes the IDE#openEditor() method. (I've done some more
>> digging since my original post). The problem is that the
>> IDE#openEditor() method just constructs a new FileEditorInput object.
>> I have looked at the extension points in the help, but I didn't see
>> anything that would allow me to specify which IEditorInput to use for
>> a certain file name/extension (there was something for the
>> documentSetup, documentCreation, and documentProvider, but nothing for
>> the editor input). Anyway, I need a way to "intercept" the detection
>> of whether a file is already open or not.
>>
>> I appreciate you help,
>> Keith

I already have my own editor. What I don't have is way to control how
eclipse determines if a file is already open for editing. The default
functionality is fine for general purpose stuff, but I would like to
find a way to fine tune it if I can. My editor can be opened for any
one of 3 file extensions. 3 files related together are edited at once
in my editor. Eclipse allows each of the three files to be opened at
the same time in separate editors. I would like to be able to say that
if one of the files is open, then the user cannot open either of the
other two, until he/she closes the one that is currently open. I need
to be able to get my own logic into that file opening code. Anybody
have any clues?

Thanks,
Keith

PS I don't really mean to sound so snotty :-)
Re: How does eclipse know [message #281170 is a reply to message #281157] Wed, 16 February 2005 07:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Chris_Laffra.ca.ibm.com

In http://www.eclipsefaq.org/chris/faq/html/faq167.html there is a
description how editors are managed.
Perhaps that is a starting point for you?


--
Chris Laffra, http://eclipsefaq.org


"Keith McQueen" <kmcqueen@tsccos.com> wrote in message
news:cuuflc$fgf$1@www.eclipse.org...
> Pascal Rapicault wrote:
> > Take a look at the extension point org.eclipse.ui.editors. It allows to
> > register a new editor with a given file extension.
> >
> > PaScaL
> >
> >
> > Keith McQueen wrote:
> >
> >> CL [dnoyeb] Gilbert wrote:
> >>
> >>> Keith McQueen wrote:
> >>>
> >>>> How does eclipse determine that a file is already open in an
> >>>> editor? Is there a way that I can "plug-in" to that process to have
> >>>> some of my code executed at that point?
> >>>>
> >>>> Thanks,
> >>>> Keith
> >>>>
> >>>
> >>> I compares the IEditorInputs, and if they match it concludes the file
> >>> is already open. create your own ieditorInput and put in a equals
> >>> method, and set a breakpoint in it. Then you can follow the process.
> >>>
> >>>
> >>> CL
> >>
> >>
> >>
> >> That sort of sounds okay, but when I double-click a file in the
> >> navigator view, it launches the OpenFileAction#openFile() method which
> >> in turn invokes the IDE#openEditor() method. (I've done some more
> >> digging since my original post). The problem is that the
> >> IDE#openEditor() method just constructs a new FileEditorInput object.
> >> I have looked at the extension points in the help, but I didn't see
> >> anything that would allow me to specify which IEditorInput to use for
> >> a certain file name/extension (there was something for the
> >> documentSetup, documentCreation, and documentProvider, but nothing for
> >> the editor input). Anyway, I need a way to "intercept" the detection
> >> of whether a file is already open or not.
> >>
> >> I appreciate you help,
> >> Keith
>
> I already have my own editor. What I don't have is way to control how
> eclipse determines if a file is already open for editing. The default
> functionality is fine for general purpose stuff, but I would like to
> find a way to fine tune it if I can. My editor can be opened for any
> one of 3 file extensions. 3 files related together are edited at once
> in my editor. Eclipse allows each of the three files to be opened at
> the same time in separate editors. I would like to be able to say that
> if one of the files is open, then the user cannot open either of the
> other two, until he/she closes the one that is currently open. I need
> to be able to get my own logic into that file opening code. Anybody
> have any clues?
>
> Thanks,
> Keith
>
> PS I don't really mean to sound so snotty :-)
Re: How does eclipse know [message #281173 is a reply to message #281157] Wed, 16 February 2005 09:16 Go to previous messageGo to next message
Eclipse UserFriend
>>>>> How does eclipse determine that a file is already open in an editor?
>>>>> Is there a way that I can "plug-in" to that process to have some of my
>>>>> code executed at that point?
>>>>>
>>>> I compares the IEditorInputs, and if they match it concludes the file
>>>> is already open. create your own ieditorInput and put in a equals
>>>> method, and set a breakpoint in it. Then you can follow the process.
>>>>
>>> That sort of sounds okay, but when I double-click a file in the
>>> navigator view, it launches the OpenFileAction#openFile() method which
>>> in turn invokes the IDE#openEditor() method. (I've done some more
>>> digging since my original post). The problem is that the
>>> IDE#openEditor() method just constructs a new FileEditorInput object. I
>>> have looked at the extension points in the help, but I didn't see
>>> anything that would allow me to specify which IEditorInput to use for a
>>> certain file name/extension (there was something for the documentSetup,
>>> documentCreation, and documentProvider, but nothing for the editor
>>> input). Anyway, I need a way to "intercept" the detection of whether a
>>> file is already open or not.
>> Take a look at the extension point org.eclipse.ui.editors. It allows to
>> register a new editor with a given file extension.
>>
>
> I already have my own editor. What I don't have is way to control how
> eclipse determines if a file is already open for editing. The default
> functionality is fine for general purpose stuff, but I would like to find
> a way to fine tune it if I can. My editor can be opened for any one of 3
> file extensions. 3 files related together are edited at once in my
> editor. Eclipse allows each of the three files to be opened at the same
> time in separate editors. I would like to be able to say that if one of
> the files is open, then the user cannot open either of the other two,
> until he/she closes the one that is currently open. I need to be able to
> get my own logic into that file opening code. Anybody have any clues?

Are those three files needed? Isn't it better to use only one file?
Why not providing an editor for the center file
(only one of those three is editable)?
For the other two provide editors opening a main editor instead?

You can dispose your editor at will. So maybe you can do it this way:
1. Be happy Eclipse creates an editor.
(hopefully you can prevent this, but I dont know yet)
2. Dispose your Editor once it is possible.
3. Before disposing your editor, select the apropriate editor and focus
it.

Since you are lightning fast, this shouldn't disturb anyone that much.

It's quite a hack and it shouldn't make it into your product code but
hey as long as you don't have another solution ... .

But there should be a better way for sure.


Cheers,

Martin (Kersten)
Re: How does eclipse know [message #281192 is a reply to message #281155] Wed, 16 February 2005 11:10 Go to previous message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

You are out of luck. There are numerous enhancement requests that cover
what you are looking for. I can point you to a few when I get home if
you like?

The basic strategy is to create your IEditorInput, and even if you had
seperate IEditorInputs, as long as they returned true as being equal to
any of the other two types of IEditorInputs, the 'workbench' would not
open that file a 2nd time.

The problem is that its not the workbehch, IIRC, the Navigator is part
of the IDE plugin. And the IDE plugin will create its own IEditorInput
for your file. So you wont have an opportunity to create your own
'equals' method.


Its a pretty high demand feature it seems to me. Maybe you can vote for
one of the enhancement requests that best fit your requirements. The
discussions look promising, but it does appear to e quite a complicated
architectural thing to get engineered.


CL


Keith McQueen wrote:
> CL [dnoyeb] Gilbert wrote:
>
>> Keith McQueen wrote:
>>
>>> How does eclipse determine that a file is already open in an editor?
>>> Is there a way that I can "plug-in" to that process to have some of
>>> my code executed at that point?
>>>
>>> Thanks,
>>> Keith
>>>
>>
>> I compares the IEditorInputs, and if they match it concludes the file
>> is already open. create your own ieditorInput and put in a equals
>> method, and set a breakpoint in it. Then you can follow the process.
>>
>>
>> CL
>
>
> That sort of sounds okay, but when I double-click a file in the
> navigator view, it launches the OpenFileAction#openFile() method which
> in turn invokes the IDE#openEditor() method. (I've done some more
> digging since my original post). The problem is that the
> IDE#openEditor() method just constructs a new FileEditorInput object. I
> have looked at the extension points in the help, but I didn't see
> anything that would allow me to specify which IEditorInput to use for a
> certain file name/extension (there was something for the documentSetup,
> documentCreation, and documentProvider, but nothing for the editor
> input). Anyway, I need a way to "intercept" the detection of whether a
> file is already open or not.
>
> I appreciate you help,
> Keith
Previous Topic:File path within project
Next Topic:How to add page numbers to printed code?
Goto Forum:
  


Current Time: Sun May 11 23:30:40 EDT 2025

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

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

Back to the top