I built a small e4 RCP application containing both an "e4 xmi" tree view populated by emf generated model code (using ComposedAdapterFactory) and an "e3 properties view".
Tried following "dirksmetric tutorial" to display property view in application.e4xmi (shared elements) with an empty property view.
To get a tree's selected element displayed in my property sheet (IItemPropertySource), I did the following things :
On my e4 treeviewer side, I use the e4 selection service in #createComposite:
// Register the viewer as a selection provider (to be consumed by the property view...) viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); // set the selection to the service selectionService.setSelection( selection.size() == 1? selection.getFirstElement(): selection.toArray()); } });
On the e3 "classical" property sheet side, I defined a couple of things :
- I called IDE.registerAdapters in my ApplicationWorkbenchAdvisor#initialize.
- I declared my property source adapter as follow in my plugin.xml :
extension point="org.eclipse.core.runtime.adapters"> factory adaptableType="org.eclipse.emf.ecore.EObject" class="myappmodeler.properties.ModelPropertiesAdapter"> adapter type="org.eclipse.ui.views.properties.IPropertySource">
- My ModelPropertiesAdapter#getAdapter returns a property source :
public Object getAdapter(Object adaptableObject, Class adapterType) { if (adapterType== IPropertySource.class && adaptableObject instanceof EObject){ emfGlobalFactory = new ComposedAdapterFactory(); emfGlobalFactory.addAdapterFactory(new RepositorystructureItemProviderAdapterFactory()); emfGlobalFactory.addAdapterFactory(new ApplicationItemProviderAdapterFactory()); emfGlobalFactory.addAdapterFactory(new ServiceItemProviderAdapterFactory()); return new AdapterFactoryContentProvider(emfGlobalFactory).getPropertySource(adaptableObject); } return null; }
My problem is this adapter is not even executed.
Currently using Eclipse neon (it was recently updated to synchronise E3 and E4 selection service) https://bugs.eclipse.org/bugs/show_bug.cgi?id=403930