Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » TreeViewer is not updating as exected (Just one eobject reference label is notified if the relevant content changes. Others are not)
TreeViewer is not updating as exected [message #1448871] Mon, 20 October 2014 15:01 Go to next message
Phil Wim is currently offline Phil WimFriend
Messages: 89
Registered: October 2013
Member
My Treeviewer shows a hierarchy of non-containment references of eobjects. The actual eobject is saved to rootContent. The eobject has multiple references which are shown in the treeviewer. So the eobject can appear more than one time.

If I change the content of the eobject which affects the label to change I expect the label to change in all references. In my environment (RAP, CDO) only the last attached or opened reference will be updated. All others stay as they were. But If I reload, they all have the new label.

Is that the expected behavior?

This is my code:
  FilteredTree filteredTree = new FilteredTree(parent, SWT.BORDER, new PatternFilter(), false);
	  viewer = filteredTree.getViewer(); 	  
			AdapterFactoryLabelProvider labelProvider = 
			   new AdapterFactoryLabelProvider(this.adapterFactory);
			
			AdapterFactoryContentProvider contentProvider = 
			   new AdapterFactoryContentProvider(this.adapterFactory);
			viewer.setContentProvider(contentProvider);			
			viewer.setLabelProvider(labelProvider);
			viewer.setInput(CDOProvider.getInstance().getContainer ());

Re: TreeViewer is not updating as exected [message #1449248 is a reply to message #1448871] Tue, 21 October 2014 04:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30372
Registered: July 2009
Senior Member
Phil,

Comments below.

On 20/10/2014 5:01 PM, Phil Wim wrote:
> My Treeviewer shows a hierarchy of non-containment references of
> eobjects. The actual eobject is saved to rootContent. The eobject has
> multiple references which are shown in the treeviewer. So the eobject
> can appear more than one time.
Did you achieve this by modifying the GenFeatures of that object to set
Children and Notify to true?
> If I change the content of the eobject which affects the label to
> change I expect the label to change in all references. In my
> environment (RAP, CDO) only the last attached or opened reference will
> be updated. All others stay as they were. But If I reload, they all
> have the new label.
Check what's happening in
org.eclipse.emf.edit.provider.ItemProviderAdapter.createWrapper(EObject,
EStructuralFeature, Object, int) for the object with those
non-containment "children" references. It should be creating wrappers
for this to work properly. Most likely you just need to specialize
org.eclipse.emf.edit.provider.ItemProviderAdapter.isWrappingNeeded(Object)
to return true.
>
> Is that the expected behavior?
>
> This is my code:
> FilteredTree filteredTree = new FilteredTree(parent, SWT.BORDER, new
> PatternFilter(), false);
> viewer = filteredTree.getViewer(); AdapterFactoryLabelProvider
> labelProvider = new
> AdapterFactoryLabelProvider(this.adapterFactory);
>
> AdapterFactoryContentProvider contentProvider =
> new AdapterFactoryContentProvider(this.adapterFactory);
> viewer.setContentProvider(contentProvider);
> viewer.setLabelProvider(labelProvider);
> viewer.setInput(CDOProvider.getInstance().getContainer ());
>
Re: TreeViewer is not updating as exected [message #1449377 is a reply to message #1448871] Tue, 21 October 2014 09:04 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6440
Registered: July 2009
Senior Member
Hi

You will find that the Sample Ecore Model Editor can display stale
labels, most commonly after changing an inheritance.

This seems inevitable, unless the Tree Editor is able to analyze all the
code that contributes to the displayed labels.

In the past, when I have cared, I have set up my own Notifier listeners
so that the refreshes occur automatically. Perhaps Ed M can identify
tooling or hooks that facilitate this.

[This automated analysis is much easier when the code to be analyzed is
written in OCL, and while there is an OCL Impact Analyzer, we have yet
to produce a cookbook example of how this use case could be handled.]

Regards

Ed Willink


On 20/10/2014 16:01, Phil Wim wrote:
> My Treeviewer shows a hierarchy of non-containment references of
> eobjects. The actual eobject is saved to rootContent. The eobject has
> multiple references which are shown in the treeviewer. So the eobject
> can appear more than one time.
> If I change the content of the eobject which affects the label to change
> I expect the label to change in all references. In my environment (RAP,
> CDO) only the last attached or opened reference will be updated. All
> others stay as they were. But If I reload, they all have the new label.
>
> Is that the expected behavior?
>
> This is my code:
> FilteredTree filteredTree = new FilteredTree(parent, SWT.BORDER, new
> PatternFilter(), false);
> viewer = filteredTree.getViewer();
> AdapterFactoryLabelProvider labelProvider = new
> AdapterFactoryLabelProvider(this.adapterFactory);
>
> AdapterFactoryContentProvider contentProvider =
> new AdapterFactoryContentProvider(this.adapterFactory);
> viewer.setContentProvider(contentProvider);
> viewer.setLabelProvider(labelProvider);
> viewer.setInput(CDOProvider.getInstance().getContainer ());
>
Re: TreeViewer is not updating as exected [message #1449404 is a reply to message #1449377] Tue, 21 October 2014 09:57 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30372
Registered: July 2009
Senior Member
Ed,

Comments below.

On 21/10/2014 11:04 AM, Ed Willink wrote:
> Hi
>
> You will find that the Sample Ecore Model Editor can display stale
> labels, most commonly after changing an inheritance.
That's a different problem as far as I can tell. The problem you
describe is related to the fact that the label of a node is computed
from information that involves following references. In Phil's case,
it's apparently a problem that he's showing the same object more the
once in the tree without wrappers. The wrappers would take care of
updating all occurrences.
>
> This seems inevitable, unless the Tree Editor is able to analyze all
> the code that contributes to the displayed labels.
Yes, if the label is derived from information other than direct features
of the object (which properly notify), it won't know about changes that
happen to other objects.
>
> In the past, when I have cared, I have set up my own Notifier
> listeners so that the refreshes occur automatically. Perhaps Ed M can
> identify tooling or hooks that facilitate this.
If I were made of spare time. :-P
>
> [This automated analysis is much easier when the code to be analyzed
> is written in OCL, and while there is an OCL Impact Analyzer, we have
> yet to produce a cookbook example of how this use case could be handled.]
Yes, or if one defined the model with IncQuery and defined derived
features for the labels; such query-defined features will produce
notifications just like non-derived features.
>
> Regards
>
> Ed Willink
>
>
> On 20/10/2014 16:01, Phil Wim wrote:
>> My Treeviewer shows a hierarchy of non-containment references of
>> eobjects. The actual eobject is saved to rootContent. The eobject has
>> multiple references which are shown in the treeviewer. So the eobject
>> can appear more than one time.
>> If I change the content of the eobject which affects the label to change
>> I expect the label to change in all references. In my environment (RAP,
>> CDO) only the last attached or opened reference will be updated. All
>> others stay as they were. But If I reload, they all have the new label.
>>
>> Is that the expected behavior?
>>
>> This is my code:
>> FilteredTree filteredTree = new FilteredTree(parent, SWT.BORDER, new
>> PatternFilter(), false);
>> viewer = filteredTree.getViewer();
>> AdapterFactoryLabelProvider labelProvider = new
>> AdapterFactoryLabelProvider(this.adapterFactory);
>>
>> AdapterFactoryContentProvider contentProvider =
>> new AdapterFactoryContentProvider(this.adapterFactory);
>> viewer.setContentProvider(contentProvider);
>> viewer.setLabelProvider(labelProvider);
>> viewer.setInput(CDOProvider.getInstance().getContainer ());
>>
>
Re: TreeViewer is not updating as exected [message #1449412 is a reply to message #1449404] Tue, 21 October 2014 10:12 Go to previous messageGo to next message
Phil Wim is currently offline Phil WimFriend
Messages: 89
Registered: October 2013
Member
Guys, thanks for your quick response.

Ed M, yes i did change notify and children gen-feature.

Even if I'm not fully emf- terminology save I'm glad that Ed M got my question right.

Indeed, I'm showing the same eobject more than once in a treeviewer. I'll give the wrapper a try.

Thanks a lot!
Re: TreeViewer is not updating as exected [message #1451816 is a reply to message #1449412] Fri, 24 October 2014 10:21 Go to previous message
Phil Wim is currently offline Phil WimFriend
Messages: 89
Registered: October 2013
Member
Hey,

as simple as you said. I override isWrappingNeeded to return true. It's working as expected.

Thanks!


Previous Topic:NotificationImpl.wasSet() ignores the feature default value when it's null
Next Topic:[CDO] Hacking CDO to add an ability to search for commits affecting eObject or it's containments
Goto Forum:
  


Current Time: Sun Aug 25 07:47:41 GMT 2019

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

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

Back to the top