Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF] Editor Page for source code field?(Extending MultipageEditor with a text (source code) editor for a field.)
icon5.gif  [EMF] Editor Page for source code field? [message #992382] Fri, 21 December 2012 09:07 Go to next message
Juan Pedro Silva is currently offline Juan Pedro Silva
Messages: 258
Registered: July 2009
Senior Member
Hi everybody.
I am facing some problems trying to add an editor page to the generated multipage editor for editing the contents of a particular model element's field. 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 extend
AbstractDecoratedTextEditor 
to be able to edit this field's content, to no avail.

I have already extended AbstractDecoratedTextEditor and I'm using a customized implementation of DocumentProvider to provide the correct content to the editor. I've also created my own StringEditorInput to be provided as the editor's input. I have registered my DP for this type of editor input, and also set it programmatically in my editor's constructor, but I got that 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()
method. The exact offending line is (AnnotationModel.java:line 498):

Assert.isTrue(fDocument == null || fDocument == document);


when called from within the for loop below in that same method (AnnotationModel.java:lines 517 to 529):
for (Iterator it= fAttachments.keySet().iterator(); it.hasNext();) 
{
   IAnnotationModel model= (IAnnotationModel) fAttachments.get(it.next());
   model.connect(document);
}


The document variable in the assertion always contains the document passed by my DocumentProvider but, when called from within that for loop (on the IAnnotationModel model elements), the fDocument field contains a SynchronizableDocument (which contains the complete contents of the enclosing file). It looks as if it was created using the default DocumentProvider and not my own, even though I registered my DP for my type of EditorInput.

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). Is there a way to set the document in these IAnnotationModel model elements?

Thanks in advance.
Regards,
JP

[Updated on: Fri, 21 December 2012 11:42]

Report message to a moderator

Re: [EMF] Editor Page for source code field? [message #992501 is a reply to message #992382] Fri, 21 December 2012 15:13 Go to previous messageGo to next message
Juan Pedro Silva is currently offline Juan Pedro Silva
Messages: 258
Registered: July 2009
Senior Member
The problem originates in org.eclipse.ui.editors.text.TextFileDocumentProvider.createFileInfo(Object). The ITextFileBufferManager creates the different elements with the SynchronizableDocument. I overrid the method and currently I am returning null, but I'm not sure that is the best solution.

Any ideas?
Re: [EMF] Editor Page for source code field? [message #992838 is a reply to message #992501] Sat, 22 December 2012 14:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25938
Registered: July 2009
Senior Member
Juan,

Sorry but all these details how of text editors work are beyond my
expertise and this isn't really and EMF question...

On 21/12/2012 12:13 PM, Juan Pedro Silva wrote:
> The problem originates in
> org.eclipse.ui.editors.text.TextFileDocumentProvider.createFileInfo(Object).
> The ITextFileBufferManager creates the different elements with the
> SynchronizableDocument. I overrid the method and currently I am
> returning null, but I'm not sure that is the best solution.
>
> Any ideas?
Re: [EMF] Editor Page for source code field? [message #996567 is a reply to message #992838] Wed, 02 January 2013 06:51 Go to previous message
Juan Pedro Silva is currently offline Juan Pedro Silva
Messages: 258
Registered: July 2009
Senior Member
Thanks, Ed, anyhow.
I thought it applied, because this intended to be an editor for an eAttribute within an EMF Multipage editor, although in an afterthought, it is much specific to text editors in reality.
I'm sorry for the inconvenience.

Happy new year! Smile

[Updated on: Wed, 02 January 2013 06:53]

Report message to a moderator

Previous Topic:EMF and Large Scientific Datasets
Next Topic:Embedding arbitrary models in a model
Goto Forum:
  


Current Time: Tue Jul 29 06:46:49 EDT 2014

Powered by FUDForum. Page generated in 0.01949 seconds