Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to react to graphical changes/events in the diagram without manipulating generated code
How to react to graphical changes/events in the diagram without manipulating generated code [message #709892] Thu, 04 August 2011 13:01 Go to next message
Greg is currently offline GregFriend
Messages: 15
Registered: April 2011
Junior Member
Is there a way to react to changes/events in the diagram on GMF level similar to the EditHelperAdvice that reacts on the EMF level? It should not alter anything within the package of the generated code.

I want to do three things after a connection has been created:

1.) I want to alter labels in the target indicating the other end of the connection.

2.) I want to change the background color of source and target to indicate that both somehow are connected in the diagram.

3.) In some cases I want to create elements in the target node that reflect the source's layout.

All of this is due to the fact that we want to compress the diagram as far as possible to show the relevant information and hide everything that could confuse the user. For this we collapse all nodes that aren't focused (Another issue we have).

All of these tasks have been solved already, but everything happens deep within the generated code, which makes it very complicated and even slight changes cause chaos.

At first we focus on the first two points.
Our first attempt was inside the getAfterCreateRelationshipCommand method in the EditHelperAdvice for the target node. But there is no way to get the EditPart of the new conncection which would tell us what anchors we are going to connect to, which is vital for our further work. We addressed that issue already here : http://www.eclipse.org/forums/index.php/t/225502/ .
Re: How to react to graphical changes/events in the diagram without manipulating generated code [message #709923 is a reply to message #709892] Thu, 04 August 2011 13:16 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Maybe you could use the GMF runtime extension points to re-use and
override some generated behavior and add your customization.

http://wiki.eclipse.org/Graphical_Modeling_Framework/Tutorial/Part_3#Creating_a_Customization_Plug-in
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.gmf.doc/reference/extension-points/index.html

--
http://mickaelistria.wordpress.com
http://twitter.com/#!/mickaelistria
http://www.petalslink.com
Re: How to react to graphical changes/events in the diagram without manipulating generated code [message #709938 is a reply to message #709923] Thu, 04 August 2011 14:00 Go to previous messageGo to next message
Greg is currently offline GregFriend
Messages: 15
Registered: April 2011
Junior Member
Thank you Mickael,

In general this is what we are doing already. We have a new Plug-In project and already use an extension of org.eclipse.gmf.runtime.emf.type.core.elementTypes and org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings to create the EditHelperAdvice outside of the generated project.

I was hoping to find some specific information about what extension point to use that does react to changes to the graphical parts of the diagram.

In fact just something what the EditHelperAdvice did only with more attention to GMF EditParts.
Re: How to react to graphical changes/events in the diagram without manipulating generated code [message #709954 is a reply to message #709938] Thu, 04 August 2011 14:05 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Ok, then I think you should create your own EditPart provider that would
delegate the instantiation to the default provider, and that would
simply add some listeners on neewly created EditParts.

HTH
--
http://mickaelistria.wordpress.com
http://twitter.com/#!/mickaelistria
http://www.petalslink.com
Re: How to react to graphical changes/events in the diagram without manipulating generated code [message #709955 is a reply to message #709938] Thu, 04 August 2011 14:07 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

By the way, if you think this use-case can be helpful to other, you can
also provide a patch to GMF Runtime to add a "editPartListenerProvider"
or something like that ;)
--
http://mickaelistria.wordpress.com
http://twitter.com/#!/mickaelistria
http://www.petalslink.com
Re: How to react to graphical changes/events in the diagram without manipulating generated code [message #710667 is a reply to message #709955] Fri, 05 August 2011 09:28 Go to previous messageGo to next message
Greg is currently offline GregFriend
Messages: 15
Registered: April 2011
Junior Member
Thank you again, Mickael.

It seems to be the way to go.
I will write again once I've fully implemented it.
Re: How to react to graphical changes/events in the diagram without manipulating generated code [message #714275 is a reply to message #710667] Wed, 10 August 2011 08:06 Go to previous message
Greg is currently offline GregFriend
Messages: 15
Registered: April 2011
Junior Member
My first attempt was to address the first two points from my first post directly inside the provider similar to this:

package ...

import ...

public class ExtendedEditPartProvider extends TestProjectEditPartProvider
{
  @Override
  public synchronized IGraphicalEditPart createGraphicEditPart(View view)
  {
    IGraphicalEditPart iEditPart = super.createGraphicEditPart(view);

    if (view instanceof NodeImpl)
    {
        // #1 at startup see if connections exist and then paint the background
    }

    if (view instanceof EdgeImpl)
    {
        // #2 if connection is created, paint target and source background
        // and rename the target's label according to which anchor has been
        // used for the connection
    }

    return iEditPart;
  }
}


But I didn't succeed since the EditParts weren't fully initialized at this point.

Changing the background color didn't work since the figure wasn't initialized. Before sending the command the figure was null and afterwards the figure was a minimalistic version with the new background color, a size of (0,0) and the location (0,0). The only thing that happened with one of my models was, that the figure grew very large.

Also I cannot rename the target's label yet, because I do not know which target anchor is being used as it is not declared, yet.
Previous Topic:Validation in gmf
Next Topic:GMF Tooling 2.4.0 Release ????
Goto Forum:
  


Current Time: Tue Apr 23 09:16:12 GMT 2024

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

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

Back to the top