Re: IPropertySource for EObject [message #428949] |
Fri, 03 April 2009 15:31 |
Ed Merks 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. 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> /**</small><br>
<small> * This accesses a cached version of the property sheet.</small><br>
<small> * <!-- begin-user-doc --></small><br>
<small> * <!-- end-user-doc --></small><br>
<small> * @generated</small><br>
<small> */</small><br>
<small> public IPropertySheetPage getPropertySheetPage()</small><br>
<small> {</small><br>
<small> if (propertySheetPage == null)</small><br>
<small> {</small><br>
<small> propertySheetPage =</small><br>
<small> new ExtendedPropertySheetPage(editingDomain)</small><br>
<small> {</small><br>
<small> @Override</small><br>
<small> public void setSelectionToViewer(List<?>
selection)</small><br>
<small> {</small><br>
<small> LibraryEditor.this.setSelectionToViewer(selection);</small> <br>
<small> LibraryEditor.this.setFocus();</small><br>
<small> }</small><br>
<br>
<small> @Override</small><br>
<small> public void setActionBars(IActionBars actionBars)</small><br>
<small> {</small><br>
<small> super.setActionBars(actionBars);</small><br>
<small> getActionBarContributor().shareGlobalActions(this,
actionBars);</small><br>
<small> }</small><br>
<small> };</small><br>
<small> propertySheetPage.setPropertySourceProvider(new
AdapterFactoryContentProvider(adapterFactory));</small><br >
<small> }</small><br>
<br>
<small> return propertySheetPage;</small><br>
<small> }</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/
|
|
|
|
Powered by
FUDForum. Page generated in 0.02620 seconds