|Re: My tree items collapse when the semantic model is modified [message #1690293 is a reply to message #1689931]
||Thu, 26 March 2015 11:36
|| Laurent Redor
Registered: July 2009
Le 24/03/2015 18:02, Francois Cabrol a écrit :|
> Hi everyone,
I'm not sure to understand your problem. I join an example:
Steps to reproduce:
* Import Tree project in your workspace
* Open tree1 representation
* Open tree2 representation
* Open tree.ecore with "Sample Ecore Model Editor"
* Split all these 3 editors to allow to see them simultaneously
* Rename C5 to C5A in tree2
* --> The change is visible in tree1 and items are not collapsed.
* Rename C2 to C2A in tree.ecore editor and save
* --> The change is visible in tree1 and tree2, and items are not collapsed.
> 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
You do not have to instantiate DTreeItem (you must not instantiate
DTreeItem). They are the children of the DTree (root element of your
editor) or of other DTreeItem.
> and retrieve the state of a DTreeItem object ?
From a DTreeItem you have a method isExpanded().
> Thanks in advance,
Laurent Redor - Obeo
Need professional services for Sirius?
Laurent Redor - Obeo
Need training or professional services for Sirius?
|Re: My tree items collapse when the semantic model is modified [message #1699011 is a reply to message #1690293]
||Fri, 19 June 2015 13:11
| Francois Cabrol
Registered: January 2015
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,
(Size: 35.80KB, Downloaded 505 times)
[Updated on: Fri, 19 June 2015 13:30]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.02315 seconds