Question

I have a sample EMF hierarchy like this -

  • Parent : Shape
  • Child 1 : Circle
  • Child 2 : Square
  • Child 3 : Rect

Now I want to generate my properties view in Eclipse in such a way that . I have a drop down with ShapeType and based on the shape type I want to show the properties of the child element.

Essentially I want to display/edit the child properties based on the 'type' selection in the parent.

Any thoughts how I can achieve this?

Was it helpful?

Solution

You cannot solve this issue easily, as in that case the dropdown needs to change the EMF type of an object, that results in Java class changes. To have such thing working, you have to create a new EObject instance, copy all relevant attributes, and remove the old object (and possibly update the selection).

So, alltogether, I believe, what you want is not possible with basic EMF tooling, however, if you provide a custom model manipulation commands, it should be possible.

Other things, you can try (if possible in your domain):

  • Move all your data to properties of the parent object, add EValidators to prevent inconsistent states from appearing, and update the default EMF Edit commands to filter out unnecessary editors. Ugly, but may work.
  • Create custom forms/editors, that manage the object removal/addition during the manually coded editing process.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top