|
Re: Graphical Container with No Semantic Container [message #1310486 is a reply to message #1303177] |
Wed, 23 April 2014 08:00 |
|
Le 19/04/2014 06:56, Nikolay Manolov a écrit :
> Hi All,
Hi.
> My question is would it be possible to have a dynamic number of
> containers based on some attribute value of the Fields. Say I have the
> following metamodel
>
> class Field
> String type
>
> class Group{
> Field[] fields
> }
>
> I want my representation to have a subgroup for each unique value of
> Field.type among all existing Fields. The problem here, in contrast to
> the previous example, is that I do NOT know in advance all of the
> subgroups as they are determined by the user input (model).
>
> Group
> SubgroupForFieldType="Fruit"
> Field_Apple
> Field_Wattermellon
> SubgroupForFieldType="Car"
> Field_Ford
> Field_BMW
> SubgroupForFieldType="Whatever..."
> ...
From a quick look it does not seem possible, sorry. Normally graphical
elements on a diagram must be bound to an element in the model to
identify them (along with their type and context), but in your case the
identifying "key" is an attribute value, and not full blown EObject.
A trick that may be possible in some cases, but has its own issues, is
to use one of the element of each group as an identifying element for
the whole group, and associate e.g. SubgroupForFieldType="Fruit" to
Field_Apple. For this to work you must be able to write an expression
that, from a Group, returns a single element for each of the groups you
want to have (say, Field_Apple and Field_Ford in your case). But this
has important limitations: the expression must return the same
identifying element each time it will be evaluated by Sirius. If you do
something like "group by type, sort by name and take the first of each
group", some changes in the model (elements renamed, added, removed)
will result in a different element used a a key for the group. Sirius
will interpret this as "old group removed (with all its contents), new
group added (with new equivalent content)", and all layout information
on the old group will be lost in the new one.
If you control the metamodel and if it is not too impacting, you can
create a reified type (i.e. an explicit EClass) to represent the group
keys, and a derived feature in Group, say EList<GroupKey>
getGroupKeys(), with GroupKey an EClass with a single EString attribute.
It would work, but it would be a shame to "pollute" your model with
concepts irrelevant to your domain just to please a specific tool.
Anyway, that's the current state of affairs. It's not the first time we
are confronted with this (or similar) issues, maybe we can think of a
better solution to directly support these cases. Could you open a
bugzilla about this?
Regards,
Pierre-Charles David
Pierre-Charles David - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02720 seconds