Mapping model elements to EditParts [message #77423] |
Tue, 29 April 2003 19:04  |
Eclipse User |
|
|
|
The editor I'm building uses nested edit parts as in the Logic Editor, but I
need to arrange them in a particular order (i.e. I need to manage their
layout.) I'm looking for a sanctioned way to get the EditPart corresponding
with a particular model element.
As far as I can tell, there's no getEditPart(Object model) function on
AbstractEditPart; instead, AbstractEditPart builds and discards a private
Map each time refreshVisuals() is called. I could do what refreshVisuals()
does -- walk the list of child edit parts, calling getModel() on each -- but
I was wondering if there's a "sanctioned" way to get at the model
element-to-EditPart mapping.
If there isn't a built-in method, please consider this a 2.2 feature
request. :)
On a related note, I'm a little bothered by refreshVisuals() depending on
getModel() to build its map. There's nothing in the API contract that
indicates a model _must_ be set on an EditPart, only that it's used "by an
EditPartFactory when creating an EditPart" (from the Javadoc). Since you
can't force someone to set the model (e.g. by making it a parameter to the
constructor) without breaking existing APIs, it's probably worth a note
inthe documentation: "some routines in AbstractEditPart assume you have
called setModel to bind the part to its corresponding model element"
....Richard
|
|
|
Re: Mapping model elements to EditParts [message #77441 is a reply to message #77423] |
Wed, 30 April 2003 10:08  |
Eclipse User |
|
|
|
If you have the model and the viewer, you can call
viewer.getEditPartRegistry().get(model) to get the edit part.
Eric
Richard Clark wrote:
> The editor I'm building uses nested edit parts as in the Logic Editor, but I
> need to arrange them in a particular order (i.e. I need to manage their
> layout.) I'm looking for a sanctioned way to get the EditPart corresponding
> with a particular model element.
>
> As far as I can tell, there's no getEditPart(Object model) function on
> AbstractEditPart; instead, AbstractEditPart builds and discards a private
> Map each time refreshVisuals() is called. I could do what refreshVisuals()
> does -- walk the list of child edit parts, calling getModel() on each -- but
> I was wondering if there's a "sanctioned" way to get at the model
> element-to-EditPart mapping.
>
> If there isn't a built-in method, please consider this a 2.2 feature
> request. :)
>
> On a related note, I'm a little bothered by refreshVisuals() depending on
> getModel() to build its map. There's nothing in the API contract that
> indicates a model _must_ be set on an EditPart, only that it's used "by an
> EditPartFactory when creating an EditPart" (from the Javadoc). Since you
> can't force someone to set the model (e.g. by making it a parameter to the
> constructor) without breaking existing APIs, it's probably worth a note
> inthe documentation: "some routines in AbstractEditPart assume you have
> called setModel to bind the part to its corresponding model element"
>
> ...Richard
>
>
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.04041 seconds