PDA

View Full Version : [2.0 Trunk] Bug in TreeStore when inserting a new item?



ionut.rachita
22 Apr 2009, 2:05 AM
Hi,
I'm trying to insert a new TreeItem at a specific index by modifying the TreeStore. The problem is that the new item is added as a last child instead of the specified position.

The TreeStore has the setMonitorChanges set to true, and when inserting the new item I create a ChangeEvent and call notify:

ChangeEvent evt = new ChangeEvent(Add, this);
evt.setParent(this);
evt.setItem(child);
evt.setIndex(index);
notify(evt);Now, in the TreeStore the onModelChange will execute, and the ChangeEventSource.Add will be chosen. The add method will insert the new child using as index the number of children under the given parent instead of the index from ChangeEvent:

insert(parent, item, getChildCount(parent), addChildren); (TreeStore, line 186).

My question is what is the solution to insert a new treeItem at a specific position? Should the TreeStore be modified so that it takes into consideration the index set in the ChangeEvent?

Regards,
Ionut

sven
27 Apr 2009, 1:22 PM
Fixed in SVN.