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 :
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">
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
There are different ways to fix this problem, but for my case, these are the steps
I took to these steps to solve mine
EObject
org.eclipse.emf.edit.ui.provider.*
IItemPropertySource
AdapterFactoryContentProvider
) and override createPropertySource
with custom property sourceItemProvider
(implement ITableItemLabelProvider
) for individual elements in the modelWorked perfectly with ESelectionService
Hope these notes helps somebody
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With