Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext editor working with custom resource(How to customise generated Xtext editor to support my custom resources?)
Xtext editor working with custom resource [message #721012] Wed, 31 August 2011 16:57 Go to next message
Vitaly Savickas is currently offline Vitaly SavickasFriend
Messages: 62
Registered: March 2010
Member
Hi,

I am completely new to Xtext, and first impression is very good:) I've managed to generate an editor for my existing ecore model. Now what I already have is a well-built Eclipse-based platform that has its own resources, not even EMF compatible. But there is an EMF-based implementation of resource that persists EMF model to these specific resources, which allows to open them with let's say standard EMF editor. Now what would be cool is to customise the generated Xtext editor so that it uses the existing EMF-based resource for persistence i.e. loading/saving. Is it possible and where to start?

Regards,
Vitaly
Re: Xtext editor working with custom resource [message #721046 is a reply to message #721012] Wed, 31 August 2011 19:05 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
You can open a text based resource with a standard EMF editor already -
the textual form is just a type of serialization.

Not sure I understand what you are trying to do. It sounds like you have
a resource in XMI form and you want to edit it as text. Is that correct?

Regards
- henrik

On 8/31/11 6:57 PM, Vitaly Savickas wrote:
> Hi,
>
> I am completely new to Xtext, and first impression is very good:) I've
> managed to generate an editor for my existing ecore model. Now what I
> already have is a well-built Eclipse-based platform that has its own
> resources, not even EMF compatible. But there is an EMF-based
> implementation of resource that persists EMF model to these specific
> resources, which allows to open them with let's say standard EMF editor.
> Now what would be cool is to customise the generated Xtext editor so
> that it uses the existing EMF-based resource for persistence i.e.
> loading/saving. Is it possible and where to start?
>
> Regards,
> Vitaly
Re: Xtext editor working with custom resource [message #721249 is a reply to message #721046] Thu, 01 September 2011 09:21 Go to previous messageGo to next message
Vitaly Savicks is currently offline Vitaly SavicksFriend
Messages: 15
Registered: July 2009
Junior Member
Yes, indeed, I just want to edit it as text. There are existing editors in platform, but my goal is to implement a text editor. The file is in XMI (but not standard) and I need to persist it in this format for platform to understand it, not in plain text. The generated Xtext editor stores it as plain text. So my question is simply how to customise the generated editor to persist it as needed by platform, essentially to use existing custom resource implementation which does correct XMI persistence via save/load methods.

Regards,
Vitaly

Quote:
You can open a text based resource with a standard EMF editor already -
the textual form is just a type of serialization.

Not sure I understand what you are trying to do. It sounds like you have
a resource in XMI form and you want to edit it as text. Is that correct?

Regards
- henrik

On 8/31/11 6:57 PM, Vitaly Savickas wrote:
> Hi,
>
> I am completely new to Xtext, and first impression is very good:) I've
> managed to generate an editor for my existing ecore model. Now what I
> already have is a well-built Eclipse-based platform that has its own
> resources, not even EMF compatible. But there is an EMF-based
> implementation of resource that persists EMF model to these specific
> resources, which allows to open them with let's say standard EMF editor.
> Now what would be cool is to customise the generated Xtext editor so
> that it uses the existing EMF-based resource for persistence i.e.
> loading/saving. Is it possible and where to start?
>
> Regards,
> Vitaly

[Updated on: Thu, 01 September 2011 09:25]

Report message to a moderator

Re: Xtext editor working with custom resource [message #721357 is a reply to message #721249] Thu, 01 September 2011 14:47 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
But platform can read the XMI if the parser is installed - it is loaded
just like any other resource. It is only if you need to send the model
someplace where the parser is not present that you would need an XMI
representation of it. Likewise, if you receive a model in XMI, you can
simply load it, serialize it to text and save it.

You could probably come up with a scheme that creates the text on the
fly, user edits, and when saving, it is saved in XMI. The problem is
that you loose all textual information that is not stored in the model.
Each time the text is opened it is the auto-formatted/serialied result
that is presented. Most notably, comments will be missing.

It is probably better to run a builder that synchronizes between a
textual representation and xmi. (If the text does not exist, it is
created from the xmi, and after that, the xmi is synched to changes in
the text).

- henrik

On 9/1/11 11:21 AM, Vitaly Savicks wrote:
> Yes, the file is in XMI (but not standard) and I need to persist it in
> this format for platform to understand it, not in plain text. The
> generated Xtext editor stores it as plain text. So my question is simply
> how to customise the generated editor to persist it as needed by
> platform, essentially to use existing custom resource implementation
> which does correct XMI persistence via save/load methods.
>
> Regards,
> Vitaly
>
> Quote:
>> You can open a text based resource with a standard EMF editor already -
>> the textual form is just a type of serialization.
>>
>> Not sure I understand what you are trying to do. It sounds like you have
>> a resource in XMI form and you want to edit it as text. Is that correct?
>>
>> Regards
>> - henrik
>>
>> On 8/31/11 6:57 PM, Vitaly Savickas wrote:
>> > Hi,
>> >
>> > I am completely new to Xtext, and first impression is very good:) I've
>> > managed to generate an editor for my existing ecore model. Now what I
>> > already have is a well-built Eclipse-based platform that has its own
>> > resources, not even EMF compatible. But there is an EMF-based
>> > implementation of resource that persists EMF model to these specific
>> > resources, which allows to open them with let's say standard EMF
>> editor.
>> > Now what would be cool is to customise the generated Xtext editor so
>> > that it uses the existing EMF-based resource for persistence i.e.
>> > loading/saving. Is it possible and where to start?
>> >
>> > Regards,
>> > Vitaly
>
Re: Xtext editor working with custom resource [message #721380 is a reply to message #721357] Thu, 01 September 2011 15:52 Go to previous message
Vitaly Savickas is currently offline Vitaly SavickasFriend
Messages: 62
Registered: March 2010
Member
Yes, the idea of having two copies of one resource, namely XMI and text, has also visited me, but I'm afraid the synchronisation will be a weak link here, and taking into account likely big scale of projects in my application and many building tasks that have to be carried out on each build run, I guess it can become a serious problem.

As you correctly spotted - I just need a text editor, but not text persistence. I understand that I require text to preserve formatting (though comments are not an issue, as comments are part of the existing ecore metamodel:) Thus if we assume that formatting is not important i.e. it will be auto-formatted whenever we open a resource, how to make the Xtext work with XMI resources? Is there a simple way to tell the generated Xtext editor to use my own resource implementation instead of XtextResource?

Regards,
Vitaly

Henrik Lindberg wrote on Thu, 01 September 2011 10:47
But platform can read the XMI if the parser is installed - it is loaded
just like any other resource. It is only if you need to send the model
someplace where the parser is not present that you would need an XMI
representation of it. Likewise, if you receive a model in XMI, you can
simply load it, serialize it to text and save it.

You could probably come up with a scheme that creates the text on the
fly, user edits, and when saving, it is saved in XMI. The problem is
that you loose all textual information that is not stored in the model.
Each time the text is opened it is the auto-formatted/serialied result
that is presented. Most notably, comments will be missing.

It is probably better to run a builder that synchronizes between a
textual representation and xmi. (If the text does not exist, it is
created from the xmi, and after that, the xmi is synched to changes in
the text).

- henrik

On 9/1/11 11:21 AM, Vitaly Savicks wrote:
> Yes, the file is in XMI (but not standard) and I need to persist it in
> this format for platform to understand it, not in plain text. The
> generated Xtext editor stores it as plain text. So my question is simply
> how to customise the generated editor to persist it as needed by
> platform, essentially to use existing custom resource implementation
> which does correct XMI persistence via save/load methods.
>
> Regards,
> Vitaly
>
> Quote:
>> You can open a text based resource with a standard EMF editor already -
>> the textual form is just a type of serialization.
>>
>> Not sure I understand what you are trying to do. It sounds like you have
>> a resource in XMI form and you want to edit it as text. Is that correct?
>>
>> Regards
>> - henrik
>>
>> On 8/31/11 6:57 PM, Vitaly Savickas wrote:
>> > Hi,
>> >
>> > I am completely new to Xtext, and first impression is very good:) I've
>> > managed to generate an editor for my existing ecore model. Now what I
>> > already have is a well-built Eclipse-based platform that has its own
>> > resources, not even EMF compatible. But there is an EMF-based
>> > implementation of resource that persists EMF model to these specific
>> > resources, which allows to open them with let's say standard EMF
>> editor.
>> > Now what would be cool is to customise the generated Xtext editor so
>> > that it uses the existing EMF-based resource for persistence i.e.
>> > loading/saving. Is it possible and where to start?
>> >
>> > Regards,
>> > Vitaly
>

Previous Topic:problem with lexing terminal rules
Next Topic:Xtend nearly unusable in big files
Goto Forum:
  


Current Time: Fri Apr 26 12:25:10 GMT 2024

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

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

Back to the top