Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Tree Viewer Input
Tree Viewer Input [message #424143] Fri, 17 October 2008 08:50 Go to next message
Bogdan Nic. is currently offline Bogdan Nic.Friend
Messages: 3
Registered: July 2009
Junior Member
I am trying to build a TreeViewer for a Eclipse Application which uses EMF.
I wrote this code:
AgentiAdapterFactory myAdapterFactory= new AgentiAdapterFactory();
TreeViewer treeViewer = new TreeViewer(parent,SWT.MULTI | SWT.H_SCROLL |
SWT.V_SCROLL);
treeViewer.setContentProvider(new
AdapterFactoryContentProvider(myAdapterFactory));
treeViewer.setLabelProvider(new
AdapterFactoryLabelProvider(myAdapterFactory));

And also i tryed a few solutions for treeViewer.setInput() but none of
them worked correctly.I only get a small square with nothing in it.My EMF
class is called ContContabil and i'm trying to display all ContContabil-s.
Has anybody got a solution for my problem? Thanks in advance.

PS: Should i use an EMFObservable???like this...:
treeViewer.setInput(EMFObservables.observeList(Realm.getDefa ult(),
contContabil,
AgentiPackage.Literals.CONT_CONTABIL__SIMBOL));
Re: Tree Viewer Input [message #424145 is a reply to message #424143] Fri, 17 October 2008 09:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Bogdan,

Comments below.

Bogdan Nic. wrote:

> I am trying to build a TreeViewer for a Eclipse Application which uses EMF.
> I wrote this code:
> AgentiAdapterFactory myAdapterFactory= new AgentiAdapterFactory();
> TreeViewer treeViewer = new TreeViewer(parent,SWT.MULTI | SWT.H_SCROLL |
> SWT.V_SCROLL);
> treeViewer.setContentProvider(new
> AdapterFactoryContentProvider(myAdapterFactory));
> treeViewer.setLabelProvider(new
> AdapterFactoryLabelProvider(myAdapterFactory));

> And also i tryed a few solutions for treeViewer.setInput() but none of
> them worked correctly.

What did you try to set as the input? For the above to work, it would have
to be an instance of the Agenti model. Also, I'm pretty sure you meant to
use AgentiItemProviderAdapterFactory...

> I only get a small square with nothing in it.My EMF
> class is called ContContabil and i'm trying to display all ContContabil-s.
> Has anybody got a solution for my problem? Thanks in advance.

Looking closely at what the generated editor does is probably a good idea.

> PS: Should i use an EMFObservable???like this...:
> treeViewer.setInput(EMFObservables.observeList(Realm.getDefa ult(),
> contContabil,
> AgentiPackage.Literals.CONT_CONTABIL__SIMBOL));

I'm not sure how the data binding support for tree works.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Tree Viewer Input [message #424146 is a reply to message #424145] Fri, 17 October 2008 09:16 Go to previous messageGo to next message
Bogdan Nic. is currently offline Bogdan Nic.Friend
Messages: 3
Registered: July 2009
Junior Member
> Bogdan Nic. wrote:

>> I am trying to build a TreeViewer for a Eclipse Application which uses EMF.
>> I wrote this code:
>> AgentiAdapterFactory myAdapterFactory= new AgentiAdapterFactory();
>> TreeViewer treeViewer = new TreeViewer(parent,SWT.MULTI | SWT.H_SCROLL |
>> SWT.V_SCROLL);
>> treeViewer.setContentProvider(new
>> AdapterFactoryContentProvider(myAdapterFactory));
>> treeViewer.setLabelProvider(new
>> AdapterFactoryLabelProvider(myAdapterFactory));

>> And also i tryed a few solutions for treeViewer.setInput() but none of
>> them worked correctly.

> What did you try to set as the input? For the above to work, it would have
> to be an instance of the Agenti model. Also, I'm pretty sure you meant to
> use AgentiItemProviderAdapterFactory...

I've changed AgentiAdapterFactory to AgentiItemProviderAdapterFactory.
Could you give me a suggestion for an input....Should i get somehow all
ContContabil items from my database and put them as an input or what
should I have to do??Thanks

>> I only get a small square with nothing in it.My EMF
>> class is called ContContabil and i'm trying to display all ContContabil-s.
>> Has anybody got a solution for my problem? Thanks in advance.

> Looking closely at what the generated editor does is probably a good idea.

I don't understand what's the generated editor?Does an editor generated
automaticaly by EMF for ContContabil exist?
Re: Tree Viewer Input [message #424147 is a reply to message #424146] Fri, 17 October 2008 09:33 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Bogdan,

Comments below.

Bogdan Nic. wrote:

>> Bogdan Nic. wrote:

>>> I am trying to build a TreeViewer for a Eclipse Application which uses EMF.
>>> I wrote this code:
>>> AgentiAdapterFactory myAdapterFactory= new AgentiAdapterFactory();
>>> TreeViewer treeViewer = new TreeViewer(parent,SWT.MULTI | SWT.H_SCROLL |
>>> SWT.V_SCROLL);
>>> treeViewer.setContentProvider(new
>>> AdapterFactoryContentProvider(myAdapterFactory));
>>> treeViewer.setLabelProvider(new
>>> AdapterFactoryLabelProvider(myAdapterFactory));

>>> And also i tryed a few solutions for treeViewer.setInput() but none of
>>> them worked correctly.

>> What did you try to set as the input? For the above to work, it would have
>> to be an instance of the Agenti model. Also, I'm pretty sure you meant to
>> use AgentiItemProviderAdapterFactory...

> I've changed AgentiAdapterFactory to AgentiItemProviderAdapterFactory.
> Could you give me a suggestion for an input....Should i get somehow all
> ContContabil items from my database and put them as an input or what
> should I have to do??Thanks

When you set an object as input to a tree, the children of that object are
what's shown in the actual view. You can create an new ItemProvider with
a list of objects to create a "fake" object to act as input.

>>> I only get a small square with nothing in it.My EMF
>>> class is called ContContabil and i'm trying to display all ContContabil-s.
>>> Has anybody got a solution for my problem? Thanks in advance.

>> Looking closely at what the generated editor does is probably a good idea.

> I don't understand what's the generated editor?

When you invoke Generate Editor Code, you end up with an editor that has
an example of what you're trying to do. All of the tutorials on the
documentation page show how to do this...

> Does an editor generated
> automaticaly by EMF for ContContabil exist?

The generated editor will be able to manipulate any instance of your
generated model...


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Tree Viewer Input [message #424149 is a reply to message #424145] Fri, 17 October 2008 10:16 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi Bogdan,

Your setup doesn't make sense you need to decide between 2 possibilities.

a) use EMF and the provided AdapterFactoryContentProvider
b) use Databinding and the ObservableTreeContentProvider

Currently you are passing an IObservableList as input and
AdapterFactoryContentProvider has no idea what to do with this type of
object because it expects some EObject.

If you need an example how to setup a TreeViewer with EMF and
Databinding you can take a look at my Soccer-Example-App [1,2]. Please
make sure that you are using Databinding 3.4.1 and maybe you also need
the patch [3] applied (Ed can we take a look at it and apply it to the
code base?) when you want to use an ObservableMapLabelProvider [4] like
shown in the example but your objects don't inherit from a common base
class.

Tom

[1] http://tom-eclipse-dev.blogspot.com/2008/09/exploring-new-te chnologies-part-of.html
[2] http://publicsvn.bestsolution.at/repos/java/examples/EMF-Dat abinding/at.bestsolution.soccer.ui.associationadmin/src/at/b estsolution/soccer/ui/associationadmin/AssociationAdministra tionViewPart.java
[3]https://bugs.eclipse.org/bugs/show_bug.cgi?id=248069
[4] http://publicsvn.bestsolution.at/repos/java/examples/EMF-Dat abinding/at.bestsolution.soccer.ui.common/src/at/bestsolutio n/soccer/ui/common/viewers/ObservableColumnLabelProvider.jav a

Ed Merks schrieb:
> Bogdan,
>
> Comments below.
>
> Bogdan Nic. wrote:
>
>> I am trying to build a TreeViewer for a Eclipse Application which uses
>> EMF.
>> I wrote this code:
>> AgentiAdapterFactory myAdapterFactory= new AgentiAdapterFactory();
>> TreeViewer treeViewer = new TreeViewer(parent,SWT.MULTI | SWT.H_SCROLL
>> | SWT.V_SCROLL);
>> treeViewer.setContentProvider(new
>> AdapterFactoryContentProvider(myAdapterFactory));
>> treeViewer.setLabelProvider(new
>> AdapterFactoryLabelProvider(myAdapterFactory));
>
>> And also i tryed a few solutions for treeViewer.setInput() but none of
>> them worked correctly.
>
> What did you try to set as the input? For the above to work, it would
> have to be an instance of the Agenti model. Also, I'm pretty sure you
> meant to use AgentiItemProviderAdapterFactory...
>
>> I only get a small square with nothing in it.My EMF class is called
>> ContContabil and i'm trying to display all ContContabil-s. Has anybody
>> got a solution for my problem? Thanks in advance.
>
> Looking closely at what the generated editor does is probably a good idea.
>
>> PS: Should i use an EMFObservable???like this...:
>> treeViewer.setInput(EMFObservables.observeList(Realm.getDefa ult(),
>> contContabil,
>> AgentiPackage.Literals.CONT_CONTABIL__SIMBOL));
>
> I'm not sure how the data binding support for tree works.
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Previous Topic:[CD] [Teneo] could not update query
Next Topic:Question regarding the EMF Eclipse Forms Editor
Goto Forum:
  


Current Time: Thu Sep 26 00:07:17 GMT 2024

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

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

Back to the top