Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XtextEditor + editor input which is not a file
XtextEditor + editor input which is not a file [message #636669] Tue, 02 November 2010 12:33 Go to next message
Patrick Di Loreto is currently offline Patrick Di LoretoFriend
Messages: 10
Registered: May 2010
Junior Member
How can I pass to the XtextEditor an input which is not a file?

Example:

I have an EMF model based on: MyModel.

MyModel contains metrics. Each metric has a formula:

MyModel
........|
........|---- Metrics
..................|------Metric
..............................|------Formula
........................................... |----Expression
..........................................................|. ....

My DSL in Xtext defines a grammar for the Expression object.

When with the Xtext editor I write an expression I want to take the EMF object and add this to my main EMF Object which is persisted using XMIResourceImpl.

How can I achieve that result ?
Re: XtextEditor + editor input which is not a file [message #637422 is a reply to message #636669] Fri, 05 November 2010 12:31 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Am 02.11.10 13:33, schrieb Patrick:
> How can I pass to the XtextEditor an input which is not a file?

You could write an IEditorInput yourself, e.g.
ResourceWorkingCopyFileEditorInput allows you to use the contents of an
exisiting Resource as input for an XtextEditor

>
> Example:
>
> I have an EMF model based on: MyModel.
>
> MyModel contains metrics. Each metric has a formula:
>
> MyModel
> .......|
> .......|---- Metrics
> .................|------Metric
> .............................|------Formula
> .......................................... |----Expression
> ..........................................................|. ....
>
> My DSL in Xtext defines a grammar for the Expression object.
>
> When with the Xtext editor I write an expression I want to take the EMF
> object and add this to my main EMF Object which is persisted using
> XMIResourceImpl.
>
> How can I achieve that result ?

As Xtext implements an EMF Resource it can be used transparently in
almost any EMF using application. Why do you need to keep XMI
serialization, which is horrible to read and maintain?

There are also various alternatives:
- use IXtextEditorCallback to be notified on save and take an action
- have a look at the OCL in Ecore example. It is somewhere in MDT/OCL
- register an IXtextModelListener to your editor and process model changes
- wait for Xbase and use it for your expressions
- ...





--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: XtextEditor + editor input which is not a file [message #637439 is a reply to message #637422] Fri, 05 November 2010 14:00 Go to previous messageGo to next message
Patrick Di Loreto is currently offline Patrick Di LoretoFriend
Messages: 10
Registered: May 2010
Junior Member
Hi Jan,

thanks for your reply,
the reason I want to serialize in XMI is that my original model is XMI based, the xtext DSL just defines the Formula.

I want to have a Formula in XMI because it will represent a sort of AST, in the future I want to define more DSL which will map on the same ecore Formula object..

So a user can decide in which language writes the formula or reads it.

My next question is now how to put all the things together, I mean once I have created my specific editorInput which will implements the logic I need, how can I incorporate the XtextEditor inside a FormEditor and to be more specific in a IDetailsPage of a Master/Details FormPage ?

Any suggestion?

Thanks
Patrick


Re: XtextEditor + editor input which is not a file [message #637683 is a reply to message #637439] Mon, 08 November 2010 10:47 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Xtext currently does not support integrating the Xtext editor in a form
editor out of the box, but we're working on it.

You might want to have a look at the thread "Xtext editor integration
within UI Form editor". Note this is not an officially supported Xtext
solution.

Regards
Jan

Am 05.11.10 15:00, schrieb Patrick:
> Hi Jan,
>
> thanks for your reply,
> the reason I want to serialize in XMI is that my original model is XMI
> based, the xtext DSL just defines the Formula.
>
> I want to have a Formula in XMI because it will represent a sort of AST,
> in the future I want to define more DSL which will map on the same ecore
> Formula object..
>
> So a user can decide in which language writes the formula or reads it.
>
> My next question is now how to put all the things together, I mean once
> I have created my specific editorInput which will implements the logic I
> need, how can I incorporate the XtextEditor inside a FormEditor and to
> be more specific in a IDetailsPage of a Master/Details FormPage ?
>
> Any suggestion?
>
> Thanks
> Patrick
>
>
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: XtextEditor + editor input which is not a file [message #638638 is a reply to message #637683] Thu, 11 November 2010 21:48 Go to previous message
Philipp M. Fischer is currently offline Philipp M. FischerFriend
Messages: 67
Registered: November 2010
Location: Germany
Member
Hi there,

I am currently facing exatly the same problems. Did you guys manage to get around these problems. Did you manage to use a customized EditorInput to directly hang in into the EMF model in the background?

Cheers

Phil
Previous Topic:How to obtain the IEObjectDescription from an EObject?
Next Topic:Question regarding lexer and IDValueConverter
Goto Forum:
  


Current Time: Thu Apr 25 08:25:32 GMT 2024

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

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

Back to the top