Bug 495610 - Children of "virtual node" are not displayed in the model explorer view
Summary: Children of "virtual node" are not displayed in the model explorer view
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2016-06-07 11:45 EDT by Arthur Daussy CLA
Modified: 2017-01-10 04:46 EST (History)
2 users (show)

See Also:


Attachments
Tree on generated editor (13.33 KB, image/png)
2016-06-07 11:45 EDT, Arthur Daussy CLA
no flags Details
Tree in the model explorer view (16.28 KB, image/png)
2016-06-07 11:46 EDT, Arthur Daussy CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arthur Daussy CLA 2016-06-07 11:45:44 EDT
Created attachment 262283 [details]
Tree on generated editor

I have used the method described in the book "EMF Eclipse Modeling Framework" at ยง 19.2.3. "Adding Non-Model Intermediary View Objects" in order to define some "virtual node" in my content tree. In the generated editor it seems to work properly however in the content tree of the model explorer view the children of my virtual nodes are not displayed. 

See screenshots in attachment
Comment 1 Arthur Daussy CLA 2016-06-07 11:46:06 EDT
Created attachment 262284 [details]
Tree in the model explorer view
Comment 2 Maxime Porhel CLA 2016-06-08 03:12:07 EDT
org.eclipse.sirius.ui.tools.internal.views.common.SessionWrapperContentProvider.doGetChildren() handles IResource, Sirius items and EObject, it can return "virtual node" ie non EObject children but will not return children for them.

The wrapped content provider is an AdapterFactoryContentProvider, created from a ComposedAdapterFactory (with ComposedAdapterFactory.Descriptor.Registry.INSTANCE, DialectUIManager.createAdapterFactory(), ReflectiveItemProviderAdatpterFactory). This might not be optimized, see Bug 454388.

You can try to use ViewHelper.INSTANCE which will be a ViewHelperImpl and call addExtensions to provide a ISessionViewExtension with your content provider to handle your virtual nodes. Your extension will be called on getChildren() and getParent(). This is not API but might allow you to wait for a correction of this bugzilla. 

The concrete correction will be to modify SessionWrapperContentProvider/SiriusCommonContentProvider to avoid to stop on non EObject elements.
Comment 3 Arthur Daussy CLA 2016-06-23 12:29:41 EDT
Yes I agree. But since I am using my own view I have copied SessionWrapperContentProvider and added the following correction.

In SessionWrapperContentProvider.doGetChildren I have added the following case and it works just fine.


else if (parentElement instanceof IStructuredItemContentProvider) {
            result.addAll(((IStructuredItemContentProvider) parentElement).getElements(parentElement));
        }

Thanks for your help. Should I close the bug or do you plan to integrate such change in the Sirius Content provider?
Comment 4 Eclipse Genie CLA 2017-01-10 04:46:44 EST
New Gerrit change created: https://git.eclipse.org/r/88339