Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » TreeViewer with properties view support
TreeViewer with properties view support [message #695238] Mon, 11 July 2011 11:11 Go to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

I have defined a treeviewer by using the follwing lines of code

viewer.setContentProvider(new AdapterFactoryContentProvider(factory));
viewer.setLabelProvider(new AdapterFactoryLabelProvider(factory));


In order to support the properties view I implemented the ISelectionProvider interface specifying this method:

@Override
public ISelection getSelection() {
		
 IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
		
 if (selection.getFirstElement() == null)
   return StructuredSelection.EMPTY; 
		
 IItemPropertySource source = (IItemPropertySource)factory.adapt(selection.getFirstElement(), IItemPropertySource.class);
		
 return new StructuredSelection(new PropertySource(selection.getFirstElement(), source));
}


The problem is that the Properties View is displaying nothing even though the code gets executed. What is missing?

Ralph
Re: TreeViewer with properties view support [message #695381 is a reply to message #695238] Mon, 11 July 2011 15:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Support for the properties viewer works in the generated editor. Have
you done all the things you see there?


On 11/07/2011 4:11 AM, ralph. wrote:
> Hi,
>
> I have defined a treeviewer by using the follwing lines of code
>
>
> viewer.setContentProvider(new AdapterFactoryContentProvider(factory));
> viewer.setLabelProvider(new AdapterFactoryLabelProvider(factory));
>
>
> In order to support the properties view I implemented the
> ISelectionProvider interface specifying this method:
>
>
> @Override
> public ISelection getSelection() {
>
> IStructuredSelection selection =
> (IStructuredSelection)viewer.getSelection();
>
> if (selection.getFirstElement() == null)
> return StructuredSelection.EMPTY;
> IItemPropertySource source =
> (IItemPropertySource)factory.adapt(selection.getFirstElement(),
> IItemPropertySource.class);
>
> return new StructuredSelection(new
> PropertySource(selection.getFirstElement(), source));
> }
>
>
> The problem is that the Properties View is displaying nothing even
> though the code gets executed. What is missing?
>
> Ralph


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: TreeViewer with properties view support [message #695413 is a reply to message #695381] Mon, 11 July 2011 17:12 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

I copied a lot of code from there. Somehow I cannot figure out how the properties view is connected there.

Ralph
Re: TreeViewer with properties view support [message #695542 is a reply to message #695413] Tue, 12 July 2011 00:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Did you implement the adapter support to create a properties view like
what you see in the generated editor?


On 11/07/2011 10:12 AM, ralph. wrote:
> Hi,
>
> I copied a lot of code from there. Somehow I cannot figure out how the
> properties view is connected there.
>
> Ralph


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: TreeViewer with properties view support [message #695610 is a reply to message #695542] Tue, 12 July 2011 06:43 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

do you mean this part?

/**
* This is how the framework determines which interfaces we implement.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(Class key) {
  if (key.equals(IContentOutlinePage.class)) {
    return showOutlineView() ? getContentOutlinePage() : null;
  }
  else if (key.equals(IPropertySheetPage.class)) {
   return getPropertySheetPage();
  }
  else if (key.equals(IGotoMarker.class)) {
   return this;
  }
  else {
   return super.getAdapter(key);
  }
}


But how can I tell the properties view to call this method?

Ralph
Re: TreeViewer with properties view support [message #695633 is a reply to message #695610] Tue, 12 July 2011 07:55 Go to previous message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

using everything related to this method fixed my problems.

Ralph
Previous Topic:Problem binding EMF model to JFace TreeViewer
Next Topic:Adding object to list not result in commandstack change
Goto Forum:
  


Current Time: Fri Apr 19 08:44:39 GMT 2024

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

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

Back to the top