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

1

6

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.

Selfabasement answered 21/11, 2014 at 10:4 Comment(0)
F
2

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.

Finley answered 25/11, 2014 at 9:35 Comment(1)
that's all quite more than I need. I just need to open and edit a property value of an EMF element in a simple Default Text editor.Selfabasement

© 2022 - 2024 — McMap. All rights reserved.