Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Re: IPropertySource for EObject
Re: IPropertySource for EObject [message #428949] Fri, 03 April 2009 15:31 Go to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080106090400040307000400
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Esteban,

It's best to use the EMF newsgroup. I've added it to the "to" list of
the reply.


Esteban DUGUEPEROUX wrote:
> Hi,
>
> I post here because I don't know which group is adapted.
>
> I have a view componed of a TreeViewer with as input a tree of EObject
> from my generated Ecore model.
> I want see properties of my selected item (EObject) of my TreeViewer
> in PropertySheet Viewer, then I have added this line :
>
> getSite().setSelectionProvider(viewer);
>
> but I need that my EObjects implements IAdaptable or IPropertySource
> following this article :
>
> http://www.eclipse.org/articles/Article-Properties-View/prop erties-view.html
>
No you don't need that. The generated editor already shows how this is
supported using an AdapterFactoryContentProvider:

/**
* This accesses a cached version of the property sheet.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public IPropertySheetPage getPropertySheetPage()
{
if (propertySheetPage == null)
{
propertySheetPage =
new ExtendedPropertySheetPage(editingDomain)
{
@Override
public void setSelectionToViewer(List<?> selection)
{
LibraryEditor.this.setSelectionToViewer(selection);
LibraryEditor.this.setFocus();
}

@Override
public void setActionBars(IActionBars actionBars)
{
super.setActionBars(actionBars);
getActionBarContributor().shareGlobalActions(this,
actionBars);
}
};
propertySheetPage.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));
}

return propertySheetPage;
}


>
> How can I specify to my .genmodel to generate EObject implementing one
> of these above interfaces with default implementations.
EMF has an adapter mechanism already; one that includes support for
notification as well.
>
> I have to manually add one of these interfaces to my Ecore generated
> code?
There are definitely automatic ways you could support this, for example
by extending EObjectImpl with something that supports additional
interfaces, and then using that base class in place of EObjectImpl. in
the GenModel Root Extends Class property.

It sounds like it would be a good idea for you to generate the editor
and see how it works...
>
> Regards

--------------080106090400040307000400
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Esteban,<br>
<br>
It's best to use the EMF newsgroup.&nbsp; I've added it to the "to" list of
the reply.<br>
<br>
<br>
Esteban DUGUEPEROUX wrote:
<blockquote cite="mid:gr58jh$g38$1@build.eclipse.org" type="cite">Hi,
<br>
<br>
I post here because I don't know which group is adapted.
<br>
<br>
I have a view componed of a TreeViewer with as input a tree of EObject
from my generated Ecore model.
<br>
I want see properties of my selected item (EObject) of my TreeViewer in
PropertySheet Viewer, then I have added this line :
<br>
<br>
getSite().setSelectionProvider(viewer);
<br>
<br>
but I need that my EObjects implements IAdaptable or IPropertySource
following this article :
<br>
<br>
<a class="moz-txt-link-freetext" href=" http://www.eclipse.org/articles/Article-Properties-View/prop erties-view.html"> http://www.eclipse.org/articles/Article-Properties-View/prop erties-view.html</a>
<br>
</blockquote>
No you don't need that. The generated editor already shows how this is
supported using an AdapterFactoryContentProvider:<small><br>
</small>
<blockquote><small>&nbsp; /**</small><br>
<small>&nbsp;&nbsp; * This accesses a cached version of the property sheet.</small><br>
<small>&nbsp;&nbsp; * &lt;!-- begin-user-doc --&gt;</small><br>
<small>&nbsp;&nbsp; * &lt;!-- end-user-doc --&gt;</small><br>
<small>&nbsp;&nbsp; * @generated</small><br>
<small>&nbsp;&nbsp; */</small><br>
<small>&nbsp; public IPropertySheetPage getPropertySheetPage()</small><br>
<small>&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp; if (propertySheetPage == null)</small><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; propertySheetPage =</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; new ExtendedPropertySheetPage(editingDomain)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; @Override</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public void setSelectionToViewer(List&lt;?&gt;
selection)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LibraryEditor.this.setSelectionToViewer(selection);</small> <br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LibraryEditor.this.setFocus();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; @Override</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public void setActionBars(IActionBars actionBars)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; super.setActionBars(actionBars);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getActionBarContributor().shareGlobalActions(this,
actionBars);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; };</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; propertySheetPage.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));</small><br >
<small>&nbsp;&nbsp;&nbsp; }</small><br>
<br>
<small>&nbsp;&nbsp;&nbsp; return propertySheetPage;</small><br>
<small>&nbsp; }</small><br>
</blockquote>
<br>
<blockquote cite="mid:gr58jh$g38$1@build.eclipse.org" type="cite"><br>
How can I specify to my .genmodel to generate EObject implementing one
of these above interfaces with default implementations.
<br>
</blockquote>
EMF has an adapter mechanism already; one that includes support for
notification as well.<br>
<blockquote cite="mid:gr58jh$g38$1@build.eclipse.org" type="cite"><br>
I have to manually add one of these interfaces to my Ecore generated
code?
<br>
</blockquote>
There are definitely automatic ways you could support this, for example
by extending EObjectImpl with something that supports additional
interfaces, and then using that base class in place of EObjectImpl. in
the GenModel Root Extends Class property.<br>
<br>
It sounds like it would be a good idea for you to generate the editor
and see how it works...<br>
<blockquote cite="mid:gr58jh$g38$1@build.eclipse.org" type="cite"><br>
Regards
<br>
</blockquote>
</body>
</html>

--------------080106090400040307000400--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: IPropertySource for EObject [message #429058 is a reply to message #428949] Tue, 07 April 2009 09:51 Go to previous message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Ed Merks a écrit :
> Esteban,
>
> It's best to use the EMF newsgroup. I've added it to the "to" list of
> the reply.
>
>
> Esteban DUGUEPEROUX wrote:
>> Hi,
>>
>> I post here because I don't know which group is adapted.
>>
>> I have a view componed of a TreeViewer with as input a tree of EObject
>> from my generated Ecore model.
>> I want see properties of my selected item (EObject) of my TreeViewer
>> in PropertySheet Viewer, then I have added this line :
>>
>> getSite().setSelectionProvider(viewer);
>>
>> but I need that my EObjects implements IAdaptable or IPropertySource
>> following this article :
>>
>> http://www.eclipse.org/articles/Article-Properties-View/prop erties-view.html
>>
> No you don't need that. The generated editor already shows how this is
> supported using an AdapterFactoryContentProvider:
>
> /**
> * This accesses a cached version of the property sheet.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> public IPropertySheetPage getPropertySheetPage()
> {
> if (propertySheetPage == null)
> {
> propertySheetPage =
> new ExtendedPropertySheetPage(editingDomain)
> {
> @Override
> public void setSelectionToViewer(List<?> selection)
> {
> LibraryEditor.this.setSelectionToViewer(selection);
> LibraryEditor.this.setFocus();
> }
>
> @Override
> public void setActionBars(IActionBars actionBars)
> {
> super.setActionBars(actionBars);
> getActionBarContributor().shareGlobalActions(this,
> actionBars);
> }
> };
> propertySheetPage.setPropertySourceProvider(new
> AdapterFactoryContentProvider(adapterFactory));
> }
>
> return propertySheetPage;
> }
>
>
>>
>> How can I specify to my .genmodel to generate EObject implementing one
>> of these above interfaces with default implementations.
> EMF has an adapter mechanism already; one that includes support for
> notification as well.
>>
>> I have to manually add one of these interfaces to my Ecore generated
>> code?
> There are definitely automatic ways you could support this, for example
> by extending EObjectImpl with something that supports additional
> interfaces, and then using that base class in place of EObjectImpl. in
> the GenModel Root Extends Class property.
>
> It sounds like it would be a good idea for you to generate the editor
> and see how it works...
>>
>> Regards
Hi Ed,

Thanks for your reply.

I have added the "public Object getAdapter(Class adapter)" method to
fetch my PropertySheetPage. And used a ComposedAdapterFactory
initialized with default ResourceItemProviderAdapterFactory and
XXXItemProviderAdapterFactory from my own model.
My TreeViewer configured with my own AdapterFactoryContentProvider and
AdapterFactoryLabelProvider.
And now it works fine :)

Thanks for your help and for your works in Eclipse.
Previous Topic:[CDO] Query API
Next Topic:EMF Maps and useEquals()
Goto Forum:
  


Current Time: Thu Apr 25 04:59:16 GMT 2024

Powered by FUDForum. Page generated in 0.02620 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top