Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Question about Connections with EReference
Question about Connections with EReference [message #555769] Sat, 28 August 2010 12:30 Go to next message
Tijs Rademakers is currently offline Tijs RademakersFriend
Messages: 9
Registered: August 2010
Junior Member
Hi,

I'm working on a simple version of a BPMN 2.0 editor based on the EMF model of the BPMN2 subproject of MDT. In this EMF model you have for example a StartEvent and EndEvent that are eventually EObjects. I'm able to use the Graphiti tutorial example code together with these Start and End Event objects and that looks great.

But now I run into an issue with connecting a StartEvent with an EndEvent. According to the BPMN2 EMF model I should use a SequenceFlow, with is eventually also a EObject. Now I'm trying to create a Connection between a Start and End Event with a SequenceFlow. Everything goes well until the link method of the AbstractFeature class is invoked from the public PictogramElement add(IAddContext context) method in the TutorialCreateEReferenceFeature equivalent class. There I get a NullPointer on the following line (600) of the AbstractFeatureProvider class:

ResourceSet resourceSet = bo.eResource().getResourceSet();

In the tutorial a EReference instance is used to implement the Connection, and that's working okay ofcourse.
But can I also use a EMF object that extends EObject to implement such a Connection? Am I doing something wrong here?

Best regards,

Tijs
Re: Question about Connections with EReference [message #555865 is a reply to message #555769] Sun, 29 August 2010 19:19 Go to previous messageGo to next message
Tijs Rademakers is currently offline Tijs RademakersFriend
Messages: 9
Registered: August 2010
Junior Member
Hi,

I've worked a bit further with this and I just removed the link method call from my public PictogramElement add(IAddContext context) method and it works great.
I've looked at the code behind this link method, but I can't really figure out what I'm missing by not invoking it Wink. Maybe somebody can help me with understanding this?

Thanks,

Tijs
Re: Question about Connections with EReference [message #555914 is a reply to message #555865] Mon, 30 August 2010 08:24 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
Hi Tijs,

the problem with the null pointer is that the
EObject you want to link to the connection
is not contained in an EResource or the resource
of the EObject is not part of a ResourceSet.

Before linking your EObject you have to make sure that
1) it is contained by a resource
2) the resource is managed by a resource set
(you may use the resource set of the diagram, accessible via
diagram.eResource.getResourceSet())

The same issue would occur with shapes, that is, the issue is not specific for connections.

Best, Tim

ps: If you do not call the link method, a delete of the connection would
not delete the EObject you are visualizing, so i think this is not a good idea. This explains also why your EObject has to be contained in an EResource: the framework needs to know how it is serialized to be able to delete it.

Re: Question about Connections with EReference [message #555949 is a reply to message #555914] Mon, 30 August 2010 11:13 Go to previous message
Tijs Rademakers is currently offline Tijs RademakersFriend
Messages: 9
Registered: August 2010
Junior Member
Hi Tim,

Thanks!
Now that you explained this I looked back at my code and saw that I already added my SequenceFlow object to the ResourceSet of the diagram with the following line:

getDiagram().eResource().getContents().add(sequenceFlow);

So I uncommented the link method call, and it works like a breeze.

Thanks,

Tijs
Previous Topic:Re: Package Not Found exception
Next Topic:Question about Connections with EReference
Goto Forum:
  


Current Time: Fri Apr 19 17:03:38 GMT 2024

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

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

Back to the top