How to react to graphical changes/events in the diagram without manipulating generated code [message #709892] |
Thu, 04 August 2011 09:01  |
Eclipse User |
|
|
|
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 #714275 is a reply to message #710667] |
Wed, 10 August 2011 04:06  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.06205 seconds