*
* @param item the item to be added
* @param index index at which the specified element is to be inserted
*/
public void add(TreeItem item, int index) {
TreeEvent te = new TreeEvent(tree);
te.setParent(this);
te.setItem(item);
te.setIndex(index);
if (fireEvent(Events.BeforeAdd, te)) {
if (item.parentItem != null && item.parentItem != this) {
item.parentItem.remove(item);
} else if (item.parentItem != null && item.parentItem == parentItem) {
children.remove(item);