Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a Property from an EMF element in Eclipse in an Editor?

I am developing an EMF-model and an UI with different views. I also use the generated Editor from EMF.

Every element has different properties, which can be shown in the Properties-View. But especially when writing much text (f.e. description for an element), I don't want to edit this property in the small row in the Properties-View. I want to edit this property in a standard editor where I can use all of the benefits of an editor. How can I manage that?

Edit: A possible way I can think of is: Creating a Temp-File with the property-content, open this file in an editor, read the saved content after the file was saved (I don't know yet how to trigger the property-update when the file was saved) and delete the file.

like image 448
Berschi Avatar asked Nov 21 '14 10:11

Berschi


People also ask

How do I create an EMF model in Eclipse?

9.2. Example Create a new EMF project com.vogella.emf.inheritance New Modeling Project . In this project create a folder called model and in this folder create a new model by selecting File New Eclipse Modeling Framework Ecore Model on the project just created.

When should I use EMF in Eclipse?

We recommend using EMF for any structured data model you want to create in Eclipse, especially if it is stored, displayed and modified in UIs. The basic EMF workflow is very pragmatic; a model is created and defined in the Ecore format, which is basically a subset of UML Class diagrams.

Is there an editor for the EMF model?

EMF will also generate an editor for your model, complete with content outline and property sheet. There is also a reflective editor, which can view and edit any EMF model file, using only the model meta-data. It provides similar function to the default generated editor, but it can't be easily customized.

What are the advantages of Eclipse Modeling Framework (EMF)?

EMF generates interfaces and a factory to create your objects; therefore, it helps you to keep your application clean from the individual implementation classes. Another advantage is that you can regenerate the Java code from the model at any point in time. 1.2. Eclipse Modeling Framework (EMF)


1 Answers

Have a look at Xtext. Xtext allows you to create pure text based editors for your EMF models. These are called DSL editors since they usually only support a subset of the features of a complete programming language.

When writing the Xtext grammar, you need to create a structure which resembles your existing model (you especially need to use the same names). Xtext will then generate a text editor for your EMF model.

The Xbase project contains support code for multi-line strings, among other things.

Another alternative is to write your own properties view for your model which shows bigger fields for some properties.

Lastly, I've seen a demo of a new EMF model editor called "EEF" at the Eclipse Financial Day 2014 which is based in Sirius. See page 43 of the presentation slides on slideshare.net.

[EDIT]

I just need to open and edit a property value of an EMF element in a simple Default Text editor.

You need to tell Eclipse what you want. The way to do that is to write a plugin which connects the different parts. Unfortunately, the default EMF editor doesn't support any kind of configuration. If you generate an editor for your model, then you can configure the field editors (make them bigger, for example).

For editing in a normal text editor, you need to open the editor, fetch the value of the EMF property, create a document, attach it to the editor and hook into "Save" so you can set the changes back into the model.

like image 109
Aaron Digulla Avatar answered Oct 15 '22 13:10

Aaron Digulla