Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Databinding/EMF] Double entries in TreeViewer ->MapChangeEvent result set incorrect.
[Databinding/EMF] Double entries in TreeViewer ->MapChangeEvent result set incorrect. [message #743202] Fri, 21 October 2011 08:11 Go to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hi,

Sometimes (It's intermittent) I see double entries appear when adding an
item to a treeviewer which is "databinded". Sometime the entry simply
doesn't appear. A refresh usually solves the problem.

I notice the IMapChangeListener, MapChangeEvent
event.diff.getChangedKeys() returns an empty resultset, so the code to

fireLabelProviderChanged(newEvent) is never called.


In my code below, I add IObservableMap entries for which we add the
IMapChangeListener.


Why is the result set empty, while the listener is called?
Is there any relation to this issue, and the StrutureAdvisor or
TreeFactory ?

rgds Christophe


This is the databinding code. (EMF) to the viewer.
***************************************************

EMFDataBindingContext bindingContext = new EMFDataBindingContext();

ObservableListTreeContentProvider cp = new
ObservableListTreeContentProvider(
new NodeTypeTreeFactoryImpl(editingService.getEditingDomain()),
new NodeTypeTreeStructureAdvisorImpl());
nodeTypeTreeViewer.setContentProvider(cp);
IObservableSet set = cp.getKnownElements();

List<IObservableMap> mapList = Lists.newArrayList();

mapList.add(EMFEditProperties.value(editingService.getEditingDomain(),
LibraryPackage.Literals.NODE_TYPE__NAME).observeDetail(set));

mapList.add(EMFEditProperties.value(editingService.getEditingDomain(),
LibraryPackage.Literals.NODE_TYPE__EQUIPMENTS).observeDetail(set));

mapList.add(EMFEditProperties.value(editingService.getEditingDomain(),
LibraryPackage.Literals.NODE_TYPE__FUNCTIONS).observeDetail(set));

mapList.add(EMFProperties
.value(LibraryPackage.Literals.COMPONENT__NAME).observeDetail(
set));


mapList.add(EMFProperties.value(
LibraryPackage.Literals.EQUIPMENT__EQUIPMENT_CODE)
.observeDetail(set));

IObservableMap[] map = new IObservableMap[mapList.size()];
mapList.toArray(map);

nodeTypeTreeViewer.setLabelProvider(new NodeTypeTreeLabelProvider(map));
IEMFListProperty projects = EMFEditProperties.resource(editingService
.getEditingDomain());

IObservableList nodeTypeObservableList = projects
.observe(nodeTypeResource);
nodeTypeTreeViewer.setInput(nodeTypeObservableList);
Re: [Databinding/EMF] Double entries in TreeViewer -&gt;MapChangeEvent result set incorrect. [message #743219 is a reply to message #743202] Fri, 21 October 2011 08:24 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Entry doubleing must have it's reason in StructureAdvisor or the
underlying ObservableTreeContentProvider. The map stuff is only needed
for label-updateing.

Tom

Am 21.10.11 10:11, schrieb Christophe Bouhier:
> Hi,
>
> Sometimes (It's intermittent) I see double entries appear when adding an
> item to a treeviewer which is "databinded". Sometime the entry simply
> doesn't appear. A refresh usually solves the problem.
>
> I notice the IMapChangeListener, MapChangeEvent
> event.diff.getChangedKeys() returns an empty resultset, so the code to
>
> fireLabelProviderChanged(newEvent) is never called.
>
>
> In my code below, I add IObservableMap entries for which we add the
> IMapChangeListener.
>
>
> Why is the result set empty, while the listener is called?
> Is there any relation to this issue, and the StrutureAdvisor or
> TreeFactory ?
>
> rgds Christophe
>
>
> This is the databinding code. (EMF) to the viewer.
> ***************************************************
>
> EMFDataBindingContext bindingContext = new EMFDataBindingContext();
>
> ObservableListTreeContentProvider cp = new
> ObservableListTreeContentProvider(
> new
> NodeTypeTreeFactoryImpl(editingService.getEditingDomain()),
> new NodeTypeTreeStructureAdvisorImpl());
> nodeTypeTreeViewer.setContentProvider(cp);
> IObservableSet set = cp.getKnownElements();
>
> List<IObservableMap> mapList = Lists.newArrayList();
>
>
> mapList.add(EMFEditProperties.value(editingService.getEditingDomain(),
>
> LibraryPackage.Literals.NODE_TYPE__NAME).observeDetail(set));
>
>
> mapList.add(EMFEditProperties.value(editingService.getEditingDomain(),
>
> LibraryPackage.Literals.NODE_TYPE__EQUIPMENTS).observeDetail(set));
>
>
> mapList.add(EMFEditProperties.value(editingService.getEditingDomain(),
>
> LibraryPackage.Literals.NODE_TYPE__FUNCTIONS).observeDetail(set));
>
> mapList.add(EMFProperties
>
> .value(LibraryPackage.Literals.COMPONENT__NAME).observeDetail(
> set));
>
>
> mapList.add(EMFProperties.value(
> LibraryPackage.Literals.EQUIPMENT__EQUIPMENT_CODE)
> .observeDetail(set));
>
> IObservableMap[] map = new IObservableMap[mapList.size()];
> mapList.toArray(map);
>
> nodeTypeTreeViewer.setLabelProvider(new
> NodeTypeTreeLabelProvider(map));
> IEMFListProperty projects =
> EMFEditProperties.resource(editingService
> .getEditingDomain());
>
> IObservableList nodeTypeObservableList = projects
> .observe(nodeTypeResource);
> nodeTypeTreeViewer.setInput(nodeTypeObservableList);
Re: [Databinding/EMF] Double entries in TreeViewer -&gt;MapChangeEvent result set incorrect. [message #743233 is a reply to message #743219] Fri, 21 October 2011 08:46 Go to previous message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
On 21-10-11 10:24, Tom Schindl wrote:
> Entry doubleing must have it's reason in StructureAdvisor or the
> underlying ObservableTreeContentProvider. The map stuff is only needed
> for label-updateing.
>
Thanks Tom, I spotted the problem. Actually it was two problems.

1) Double entries: My StructureAdvisor was not correct in returning
public Boolean hasChildren(Object element)

2) No entries:

A) When I add a new item, I right click on the parent, which gives me
the ChildCreator Menu. So when adding the child the parent is selected,
and the CreateChildCommand works.

B) If I right-click again, and select to create a new child item, the
CreateChildCommand can't execute as the selection is not set, as A)
caused the CreateChildAction to have no selection somehow. (Altough in
the viewer it seems selected). I get a similar misbehaviour with the
"Paste" command.


So I need to explicitly left click on the parent first, and then invoke
the right-click subsequently. Remembering correctly, I believe the
emf.edit command should cater for this, but in my case it doesn't work.
Did I accidently break something in emf.edit, or is this a known issue?

thank you.



> Tom
>
> Am 21.10.11 10:11, schrieb Christophe Bouhier:
>> Hi,
>>
>> Sometimes (It's intermittent) I see double entries appear when adding an
>> item to a treeviewer which is "databinded". Sometime the entry simply
>> doesn't appear. A refresh usually solves the problem.
>>
>> I notice the IMapChangeListener, MapChangeEvent
>> event.diff.getChangedKeys() returns an empty resultset, so the code to
>>
>> fireLabelProviderChanged(newEvent) is never called.
>>
>>
>> In my code below, I add IObservableMap entries for which we add the
>> IMapChangeListener.
>>
>>
>> Why is the result set empty, while the listener is called?
>> Is there any relation to this issue, and the StrutureAdvisor or
>> TreeFactory ?
>>
>> rgds Christophe
>>
>>
>> This is the databinding code. (EMF) to the viewer.
>> ***************************************************
>>
>> EMFDataBindingContext bindingContext = new EMFDataBindingContext();
>>
>> ObservableListTreeContentProvider cp = new
>> ObservableListTreeContentProvider(
>> new
>> NodeTypeTreeFactoryImpl(editingService.getEditingDomain()),
>> new NodeTypeTreeStructureAdvisorImpl());
>> nodeTypeTreeViewer.setContentProvider(cp);
>> IObservableSet set = cp.getKnownElements();
>>
>> List<IObservableMap> mapList = Lists.newArrayList();
>>
>>
>> mapList.add(EMFEditProperties.value(editingService.getEditingDomain(),
>>
>> LibraryPackage.Literals.NODE_TYPE__NAME).observeDetail(set));
>>
>>
>> mapList.add(EMFEditProperties.value(editingService.getEditingDomain(),
>>
>> LibraryPackage.Literals.NODE_TYPE__EQUIPMENTS).observeDetail(set));
>>
>>
>> mapList.add(EMFEditProperties.value(editingService.getEditingDomain(),
>>
>> LibraryPackage.Literals.NODE_TYPE__FUNCTIONS).observeDetail(set));
>>
>> mapList.add(EMFProperties
>>
>> .value(LibraryPackage.Literals.COMPONENT__NAME).observeDetail(
>> set));
>>
>>
>> mapList.add(EMFProperties.value(
>> LibraryPackage.Literals.EQUIPMENT__EQUIPMENT_CODE)
>> .observeDetail(set));
>>
>> IObservableMap[] map = new IObservableMap[mapList.size()];
>> mapList.toArray(map);
>>
>> nodeTypeTreeViewer.setLabelProvider(new
>> NodeTypeTreeLabelProvider(map));
>> IEMFListProperty projects =
>> EMFEditProperties.resource(editingService
>> .getEditingDomain());
>>
>> IObservableList nodeTypeObservableList = projects
>> .observe(nodeTypeResource);
>> nodeTypeTreeViewer.setInput(nodeTypeObservableList);
>
Previous Topic:Null Pointer Exception during drag and drop in emf editor: appeared in 2.7
Next Topic:Subtyping Ecore classes
Goto Forum:
  


Current Time: Thu Apr 25 13:40:54 GMT 2024

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

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

Back to the top