Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Multiple EditPartProviders for Diagram Partitioning
Multiple EditPartProviders for Diagram Partitioning [message #205195] Thu, 11 September 2008 06:26 Go to next message
Eclipse UserFriend
Hi,

I was trying to add two EditPartProviders for two different editors
(diagram partitioning) but through one plugin.xml. That is, I wanted one
EditPartProvider for "Component" diagrams, and another EditPartProvider
for "Wire" diagrams.

My model is like so:
- Component, can contain Wires
- abstract Wire
- NavigateWire implements Wire

I had done this in plugin.xml:

<extension point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders ">
<editpartProvider
class=" my.diagram.component.custom.edit.providers.MyShortcutsEditPa rtProvider ">
<Priority name="Low" />
<object class="org.eclipse.gmf.runtime.notation.Node"
id="MyOverride">
<method name="getElement()">
<value class="my.model.Component"/>
</method>
</object>
<context views="MyOverride"/>
</editpartProvider>
</extension>

<extension point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders ">
<editpartProvider
class=" my.diagram.wire.custom.edit.providers.MyShortcutsEditPartPro vider ">
<Priority name="Low" />
<object class="org.eclipse.gmf.runtime.notation.Node"
id="MyOverride">
<method name="getElement()">
<value class="my.model.NavigateWire"/>
</method>
</object>
<context views="MyOverride"/>
</editpartProvider>
</extension>

But it wasn't working. Only the first was (the Component) and nothing
was happening with the Wire. I tried changing the value class
"my.model.NavigateWire" to "my.model.Wire" and this also didn't help.

However, I tried removing the whole second <method> block, so my
plugin.xml now looks like this:

<extension point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders ">
<editpartProvider
class=" my.diagram.component.custom.edit.providers.MyShortcutsEditPa rtProvider ">
<Priority name="Low" />
<object class="org.eclipse.gmf.runtime.notation.Node"
id="MyOverride">
<method name="getElement()">
<value class="my.model.Component"/>
</method>
</object>
<context views="MyOverride"/>
</editpartProvider>
</extension>

<extension point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders ">
<editpartProvider
class=" my.diagram.wire.custom.edit.providers.MyShortcutsEditPartPro vider ">
<Priority name="Low" />
<object class="org.eclipse.gmf.runtime.notation.Node"
id="MyOverride">
</object>
<context views="MyOverride"/>
</editpartProvider>
</extension>

And it works exactly as desired!

Does <method> support abstract/concrete classes, or is it something else
that I am missing? This is with Eclipse 3.3/GMF 2.0.1.

I tried putting both of them into one EditPartProvider and removed
<method> (so it would theoretically call it for both Component and
Wire), but it was still only calling it for Component and I'm not sure why.

Thanks

Jevon
Re: Multiple EditPartProviders for Diagram Partitioning [message #205293 is a reply to message #205195] Thu, 11 September 2008 07:42 Go to previous messageGo to next message
Eclipse UserFriend
Hello Jevon,

Did you properly modify all necessary .gmfgen model properties before generating
first and second diagram editors? (Search for "unique" word in http://wiki.eclipse.org/GMF_GenModel_Hints).

-----------------
Alex Shatalin
Re: Multiple EditPartProviders for Diagram Partitioning [message #205329 is a reply to message #205293] Thu, 11 September 2008 08:16 Go to previous messageGo to next message
Eclipse UserFriend
Hi Alex,

Thank you for your quick reply!

I followed your advice and looked through that page; every property
mentioned is unique across all of my .gmfgens (I have three of them).
One "diagram file extension" was shared between two but making it unique
made no difference.

Would non-unique "contains shortcuts to" and "shortcuts provided for"
matter?

Cheers
Jevon

Alex Shatalin wrote:
> Hello Jevon,
>
> Did you properly modify all necessary .gmfgen model properties before
> generating first and second diagram editors? (Search for "unique" word
> in http://wiki.eclipse.org/GMF_GenModel_Hints).
>
> -----------------
> Alex Shatalin
>
>
Re: Multiple EditPartProviders for Diagram Partitioning [message #205351 is a reply to message #205329] Thu, 11 September 2008 09:20 Go to previous messageGo to next message
Eclipse UserFriend
Hello Jevon,

> Would non-unique "contains shortcuts to" and "shortcuts provided for"
> matter?
Should not. Then i was wrong while guessing what the reason of malfunction
is..

One more idea - m.b. the reason is in "<context views="MyOverride"/>"? Try
registering one EditPartProvider without any additional meta-information
- just:

<extension point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders ">
<editpartProvider class=" my.diagram.wire.custom.edit.providers.MyShortcutsEditPartPro vider ">
<Priority name="Low" />
</editpartProvider>
</extension>

Once you'll see it is called by framework you can restrict declaration by
additional conditions..

-----------------
Alex Shatalin
Re: Multiple EditPartProviders for Diagram Partitioning [message #207369 is a reply to message #205351] Mon, 29 September 2008 19:00 Go to previous message
Eclipse UserFriend
This is a bit of a delayed response, but I think I've got things sorted
out now...

I think there were two problems with my original attempt:

1- Incorrect editPartProvider mapping. I was trying to add an
EditPartProvider for a Diagram when I was actually adding it for a Node,
like so:

WRONG:
<object class="org.eclipse.gmf.runtime.notation.Node" id="MyOverride">

RIGHT:
<object class="org.eclipse.gmf.runtime.notation.Diagram" id="MyOverride">

2- Incorrect imports. Because I was working with two different generated
models, its possible I was trying to refer to a class which wouldn't
exist in a given editor. For example:

import model.diagram.edit.parts.DomainEditPart;
import model.diagram.providers.DiagramEditPartProvider;

public class MyEditPartProvider extends DiagramEditPartProvider {
public IGraphicalEditPart createGraphicEditPart(View view) {
final IGraphicalEditPart part = super.createGraphicEditPart(view);

if (part instanceof DomainEditPart) {
part.addEditPartListener(new EditPartListener() {
...
}
}
}
}

While this code would work fine in a model.diagram generated editor, if
I tried to add the same EditProvider to a model.diagram.sub generated
editor, I would have to change the imports:

import model.diagram.sub.edit.parts.DomainEditPart;
import model.diagram.sub.providers.DiagramEditPartProvider;

It would be nice if the EditPartProvider API provided some more
documentation. I've submitted bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=249058 to hopefully
resolve this. :)


Cheers

Jevon

Alex Shatalin wrote:
> Hello Jevon,
>
>> Would non-unique "contains shortcuts to" and "shortcuts provided for"
>> matter?
> Should not. Then i was wrong while guessing what the reason of
> malfunction is..
>
> One more idea - m.b. the reason is in "<context views="MyOverride"/>"?
> Try registering one EditPartProvider without any additional
> meta-information - just:
>
> <extension point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders ">
> <editpartProvider
> class=" my.diagram.wire.custom.edit.providers.MyShortcutsEditPartPro vider ">
> <Priority name="Low" />
> </editpartProvider>
> </extension>
>
> Once you'll see it is called by framework you can restrict declaration
> by additional conditions..
>
> -----------------
> Alex Shatalin
>
>
Previous Topic:Resize problem
Next Topic:Cannot initialize foo_diagram with Diagram Partitioning - diagramLink not created
Goto Forum:
  


Current Time: Tue Jul 08 11:12:01 EDT 2025

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

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

Back to the top