Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » MultiPageEditor - delete file doesn't close editor
MultiPageEditor - delete file doesn't close editor [message #335942] Sun, 10 May 2009 23:42 Go to next message
Matt Gray is currently offline Matt GrayFriend
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 Go to previous messageGo to next message
Ben Vitale is currently offline Ben VitaleFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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.
>>
>>
>
>
Re: MultiPageEditor - delete file doesn't close editor [message #335974 is a reply to message #335958] Tue, 12 May 2009 05:41 Go to previous message
Matt Gray is currently offline Matt GrayFriend
Messages: 13
Registered: July 2009
Junior Member
Thanks for the replies (and example code). I guess I'm surprised that an
EditorPart doesn't implement this for you, but now that I know that
nothing is 'broken', it's just not implemented, I'll look at writing my
own.

I was wary of writing my own before as I assumed that Eclipse would also
be trying to close the window, and didn't want to step on its toes. :-)
Previous Topic:JUnit Test Case class Generator
Next Topic:ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter
Goto Forum:
  


Current Time: Sun Sep 01 02:10:18 GMT 2024

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

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

Back to the top