Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » EMF AdapterFactory and EEF Editor
EMF AdapterFactory and EEF Editor [message #660329] Thu, 17 March 2011 18:26 Go to next message
Nathalie  is currently offline Nathalie
Messages: 22
Registered: July 2009
Junior Member
Hello,

I customized the EEF Editor tree (MasterPart) to add non-model objects to it.The procedure is described in the EMF book (Part IV section 19.2.3).

Here is what the treelook like:

 * Model sample
   * MeasureLibrary myLibrary
     * Operations                    [non-model]
        * OCL Operations          [non-model]
        * Operations  (2)            [non-model]
           - Operation myOp
     [...]


The MeasureLibraryItemProvider returns a list of children that is filled with the Operations object, the first time getChildren(Object) is called.
When I create the myOp Operation and then expanded the tree there was no issue. A NullPointerException is thrown when I select it. the exception states that the children list of the MeasureLibraryItemProvider is empty while you can see my MeasureLibrary has children on the tree.

After deep investigation I found out that there are two MeasureLibraryItemProvider created to adapt the object MeasureLibrary (any EObject in fact) on the editor. One is created by the adapter factory found in the editor class (InteractiveEditor.initializeEditingDomain()) which is called when an object is selected on the editor. It is also used by the property section (Details part).
While the other one is created by another factory which is set on the content and label provider of the tree (EEFTreeMasterPart.createSectionClient(Composite, FormToolkit)). This one is called when the tree is expanded for example or when you create a new child.

The consequence of this is that I don't get the MeasureLibraryItemProvider that has children when I select the Operation on the tree.

I don't know if it is done on purpose to have two different factories one for the tree and for the properties section, It doesn't hurt when you don't have a custom editor because the children are determined by the EStructuralFeatures of an EObject, but in my case it hurts. I looked for solution to this and didn't find any other than change the internal code to use a single adapter factory.

If you have any suggestions please let me know.

Thanks in advance.
Re: EMF AdapterFactory and EEF Editor [message #660523 is a reply to message #660329] Fri, 18 March 2011 16:35 Go to previous messageGo to next message
Nathalie  is currently offline Nathalie
Messages: 22
Registered: July 2009
Junior Member
Hello,

I just wanted to let you know that I found a fix, well a temporary one at least.

I extended the following classes EEFTreeMDFormPage, EEFTreeMasterDetailsBlock and EEFTreeMasterPart. I contributed my custom EEFTreeMDFormPage to the editor in the InteractiveEEFEditor.contributePages(). And in the custom EEFTreeMDFormPage I set the details block to be my custom EEFTreeMasterDetailsBlock, where I set the master part to be my custom EEFTreeMasterPart.

I then change the EEFTreeMasterPart.setAdapterFactory(AdapterFactory) as follow:

        @Override
	public void setAdapterFactory(AdapterFactory adapterFact) {
		super.setAdapterFactory(adapterFact);
                getModelViewer().setContentProvider(new AdapterFactoryContentProvider(getAdapterFactory()));
		getModelViewer().setLabelProvider(new AdapterFactoryLabelProvider(getAdapterFactory()));
         }


The above code causes the TreeViewer of the editor to receive the value of the AdapterFactory used by the editor object and the property section viewers.

I think this fix is just temporary as the changed method is called when the AbstractEEFEditorPage is refreshed (AbstractEEFEditorPage .refresh()).
So I am not sure I will always run trouble free with this, especially If the current behavior is desired, but at least for now it does the job.

[Updated on: Fri, 18 March 2011 16:37]

Report message to a moderator

Re: EMF AdapterFactory and EEF Editor [message #663571 is a reply to message #660523] Tue, 05 April 2011 12:57 Go to previous message
Goulwen Le Fur is currently offline Goulwen Le Fur
Messages: 124
Registered: July 2009
Senior Member
Hello Nathalie,

Le 18/03/2011 21:36, Nathalie a écrit :
> Hello,
>
> I just wanted to let you know that I found a fix, well a temporary one
> at least.
> I extended the following classes EEFTreeMDFormPage,
> EEFTreeMasterDetailsBlock and EEFTreeMasterPart. I contributed my custom
> EEFTreeMDFormPage to the editor in the
> InteractiveEEFEditor.contributePages(). And in the custom
> EEFTreeMDFormPage I set the details block to be my custom
> EEFTreeMasterDetailsBlock, where I set the master part to be my custom
> EEFTreeMasterPart.
> I then change the EEFTreeMasterPart.setAdapterFactory(AdapterFactory) as
> follow:
>
>
> @Override
> public void setAdapterFactory(AdapterFactory adapterFact) {
> super.setAdapterFactory(adapterFact);
> getModelViewer().setContentProvider(new
> AdapterFactoryContentProvider(getAdapterFactory()));
> getModelViewer().setLabelProvider(new
> AdapterFactoryLabelProvider(getAdapterFactory()));
> }
>
>

Great !

> The above code causes the TreeViewer of the editor to receive the
> AdapterFactory that is used by the editor object and the property
> section viewers.
> I think this fix is just temporary as the changed method is called when
> the AbstractEEFEditorPage is refreshed (AbstractEEFEditorPage
> .refresh()). So I am not sure I will always run trouble free with this,
> especially If the current behavior is desired, but at least for now it
> does the job.
>
>

Anway, it's not a good thing that we have 2 factories. I think the
setAdapterFactory() method should be call for each refresh. This was
done to be able to create page contents then set the adapterAdapter or
the opposite set the adapter before the page contents creation.

I need to check the refresh method to give you a better information.

Thanks,
Regards,

--
Goulwen
Previous Topic:[EEF] Master detail form extension
Next Topic:[EEF] Integration with custom Editor
Goto Forum:
  


Current Time: Mon Apr 21 03:23:03 EDT 2014

Powered by FUDForum. Page generated in 0.05282 seconds