Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » My tree items collapse when the semantic model is modified
My tree items collapse when the semantic model is modified [message #1689931] Tue, 24 March 2015 17:02 Go to next message
Francois Cabrol is currently offline Francois CabrolFriend
Messages: 32
Registered: January 2015
Member
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 #1690293 is a reply to message #1689931] Thu, 26 March 2015 11:36 Go to previous messageGo to next message
Laurent Redor is currently offline Laurent RedorFriend
Messages: 267
Registered: July 2009
Senior Member
Le 24/03/2015 18:02, Francois Cabrol a écrit :
> Hi everyone,

Hi François,

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.
* Save
* 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,
>
> François


--
Laurent Redor - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius


Laurent Redor - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/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 Go to previous message
Francois Cabrol is currently offline Francois CabrolFriend
Messages: 32
Registered: January 2015
Member
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.

index.php/fa/22239/0/

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 505 times)

[Updated on: Fri, 19 June 2015 13:30]

Report message to a moderator

Previous Topic:java.lang.IllegalStateException: Cannot modify resource set without a write transaction
Next Topic:Is it possible to show edges in a container?
Goto Forum:
  


Current Time: Wed Jan 20 20:26:49 GMT 2021

Powered by FUDForum. Page generated in 0.02315 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top