Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » dispose() for extended Document?
dispose() for extended Document? [message #333654] Fri, 19 December 2008 19:38 Go to next message
Eclipse UserFriend
Originally posted by: zzq.hvc.rr.com

As a test case, I have a simple modification to the sample XML text
editor created by: New-> Project-> Plugin-in project-> Project with an
editor.

I defined a new class which extends the Document class. I overrode
createEmptyDocument() in XMLDocumentProvider to return a new extended
document instead of a new Document. The extended document is then
processed and returned to the editor by createDocument(...) in the provider.

I can successfully add methods and data to the extended Document, and it
seems to work as I had expected.

The problems is that I want to add some processing (removing a listener)
when the document is disposed (i.e. when the editor instance is closed).

I discovered that there is no dispose() method for a Document and thus
dispose() in my extended document is never called. I could not find an
equivalent of dispose() in the Document hierarchy.

Is this a bug? (or just a feature :-)? Is there any way around it? Is
there some other Document method that is called when a document is disposed?

I realize that I can simply save a link to the document in the XMLEditor
editor instance and invoke the extended document dispose() from within
the editor dispose().

But it appears to me that a very large amount of effort has gone into
keeping an editor and its document(s) very separate. I assume this is
intentional, perhaps to allow an editor to be shared. Am I correct in
thinking that forcing a one to one relationship between a document and
its editor is a bad idea?

Is there a preferred way to do what I'm trying to do?

Thanks.

Bill Fenlason
Re: dispose() for extended Document? [message #333656 is a reply to message #333654] Sat, 20 December 2008 16:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: zzq.hvc.rr.com

I now see that an appropriate way is to override disposeElementInfo() in
my document provider and issue the dispose() for the extended document
there. Sorry for the noise, guess I should have dug more before
posting. Bill
Re: dispose() for extended Document? [message #333773 is a reply to message #333656] Mon, 05 January 2009 08:25 Go to previous message
Tom Hofmann is currently offline Tom HofmannFriend
Messages: 770
Registered: July 2009
Senior Member
Bill Fenlason wrote:
> I now see that an appropriate way is to override disposeElementInfo() in
> my document provider and issue the dispose() for the extended document
> there. Sorry for the noise, guess I should have dug more before
> posting. Bill

You should also look at the documentCreation extension point of the file
buffers plug-in. Note however that it is considered bad practice to
provide a different document implementation than the default, as the
document is shared by all other editors for the same file.

If you need additional per-document information, consider adding it on
top of the default document (e.g. using document listeners and the
org.eclipse.core.filebuffers.documentSetup extensionn point).

-tom
Previous Topic:Moving from VerticalRuler to CompositeRuler, annotations lost
Next Topic:BracketInserter, "mirrored" text in brackets
Goto Forum:
  


Current Time: Thu Dec 26 21:24:16 GMT 2024

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

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

Back to the top