TreeModel: Adding Before and After in the Children

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

TreeModel: Adding Before and After in the Children

Eric Taylor
Hello Forum,

I would like to be able to work directly upon the children of a node in
order to #add:after: and #add:before.  My #add:after: method looks like
this:

>>#add: anObject after: anotherObject

| siblings |
siblings := commands childrenOf: (commands parentOf: anotherObject)
siblings add: anObject after: anotherObject

where commands is a variable initialized as

commands := TreeModel new.

The bit of code above works fine, but I need a way to get these children
back into the tree under <commands parentOf: anotherObject>.

What I'm looking for is the Eiffel equivalent of a CURSOR_TREE, where I
can request a cursor (on the nodes) or a child_cursor (on the children
of a targeted node), and then insert a child_item at the child_cursor.

I don't mind subclassing TreeModel or VirtualTreeModel to create an
active structure, but I just want to make sure I'm not missing something
and setting out to develop a functionality that's already there.

Cheers,

Eric


Reply | Threaded
Open this post in threaded view
|

Re: TreeModel: Adding Before and After in the Children

Chris Uppal-3
Eric,

> I don't mind subclassing TreeModel or VirtualTreeModel to create an
> active structure, but I just want to make sure I'm not missing something
> and setting out to develop a functionality that's already there.

I don't think you are missing anything.

    -- chris