MultiPageEditor - delete file doesn't close editor [message #335942] |
Sun, 10 May 2009 23:42 |
Matt Gray Messages: 13 Registered: July 2009 |
Junior Member |
|
|
I've implemented a MultiPageEditor, based on the example template 'Plug-in
with a multi-page editor'.
One problem I'm having is that if a file that is opened in the multi-page
editor is deleted in the file navigator, the editor for the file stays
open. The usual action for an editor is that if the file is deleted, it
will close that editor.
Similar problem happens if the file is renamed. The editor keeps the old
name, and then gets confused if it tries to look for the old filename on
disk.
At first I thought it must be something wrong with my code, but I've gone
back to the example template code that comes with Eclipse 3.3.2, and it
also has the same problem.
I've run my code in the debugger, and stepped through what is going on -
there are all sorts of listeners that are being called, and the code goes
into handleFileDeleted() in ResourceFileBuffer.class, which then calls
fireUnderlyingFileDeleted() in TextFileBufferManager.class, which seems to
want to send things to IFileBufferListeners. At this point I can't seem
to work out where the code goes... but it is somewhere in there that
something fails for a multipage editor, but works for a single page
editor.
Anyone able to help me with this?
Matt.
|
|
|
Re: MultiPageEditor - delete file doesn't close editor [message #335948 is a reply to message #335942] |
Mon, 11 May 2009 13:26 |
Ben Vitale Messages: 247 Registered: July 2009 |
Senior Member |
|
|
I'm pretty sure this behavior is standard only for TextEditor
subclasses. Otherwise you'll have to roll your own. We did something
similar for our multi-page editors. Basically you listen for
ResourceChangeEvents against your editor input and react accordingly.
Check out AbstractTextEditor#handleEditorInputChanged().
HTH
Ben
Matt Gray wrote:
> I've implemented a MultiPageEditor, based on the example template
> 'Plug-in with a multi-page editor'.
>
> One problem I'm having is that if a file that is opened in the
> multi-page editor is deleted in the file navigator, the editor for the
> file stays open. The usual action for an editor is that if the file is
> deleted, it will close that editor.
>
> Similar problem happens if the file is renamed. The editor keeps the
> old name, and then gets confused if it tries to look for the old
> filename on disk.
>
> At first I thought it must be something wrong with my code, but I've
> gone back to the example template code that comes with Eclipse 3.3.2,
> and it also has the same problem.
> I've run my code in the debugger, and stepped through what is going on -
> there are all sorts of listeners that are being called, and the code
> goes into handleFileDeleted() in ResourceFileBuffer.class, which
> then calls fireUnderlyingFileDeleted() in TextFileBufferManager.class,
> which seems to want to send things to IFileBufferListeners. At this
> point I can't seem to work out where the code goes... but it is
> somewhere in there that something fails for a multipage editor, but
> works for a single page editor.
> Anyone able to help me with this?
>
> Matt.
>
>
|
|
|
Re: MultiPageEditor - delete file doesn't close editor [message #335958 is a reply to message #335948] |
Mon, 11 May 2009 15:04 |
Eclipse User |
|
|
|
Originally posted by: eclipse-news.rizzoweb.com
Ben Vitale wrote:
> I'm pretty sure this behavior is standard only for TextEditor
> subclasses. Otherwise you'll have to roll your own. We did something
> similar for our multi-page editors. Basically you listen for
> ResourceChangeEvents against your editor input and react accordingly.
>
> Check out AbstractTextEditor#handleEditorInputChanged().
Ben is right, you have to implement this yourself.
Here is one example:
http://www.skywayperspectives.org/fisheye/browse/CVS_OpenSou rce/skyway/common/plugins/org.skyway.core.ui/src/org/skyway/ core/ui/forms/EditorResourceChangeListener.java?r=1.1
(note, that is GPL code). An instance of that class is created from the
CoreObjectEditor in its init() method and disposed in the editor's
dispose() method.
Hope this helps,
Eric
> Matt Gray wrote:
>> I've implemented a MultiPageEditor, based on the example template
>> 'Plug-in with a multi-page editor'.
>>
>> One problem I'm having is that if a file that is opened in the
>> multi-page editor is deleted in the file navigator, the editor for the
>> file stays open. The usual action for an editor is that if the file
>> is deleted, it will close that editor.
>>
>> Similar problem happens if the file is renamed. The editor keeps the
>> old name, and then gets confused if it tries to look for the old
>> filename on disk.
>>
>> At first I thought it must be something wrong with my code, but I've
>> gone back to the example template code that comes with Eclipse 3.3.2,
>> and it also has the same problem.
>> I've run my code in the debugger, and stepped through what is going on
>> - there are all sorts of listeners that are being called, and the code
>> goes into handleFileDeleted() in ResourceFileBuffer.class, which
>> then calls fireUnderlyingFileDeleted() in TextFileBufferManager.class,
>> which seems to want to send things to IFileBufferListeners. At this
>> point I can't seem to work out where the code goes... but it is
>> somewhere in there that something fails for a multipage editor, but
>> works for a single page editor. Anyone able to help me with this?
>>
>> Matt.
>>
>>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.02838 seconds