| 
| MultiPageEditor - delete file doesn't close editor [message #335942] | Sun, 10 May 2009 19:42  |  | 
| Eclipse User  |  |  |  |  | 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 09:26   |  | 
| Eclipse User  |  |  |  |  | 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 11: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.
 >>
 >>
 >
 >
 |  |  |  | 
| 
| Re: MultiPageEditor - delete file doesn't close editor [message #335974 is a reply to message #335958] | Tue, 12 May 2009 01:41  |  | 
| Eclipse User  |  |  |  |  | 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.  :-)
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.08022 seconds