[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.gef] transforming a tree-like model to a"flat" editpart hierachy

Hi,

I have a problem, which seems really easy but which I can´t solve.

the situation:

I have a tree-like model, a root-Element (e.g. ContentElement) with NodeElements under it. NodeElements can contain other NodeElements as well. Now I want to visualize it.

First I overwrote the getModelChildren()-method of the ContentsElementEditPart like this

public List getModelChildren(){
//returns the direct child nodes of the ContentsNode	
return model.getChildren();
}

the result is, that only the children of the ContentsElement will visualized.

So I overwrote the getModelChildren()-method of the NodeElementEditParts. The result is, that all nodes of the tree are created, but they are visualized within the parent ElementNodes. I would like to have them as children of the ContentElement, so I can visualize a tree with connections and fancy decorators (based on informations within the ElementNodes).

Not satisfied I tried something else:
I overwrote the getModelChildren-method of the ContentsElementEditPart again and collected all child nodes recursivly into a List. (Construction of connections and decorators is done here later, too.) The getModelChildren-method of the ElementNodes has been removed. Now all nodes are visualized within the figure of the ContentsElementEditPart.


So finally I reached the goal, but it seems not to be that clean. Perhaps someone could give me a hint how it could be done more "professional".

I did not find an example, where model elements include elements of the same type (or I did not recognize it :-( )

Many regards

Andreas