Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Group Elements in TableTree
Group Elements in TableTree [message #1241255] Fri, 07 February 2014 13:01 Go to next message
Aleksandar Toshovski is currently offline Aleksandar Toshovski
Messages: 38
Registered: December 2011
Member
I have a class which has two lists of elements with the same type.For example:

class Field

class Group{
   Field[] headFields
   Field[] tableFields
}


When I define a Table Tree viewpoint I want to show them the same way like in the class definition -- separated. I've tried to create a line with two sublines, but it shows the elements on the same level:

Group
 headField1
 headField2
 tableField1
 tableField2


I'm trying to achieve:

Group
 headFields
  headField1
  headField2
 tableFields
  tableField1
  tableField2


How can I group the sublines without changing the metamodel?
Re: Group Elements in TableTree [message #1242928 is a reply to message #1241255] Mon, 10 February 2014 04:17 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles David
Messages: 127
Registered: July 2009
Senior Member
Hi.

Le 07/02/2014 19:01, Aleksandar Toshovski a écrit :
> I'm trying to achieve:
>
> Group
> headFields
> headField1
> headField2
> tableFields
> tableField1
> tableField2

Are the "headerFields" and "tableFields" at the same level as the
"Group"? I'll assume they are below.

> How can I group the sublines without changing the metamodel?

You can get this by creating two line mappings which technically
represent the Group (so there is only one such line each), but change
the label expression to show "headerFields" and "tableField".

So you would have mappings like this:

GroupLineMapping
domainClass: Group
semanticCandidateExpression: [someExpression/]
HeaderFieldsCategoryMapping
| domainClass: Group
| semanticCandidateExpression: [someExpression/] <- the same
| label: "headFields" <- fixed category title
|
\- HeadFieldMapping: the same mapping you currently have for this


And repeat for the tableFields category.

Note that this will only work if there is a single Group in each of your
table/tree. If you try to show several groups with this definition, you
will get something like this:

Group1
Group2
headFields
fieldsForGroup1
headFields
fieldsForGroup2

If you are in that case, you will need to move the "Category" mappings
as sub-mappings of GroupLineMapping so they are properly scoped. In that
case you also need to change the semanticCandidateExpression of the
categories to "[self/]" (or "var:self") so that the mappings only used
for visual categorization do not change the context.

Regards,
Pierre-Charles David
Re: Group Elements in TableTree [message #1243686 is a reply to message #1242928] Tue, 11 February 2014 05:03 Go to previous messageGo to next message
Aleksandar Toshovski is currently offline Aleksandar Toshovski
Messages: 38
Registered: December 2011
Member
Sorry for the last description, but I think you didn't understand my description. I'll try to explain again what I'm trying to achieve:

This is the UML diagram:
http://i.imgur.com/o2RrW32.png

I want to group the HeadField and The TableFields adding a new level on the tree structure like below: 1st Level Groups, 2nd level Head/Table Fields and 3d level are the grouped fields.

Group 1
 |--Head Fields
 |  |-- Headfield 1
 |  |-- Headfield 2  
 |--Table Fields
 |  |-- Tablefield 1
 |  |-- Tablefield 2 
Group 2
....    
Re: Group Elements in TableTree [message #1243712 is a reply to message #1243686] Tue, 11 February 2014 05:44 Go to previous message
Pierre-Charles David is currently offline Pierre-Charles David
Messages: 127
Registered: July 2009
Senior Member
Le 11/02/2014 11:03, Aleksandar Toshovski a écrit :
> Sorry for the last description, but I think you didn't understand my
> description. I'll try to explain again what I'm trying to achieve:
>
> This is the UML diagram:


> I want to group the HeadField and The TableFields adding a new level on
> the tree structure like below: 1st Level Groups, 2nd level Head/Table
> Fields and 3d level are the grouped fields.
>
>
> Group 1
> |--Head Fields
> | |-- Headfield 1
> | |-- Headfield 2 |--Table Fields
> | |-- Tablefield 1
> | |-- Tablefield 2 Group 2
> ...

So that was what I tried to say in my last paragraph.

You need 5 mappings, organized like this:

GroupMapping
HeadFieldsCategoryMapping
HeadFieldsMapping
TableFieldsCategoryMapping
TableFieldMapping

From what I understand you already have GroupMapping, HeadFieldsMapping
and TableFieldMapping. You should be able to keep them with their
current definitions.

Instead of having HeadFieldsMapping (resp. TableFieldMapping) as direct
sub-lines of GroupMapping, you must insert an intermediate
HeadFieldsCategoryMapping (resp. TableFieldsCategoryMapping) to model
the categories. Your semantic model does not contain an intermediate
element between a Group and a Field, but that's OK, it does not need to.
Simply configure the HeadFieldsCategoryMapping (resp.
TableFieldsCategoryMapping) like this:

domainClass = Group
semanticCandidatesExpression = [self/]
headerLabelExpression = "Head Fields" (resp. "Table Fields")

This way, technically the category lines are bound to the same Group
element as their parent line (because each line *must* be bound to a
model element and your model does not have an explicit object for the
categories), but visually for end-users they look and behave like
different categories for specific kinds of sub-lines.

Note that this is a general technique which can be used with all Sirius
dialects (incl. diagrams and trees): if you need intermediate elements
in your representation that don't actually exists in your domain model,
create a mapping which binds to the same domain element as its parent
(here both categories are technically bound to the Group) but use a
different graphical representation.

If this is still not clear enough or I misunderstood you, maybe you can
attach here (or send me in private) your example.

Regards,
Pierre-Charles David
Previous Topic:Set a default presentation view.
Next Topic:Integrating sirius into an RCP application, Best Practices
Goto Forum:
  


Current Time: Wed Aug 27 13:07:40 EDT 2014

Powered by FUDForum. Page generated in 0.02202 seconds