Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to prevent TreeViewer collapse on add/delete of model entities
How to prevent TreeViewer collapse on add/delete of model entities [message #733533] Wed, 05 October 2011 00:38 Go to next message
Nidhi  is currently offline Nidhi Friend
Messages: 92
Registered: December 2009
Member

Hi,

I am re-using the AdapterFactoryContentProvider in my treeviewer. How can I prevent my tree from collapsing automatically and hence restore the expanded state on creation and deletion of model elements.


Thanks a lot,
Best Regards,
Nidhi

[Updated on: Sat, 08 October 2011 17:56]

Report message to a moderator

Re: How to prevent TreeViewer collapse on add/delete of model entities [message #734824 is a reply to message #733533] Mon, 10 October 2011 05:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Nidhi,

I'm not sure why creation would cause something to collapse. I'd expect
the editor to expand to select the created node.


On 05/10/2011 2:38 AM, Nidhi wrote:
> Hi,
>
> I am re-using the AdapterFactoryContentProvider in my treeviewer. How
> can I prevent my tree from collapsing automatically and hence restore
> the expanded state on creation and deletion of model entities.
>
> Thanks,
> Best Regards,
> Nidhi


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to prevent TreeViewer collapse on add/delete of model entities [message #840800 is a reply to message #734824] Tue, 10 April 2012 14:22 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
I have a case where this happens: Imagine you have an EList<MyObject> which has to be grouped at run time by some business logic. This has to be done in the content provider (e.g. AdapterFactoryContentProvider) by introducing a non-modeled virtual node to be shown in the tree viewer.
Adding a new MyObject to the list will instruct the content provider to refresh the tree viewer: the content provider will create new virtual (grouping) nodes once getElements() is called, but the tree viewer does not know of those new virtual nodes, so the viewer will collapse the input...

If I cache the virtual nodes, then everything is ok (getElements() will re-use the created virtual nodes). Is there another way to achieve this? (Did you get the point?)
Re: How to prevent TreeViewer collapse on add/delete of model entities [message #840825 is a reply to message #840800] Tue, 10 April 2012 14:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Erdal,

Comments below.

On 10/04/2012 4:22 PM, Erdal Karaca wrote:
> I have a case where this happens: Imagine you have an EList<MyObject>
> which has to be grouped at run time by some business logic. This has
> to be done in the content provider (e.g.
> AdapterFactoryContentProvider) by introducing a non-modeled virtual
> node to be shown in the tree viewer.
> Adding a new MyObject to the list will instruct the content provider
> to refresh the tree viewer: the content provider will create new
> virtual (grouping) nodes once getElements() is called, but the tree
> viewer does not know of those new virtual nodes, so the viewer will
> collapse the input...
To be able to select the right object, a proper implementation of
getParent is needed. I.e., the child of the virtual node but return
that virtual node in getParent...
>
> If I cache the virtual nodes, then everything is ok (getElements()
> will re-use the created virtual nodes).
Consistently returning the same node is important.
> Is there another way to achieve this? (Did you get the point?)
Expanding the right path down to the node you want to select requires
that getParent returns the proper path to the root...


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to prevent TreeViewer collapse on add/delete of model entities [message #840856 is a reply to message #840800] Tue, 10 April 2012 15:36 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Yes give your Virtual nodes an ID and:
a) overload equals/hashCode
b) set an IElementComparer on the viewer

Tom

Am 10.04.12 16:22, schrieb Erdal Karaca:
> I have a case where this happens: Imagine you have an EList<MyObject>
> which has to be grouped at run time by some business logic. This has to
> be done in the content provider (e.g. AdapterFactoryContentProvider) by
> introducing a non-modeled virtual node to be shown in the tree viewer.
> Adding a new MyObject to the list will instruct the content provider to
> refresh the tree viewer: the content provider will create new virtual
> (grouping) nodes once getElements() is called, but the tree viewer does
> not know of those new virtual nodes, so the viewer will collapse the
> input...
>
> If I cache the virtual nodes, then everything is ok (getElements() will
> re-use the created virtual nodes). Is there another way to achieve this?
> (Did you get the point?)
Previous Topic:Treeviewer only refreshes when clicked on
Next Topic:SWT.VIRTUAL
Goto Forum:
  


Current Time: Thu Apr 25 07:02:05 GMT 2024

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

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

Back to the top