Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Problems conecting a custom document provider to CompilationUnitEditor.
Problems conecting a custom document provider to CompilationUnitEditor. [message #989903] Sun, 09 December 2012 18:59 Go to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
Hi everybody.
I have defined an EMF metamodel in which some elements have a String
field which will contain some Java code. Now I am trying to reuse
CompilationUnitEditor's functionality to be able to edit this field's
content. I know that CompilationUnitEditor and related classes are
internal, but I assume the risk of them changing in the future.

So, I have extended CompilationUnitEditor and
CompilationUnitDocumentProvider to provide the correct content to the
editor (I am adding the DP programmatically to my editor in its
constructor). I got this far. Regretfully, I am getting
AssertionFailedExceptions when trying to use the editor for my models.

I tried to debug the code, and found that the problem occurs at
org.eclipse.jface.text.source.AnnotationModel.connect(AnnotationModel.java:498):
Assert.isTrue(fDocument == null || fDocument == document);

The "document" variable always contains the java code passed by my
DocumentProvider but, in some ocassions, the "fDocument" field contains
the complete contents of the file. It looks as if it was filled using
the default DocumentProvider and not my own. May that be the case? I
didn't want to register my document provider in the plugin.xml as it is
not the appropriate one for other editors of the same file extension.

I would really appreciate if any of you could point me towards the right
path on how to solve this (or, alternatively, show me a better approach
to take). I really look forward to your answer.

Regards,
Juan Pedro
Re: Problems conecting a custom document provider to CompilationUnitEditor. [message #990224 is a reply to message #989903] Tue, 11 December 2012 13:37 Go to previous message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
I leave an answer here, for if someone comes along with the same problem.
I created an implementation of IEditorInput, and provide it to the editor.
That solves the Assert problem.
I will continue struggling with the save action part.
Regards,
Juan Pedro

[Updated on: Tue, 11 December 2012 13:38]

Report message to a moderator

Previous Topic:NumberFormatException
Next Topic:Classpath generation on manifest file for runnable jar
Goto Forum:
  


Current Time: Thu Apr 18 07:11:00 GMT 2024

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

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

Back to the top