Property Sheet is empty when selecting an (EMF-)object in tree viewer using a custom ViewPart [message #988505] |
Fri, 30 November 2012 04:59  |
Eclipse User |
|
|
|
Dear readers,
I have an EMF-based RCP-application that was originally generated using the genmodel-generator. The application thus has EMF.Edit end EMF.Editor components. When I run the application, I basically have an editor and a property sheet. When I select an object in the editor, the property sheet shows its properties, as expected.
Now I added a custom view part that contains a Tree viewer. Essentially the code is as follows:
public class MyCustomViewPart extends ViewPart
(...)
private ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
(...)
public void partActivated(IWorkbenchPartReference arg0) {
(...)
treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
treeViewer.setInput(editingDomain.getResourceSet());
(...)
}
public void createPartControl(Composite parent)
{ (...)
getSite().setSelectionProvider(treeViewer);
(...)
}
When I now select an object in the tree viewer of MyCustomViewPart, the property sheet remains empty. When I activate the editor and select an object in the editor, the property sheet shows the proprieties of the selected objects.
Can anyone please give me a hint why the property sheet remains empty if I select an object in the tree viewer of my MyCustomViewPart?
Thank you very much for any help,
Christoph
|
|
|
Re: Property Sheet is empty when selecting an (EMF-)object in tree viewer using a custom ViewPart [message #988550 is a reply to message #988505] |
Fri, 30 November 2012 07:48   |
Eclipse User |
|
|
|
Christoph,
I would guess that your view part needs to implement ISelectionProvider...
On 30/11/2012 10:59 AM, Christoph Miksovic wrote:
> Dear readers,
>
> I have an EMF-based RCP-application that was originally generated
> using the genmodel-generator. The application thus has EMF.Edit end
> EMF.Editor components. When I run the application, I basically have an
> editor and a property sheet. When I select an object in the editor,
> the property sheet shows its properties, as expected.
> Now I added a custom view part that contains a Tree viewer.
> Essentially the code is as follows:
>
>
> public class MyCustomViewPart extends ViewPart
> (...)
> private ComposedAdapterFactory adapterFactory = new
> ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
> (...)
> public void partActivated(IWorkbenchPartReference arg0) {
> (...)
> treeViewer.setContentProvider(new
> AdapterFactoryContentProvider(adapterFactory));
> treeViewer.setLabelProvider(new
> AdapterFactoryLabelProvider(adapterFactory));
> treeViewer.setInput(editingDomain.getResourceSet());
> (...)
> }
>
> public void createPartControl(Composite parent)
> { (...)
> getSite().setSelectionProvider(treeViewer);
> (...)
> }
>
>
> When I now select an object in the tree viewer of MyCustomViewPart,
> the property sheet remains empty. When I activate the editor and
> select an object in the editor, the property sheet shows the
> proprieties of the selected objects.
>
> Can anyone please give me a hint why the property sheet remains empty
> if I select an object in the tree viewer of my MyCustomViewPart?
>
> Thank you very much for any help,
> Christoph
|
|
|
|
Re: Property Sheet is empty when selecting an (EMF-)object in tree viewer using a custom ViewPart [message #989346 is a reply to message #988857] |
Wed, 05 December 2012 13:36  |
Eclipse User |
|
|
|
Christoph,
Comments below.
On 03/12/2012 2:25 PM, Christoph Miksovic wrote:
> Hello Ed,
> thank you for your reply.
> I thought if would be sufficient if I register the TreeViewer within
> my ViewPart as a selection provider
> (getSite().setSelectionProvider(treeViewer)).
Hmmm. One would hope so yes...
> I also use the standard org.eclipse.ui.views.properties.PropertySheet
> as my property view. And I can also see in the debugger that the
> selectionChanged method on the PropertySheet is invoked when I select
> an (EMF-)element in my TreeViewer of my ViewPart (the selected element
> is contained in the TreeSelection object). But the PropertySheet
> remains empty.
> NB: When I select an element in a View that is based on
> org.eclipse.ui.views.ContentOutline , the properties are visible in
> the PropertySheet.
I see. Note that the generated editor implements getAdapter to create
the appropriate properties view implementation, so you'd need to do that
too for your viewer...
>
> Can you give me some more hints if possible?
Hopefully that's a good hint...
> Thank you very much and cheers,
> Christoph
|
|
|
Powered by
FUDForum. Page generated in 0.07002 seconds