[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.emf] Re: use EMF model from GEF

Nikolaj,

getContents().get(0) is the way to access the first root object in a model
document. Since our models are by default all single rooted (XML documents)
its all you ever need to get from the contents to access the entire model.

Frank.


Nikolaj Berntsen wrote:

> Nikolaj Berntsen wrote:
>
> > I would probably like to get some kind of tree view (parent/child) view
> > on my data structure. I can probably use an adapter for this. Overnight
> > I occured to me I might be able to get inspired from the adapter (way of
> > doing things) for the selection viewer.
>
> I managed to get the children from an adapterfactory using the directly
> accessed root:
>
> CandyBox candyBox = (CandyBox)candyResource.getContents().get(0);
> AdapterFactoryContentProvider cp = new
>                 AdapterFactoryContentProvider(adapterFactory);
> Object[] obs = cp.getChildren(candyBox);
>
> Which is 'better' than the direct access, since it gives all children no
> matter the type (my example only had one type, Candy).
>
> Is there a way to get the Root element other than the above way? Or is
> using getContents().get(0) the 'correct' way to start walking your tree
> of data?
>
> Not really important, but I'd like to know.
>
> Cheers,
> /\/ikolaj