Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Minimal editor based on bespoke IDocument(Steps needed to display editable text)
Minimal editor based on bespoke IDocument [message #1732395] Mon, 16 May 2016 19:40 Go to next message
Robert Onslow is currently offline Robert OnslowFriend
Messages: 27
Registered: March 2016
Junior Member
Hi

I have implemented a bespoke IDocument backed by a bespoke model. I extended org.eclipse.jface.text.Document and implemented get() and get(offset, length) of IDocument to return the model as text.

I create my bespoke IDocument within the getDocument(Object element) method of IDocumentProvider and then in TextEditor I use

setDocumentProvider(documentProvider)


When I run RCP, the text editor opens. Calls are made to get() and get(offset, length) of my IDocument, and debugging shows that the correct text is returned from the model.

But no content is shown in the TextEditor - just a blue background.

I suspect that I have missed a step but can't identify that at the moment.

Can anyone help with this?

Thanks

Robert

[Updated on: Mon, 16 May 2016 20:01]

Report message to a moderator

Re: Minimal editor based on bespoke IDocument [message #1732408 is a reply to message #1732395] Mon, 16 May 2016 23:58 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

The short answer is that you've missed a lot of steps. An IDocument is not just a wrapper object around a String. Methods that the editor relies on would all be returning the wrong results, compared to what should be returned for your string, because your string isn't actually being stored in the document.

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Minimal editor based on bespoke IDocument [message #1732566 is a reply to message #1732408] Wed, 18 May 2016 09:34 Go to previous messageGo to next message
Robert Onslow is currently offline Robert OnslowFriend
Messages: 27
Registered: March 2016
Junior Member
Thanks Nitin

It looks as though I should be implementing ITextStore over my model, rather than implementing IDocument.

So I implemented ITextStore for my model, and overrode Document.getTextStore() to return that implementation.

Still blank

Are there any docs which show how TextEditor calls out to IDocument, which shows what further helpers in Document I need to override?




Thanks

Robert

[Updated on: Wed, 18 May 2016 10:23]

Report message to a moderator

Re: Minimal editor based on bespoke IDocument [message #1732736 is a reply to message #1732566] Thu, 19 May 2016 18:45 Go to previous message
Robert Onslow is currently offline Robert OnslowFriend
Messages: 27
Registered: March 2016
Junior Member
Solved

Do not attempt to implement IDocumentProvider from scratch!

Solution was to extend AbstractDocumentProvider instead.

In AbstractDocumentProvider.createDocument(), I return a MyModelDocument which extends AbstractDocument

The constructor of MyModelDocument sets a ITextStore which is backed by my bespoke model. It also sets a ILineTracker which is backed by the bespoke model.

Finally I have set a IDocumentPartitioner in preparation for future work.

Thanks

Robert
Previous Topic:Eclipse 3.x Radio Menue
Next Topic:Cannot get the active selection from CompoundContributionItem
Goto Forum:
  


Current Time: Fri Apr 19 08:19:40 GMT 2024

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

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

Back to the top