|
Re: Virtual Nodes in TreeViewer based on EMF [message #1015332 is a reply to message #1015262] |
Thu, 28 February 2013 09:29 |
Christophe Bouhier Messages: 937 Registered: July 2009 |
Senior Member |
|
|
On 28-02-13 03:09, Julien S wrote:
> Hi,
>
> I made a TreeViewer based on EMF model. It's a simple model i have an
> EClass project and an EClass dependencies with aggregation between the
> both.
>
> I'm able to display a tree like this :
>
> |--> Project 1
> |
> |--> dependency1
> |--> dependency2
>
> it works fine. But what i want to do is to have a virtual node between
> project and dependency like this :
>
> |--> Project 1
> |--> Project Dependencies (virtual node)
> |--> dependency1
> |--> dependency2
>
> But i dont know how to add "project dependencies" node WITHOUT modify my
> EMF model.
>
I think it starts with the TreeStructureAdvisor. This tells which nodes
has children, then IObservableFactory should return an observable for
the parent of the virtual node, which can produce the children. This is
the tricky part, as the Virtual node is not in the model Hierarchy, so
you would need to fake it somehow, perhaps a ComputedList/Set would do
the trick? It could return a collection of children representing the
virtual node.(Which I assume is a POJO?). For the POJO virtual node, you
could do the same, but it would then hook in to your Model hierarchy
(The real children of the parent).
It's a bit of out-loud thinking, not trialed and proved, but could
perhaps help you a bit?
Cheers Christophe
> My tree is based on ObservableListTreeContentProvider
>
> ObservableListTreeContentProvider lCp = new
> ObservableListTreeContentProvider(
> new ProjectTreeFactory(), new
> ProjectTreeStructureAdvisor());
>
> And a factory like this :
>
> public class ProjectTreeFactory implements IObservableFactory {
> private final IEMFListProperty inputsProp = EMFProperties
> .list(ModelPackage.Literals.PROJECT_DEPEN);
>
> @Override
> public IObservable createObservable(Object target) {
> if (target instanceof IObservable) {
> return (IObservable) target;
> } else if (target instanceof Project) {
> return inputsProp.observe(target);
> }
> return null;
> }
> }
>
> I have to add something in my factory ? With a content provider we have
> just to add a Children to the method getChildren but i dont know how it
> works with IObservableFactory.
>
> Thanks for any help.
>
>
>
>
|
|
|
Re: Virtual Nodes in TreeViewer based on EMF [message #1015609 is a reply to message #1015332] |
Fri, 01 March 2013 11:15 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Take a look at E4-XMI-Editor code it produces virtual nodes. It is part
of the e4.tools repo.
Tom
Am 28.02.13 10:29, schrieb Christophe Bouhier:
> On 28-02-13 03:09, Julien S wrote:
>> Hi,
>>
>> I made a TreeViewer based on EMF model. It's a simple model i have an
>> EClass project and an EClass dependencies with aggregation between the
>> both.
>>
>> I'm able to display a tree like this :
>>
>> |--> Project 1
>> |
>> |--> dependency1
>> |--> dependency2
>>
>> it works fine. But what i want to do is to have a virtual node between
>> project and dependency like this :
>>
>> |--> Project 1
>> |--> Project Dependencies (virtual node)
>> |--> dependency1
>> |--> dependency2
>>
>> But i dont know how to add "project dependencies" node WITHOUT modify my
>> EMF model.
>>
>
>
> I think it starts with the TreeStructureAdvisor. This tells which nodes
> has children, then IObservableFactory should return an observable for
> the parent of the virtual node, which can produce the children. This is
> the tricky part, as the Virtual node is not in the model Hierarchy, so
> you would need to fake it somehow, perhaps a ComputedList/Set would do
> the trick? It could return a collection of children representing the
> virtual node.(Which I assume is a POJO?). For the POJO virtual node, you
> could do the same, but it would then hook in to your Model hierarchy
> (The real children of the parent).
>
> It's a bit of out-loud thinking, not trialed and proved, but could
> perhaps help you a bit?
>
> Cheers Christophe
>
>
>
>> My tree is based on ObservableListTreeContentProvider
>>
>> ObservableListTreeContentProvider lCp = new
>> ObservableListTreeContentProvider(
>> new ProjectTreeFactory(), new
>> ProjectTreeStructureAdvisor());
>>
>> And a factory like this :
>>
>> public class ProjectTreeFactory implements IObservableFactory {
>> private final IEMFListProperty inputsProp = EMFProperties
>> .list(ModelPackage.Literals.PROJECT_DEPEN);
>>
>> @Override
>> public IObservable createObservable(Object target) {
>> if (target instanceof IObservable) {
>> return (IObservable) target;
>> } else if (target instanceof Project) {
>> return inputsProp.observe(target);
>> }
>> return null;
>> }
>> }
>>
>> I have to add something in my factory ? With a content provider we have
>> just to add a Children to the method getChildren but i dont know how it
>> works with IObservableFactory.
>>
>> Thanks for any help.
>>
>>
>>
>>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.02056 seconds