Using the e3x Property Representation Using the e4 Select Function from the EMF Model

I built a small e4 RCP application containing a tree view of "e4 xmi" populated with model code generated by emf (using ComposedAdapterFactory) and a "representation of e3 properties."

I tried the following "dirksmetric tutorial" to display a property view in application.e4xmi (common elements) with an empty property view.

To get the selected tree element displayed in my properties page (IItemPropertySource), I performed the following steps:

  • On my side of the e4 treeviewer, I use the e4 picker service in #createComposite:

    // Register the viewer as the selection provider (for use in the property view ...) viewer.addSelectionChangedListener (new ISelectionChangedListener () {@Override public void selectionChanged (event SelectionChangedEvent) {IStructuredSelection selection = (IStructuredSelection) event.getSelection (); // set the selection to the service selectionService.setSelection (selection.size () == 1? selection.getFirstElement (): selection.toArray ());}});

  • On the side of the e3 β€œclassic” property table, I defined a couple of things:

    • I called IDE.registerAdapters in the initialization of ApplicationWorkbenchAdvisor #.
    • I declared my resource source adapter as shown in my plugin.xml file:

    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 ">

    1. My ModelPropertiesAdapter # getAdapter returns the source of the property:

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 a new AdapterFactoryContentProvider (emfGlobalFactory) .getPropertySource (adaptableObject); } return null; }

My problem is that this adapter did not even complete.

Currently using Eclipse neon (it has recently been updated to synchronize E3 and E4 selection services) https://bugs.eclipse.org/bugs/show_bug.cgi?id=403930

+7
eclipse-rcp e4 eclipse-emf
source share
1 answer

There are various ways to fix this problem, but for my case these are steps

I have taken the following steps to solve my problem.

  • Take control of the base model - create an interface that extends EObject
  • Create a custom property provider, source and descriptor - extends org.eclipse.emf.edit.ui.provider.*
    • at runtime we need IItemPropertySource
  • Create a content provider class (extends AdapterFactoryContentProvider ) and override createPropertySource using a custom property source
  • Note; I also designed a table layout that means implementing a custom ItemProvider (implementing ITableItemLabelProvider ) for individual items in the model

Worked fine with ESelectionService

Hope these notes help someone

+1
source share

All Articles