[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools.emf] Re: use EMF model from GEF
|
- From: Nikolaj Berntsen <nberntsen@xxxxxxxxxxxx>
- Date: Wed, 03 Sep 2003 17:08:19 +0200
- Newsgroups: eclipse.tools.emf
- Organization: EclipseCorner
- User-agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.5b) Gecko/20030827
Frank (or any other EMF-gifted person),
You can access the model from the EditingDomain returned by
getEditingDomain() of the generated editor. The EditingDomain is the central
holder of the model for an Editor. The model objects are retrieved by
calling getResourceSet() on it. After that you can get the children,
properties, etc., by calling adapt() on the editors adapter factory, using
the appropriate adapter type.
Can you be a bit more explicit (until your book [1] arrives .-).
Say I have (in package foo.model)
---- Candybox.java
/** @model */
interface CandyBox extends EObject {
/** @model type="Candy" containment="true"*/
EList getCandy()
}
--- Candy.java
/** @model */
interface Candy extends EObject {
/** @model */
String getType();
}
I have used the generated Editor to create the following XML file (in
meta notation)
<CandyBox>
<Candy type="sugar bomb"/>
<Candy type="wine gum"/>
</CandyBox>
Now, in the generated Editor, I write
ResourceSet foo = getEditingDomain().getResourceSet();
/* Now I imagine I should interpret your answer to tell me to */
Adapter bar = adapterFactory.adapt(XXX,YYY); /* adapterFactory is a
generated variable */
CandyBox goo = bar.ZZZ();
Candy moo = bar.XYZ();
Please tell me if I am out in the woods. Any hints to what XXX,YYY, ZZZ
and XYZ might be would be much appreciated?
XXX I could imagine to be, say, CandyBoxImpl, but that is not visible
from the editor.
YYY I could imagine to be ModelItemProviderAdapterFactory.java
(generated, in .edit)
XYZ I could imagine to be getChild (perhaps with another YYY, than
proposed here).
Thanks,
/\/ikolaj
[1]
I realize that this is a shameless plug, but if you're having trouble
getting your head around all of the framework pieces, our EMF book,
http://www.awprofessional.com/titles/0131425420 , is the best resource.