Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Programatically using a Label
Programatically using a Label [message #163365] Thu, 29 November 2007 20:59 Go to next message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi modeling friends,

I got a use-case where I have to add an EditPart for a Draw2D-Label by
ExtensionPoints. I couldn't find an example :(. Neglecting my specific
situation, the problem can be reduced to add the label behavior to an
existing editor.

A) Comparison
Therefore I created a small example editor and compared the generated
result. The Model is basically:
Semantic.ecore
Wurzel <>---->* (contains)
Element
name

The label in ElementFigure should show Elements name attribute.

If I refer to the generated code changes are made in:

Edit.Parts:
SemanticEditPartFactory: new create Label-EP
ElementNameEditPart: the new EP for the label
ElementEditPart: in the 'addFixedChild'-method, the draw2d-label is set

Part:
SemanticVisualIDRegistry: in 'canCreateNode' VisualID of ElementNameEP added

Providers:
SemanticParserProvider: parser options for the LabelInput
SemanticViewProvider: added create-method for ElementNameEP for VisualID

View.Factories:
ElementNameViewFactory: nothing special here.
ElementViewFactory: Adds a Notation-View for ElementNameEP to ElementEP.

B) Thoughts:
1) There is no metamodel type needed for Element.Name.
2) I guess EditHelper(Advice) are just made for the SemanticModel, so
the NotationView can't be changed by them.
3a) As far as I debugged, the ElementEP returns the ElementNameEP in
'getChildren'. To make ElementNameEP a child, it is added in the
ElementViewFactory to the NotationModel of Element as a child. For
children the SemanticEditPartFactory is called and the Label is added.
3b) I'm not sure if the same behavior like 3a could be done by
installing an EditPolicy for ElementEP?
4) I'm confused weather or not I have to customize ElementEP,
SemanticEPFactory, SemanticVisualIDRegistry, SemanticViewProvider, and
the ElementViewFactory?


Can anybody give me some hints?

- -stefan

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHTygjIYVWjMSpDwwRAvowAKCp7dhMVOHp9PyodVdtLI+xXOF9wQCe NHwW
f+x3KYgra/hLWy263GOFlgg=
=1PdY
-----END PGP SIGNATURE-----
Re: Programatically using a Label [message #163740 is a reply to message #163365] Mon, 03 December 2007 14:50 Go to previous messageGo to next message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi again,

was my question too simple or not understandable? Or should I split it
into several questions like how to change the view-factory for an EditPart?

I could really use some help here :)

- -stefan


SKuhn wrote:
> hi modeling friends,
>
> I got a use-case where I have to add an EditPart for a Draw2D-Label by
> ExtensionPoints. I couldn't find an example :(. Neglecting my specific
> situation, the problem can be reduced to add the label behavior to an
> existing editor.
>
> A) Comparison
> Therefore I created a small example editor and compared the generated
> result. The Model is basically:
> Semantic.ecore
> Wurzel <>---->* (contains)
> Element
> name
>
> The label in ElementFigure should show Elements name attribute.
>
> If I refer to the generated code changes are made in:
>
> Edit.Parts:
> SemanticEditPartFactory: new create Label-EP
> ElementNameEditPart: the new EP for the label
> ElementEditPart: in the 'addFixedChild'-method, the draw2d-label is set
>
> Part:
> SemanticVisualIDRegistry: in 'canCreateNode' VisualID of ElementNameEP added
>
> Providers:
> SemanticParserProvider: parser options for the LabelInput
> SemanticViewProvider: added create-method for ElementNameEP for VisualID
>
> View.Factories:
> ElementNameViewFactory: nothing special here.
> ElementViewFactory: Adds a Notation-View for ElementNameEP to ElementEP.
>
> B) Thoughts:
> 1) There is no metamodel type needed for Element.Name.
> 2) I guess EditHelper(Advice) are just made for the SemanticModel, so
> the NotationView can't be changed by them.
> 3a) As far as I debugged, the ElementEP returns the ElementNameEP in
> 'getChildren'. To make ElementNameEP a child, it is added in the
> ElementViewFactory to the NotationModel of Element as a child. For
> children the SemanticEditPartFactory is called and the Label is added.
> 3b) I'm not sure if the same behavior like 3a could be done by
> installing an EditPolicy for ElementEP?
> 4) I'm confused weather or not I have to customize ElementEP,
> SemanticEPFactory, SemanticVisualIDRegistry, SemanticViewProvider, and
> the ElementViewFactory?
>
>
> Can anybody give me some hints?
>
> -stefan
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHVBfJIYVWjMSpDwwRAkCjAJwOF1aDDZIhOmKIbWDOEcwePEvrVwCe LlSw
pXjo2A1QxKm9RAzSXMTvdcA=
=oR/y
-----END PGP SIGNATURE-----
Re: Programatically using a Label [message #164039 is a reply to message #163740] Tue, 04 December 2007 10:46 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello SKuhn,

Well, I think your question is large enough but for me it looks like you
are on the right way. To my understanding you should create new "extending"
plugin with the following classes:

- ???ViewProvider this class should return customized ElementViewFactory
& ElementNameViewFactory. As a result (but setting high priority for your
provider) you should be able to override original generated view provider
for this particular element (returning ElementViewFactory).
- ElementViewFactory - this view factory should create additional view for
your label you can extend generated ViewFactory here and add your custom
code.
- ???EditPartProvider - again this provider should override original one
and be responsible for the creation of ElementEditPart + ElementNameEditPart.
- ElementEditPart + ElementNameEditPart again, you can extend generated ElementEditPart
if necessary.

The rest i think is less important, so we can discuss it later. So, as a
first step you can create extension plugin with all these providers. As a
result you should be able to create _new_ diagram elements with this additional
label on it (I suppose you can place just a static text into this label first).
The problem is: you will not be able to open diagram with this “additional
label” without extension plugin.

I suggest you to start following this direction and then try to resolve existing
problems one by one.

-----------------
Alex Shatalin
Previous Topic:Change default file name in the "Save as image dialog"
Next Topic:Error in Mapping Model after Transform
Goto Forum:
  


Current Time: Tue May 14 19:58:28 GMT 2024

Powered by FUDForum. Page generated in 0.03410 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top