My tree items collapse when the semantic model is modified [message #1689931] |
Tue, 24 March 2015 13:02  |
Eclipse User |
|
|
|
Hi everyone,
My Sirius-based RCP application contains a Tree representation with conditional styles. The application enables to modify the semantic model represented in the tree from outside this representation in an EMF transaction (from another Sirius representation or a custom command). The problem I have is the following: whenever the semantic model is modified from a custom command, and if the modification has an impact on the Tree:
- the contents of the tree are updated accordingly. OK.
- all nodes of the tree collapse.
I would like the expand/collapse status of all nodes of the tree not impacted by the transaction to remain unchanged.
1) Is it possible to specify such a behaviour using properties of the Tree representation ?
2) Otherwise, how is it possible to programmatically get/set the expanded/collapsed status of the nodes of a Tree representation ? I noticed that the DTreeItemExpansionChangeCommand command enables to expand/collapse a DTreeItem, but how can I instantiate a DTreeItem and retrieve the state of a DTreeItem object ?
Thanks in advance,
François
|
|
|
|
Re: My tree items collapse when the semantic model is modified [message #1699011 is a reply to message #1690293] |
Fri, 19 June 2015 09:11  |
Eclipse User |
|
|
|
Hi Laurent,
I have tested your example and it works perfectly. In fact, the tree representation I am trying to create is a little more complex. Our semantic model can contain a lot of objects and references, so we would like to show in our tree representation the contents of every one-to-many reference as a folder whose label displays the number of referenced objets. Then, once the folder is unfolded, the end user can access the referenced objects themselves.

To be able to achieve that, I created an EMF type called Folder encapsulating the source object and the reference's feature id. I created 2 Java Services used as "Semantic Candidates Expressions" in my VSM.
- List<Folder> getFolders(EObject) : creates then returns one folder per reference whose source is the EObject parameter. After being created, the Folder objects are attached to the Sirius session using the SessionTransientAttachment eAdapter.
- List<EObject> getFolderContents(Folder) : returns the list of the referenced EObject associated to a Folder
It works perfectly when accessing the model in a read-only way. But when I try to change the contents of the model from my application (either from a Create Instance action, or using another view or doing it programmatically), my tree representation collapses immediately.
I also noticed that the collapse/expand status of the tree items is serialized when I save the representation (expanded="true"), but when I load it again, the whole tree is collapsed.
I guess that it has something to do with the use of transient Folder objects. Is there a smarter way to achieve my goal using more standard mechanisms in a way that the tree's expand/collapse status is not lost at each modification ?
Thanks in advance,
François
Attachment: bolv.png
(Size: 35.80KB, Downloaded 752 times)
[Updated on: Fri, 19 June 2015 09:30] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.02693 seconds