Creating a custom task with multiple visible elements [message #1259332] |
Fri, 28 February 2014 04:06  |
Eclipse User |
|
|
|
Hi,
I use a custom task to define a "Message Start Event", that should create a Start Event with a Message Event Definition. I found that this is done in the jBpm modeler by just defining a tool with a type like "StartEvent+MessageEventDefinition", but I want more control on the created object so I prefered to use a custom task.
I override the createBusinessObject method in my Create Feature (which extends AbstractCreateEventFeature<StartEvent>)to create the Message Event Definition attached to the Start Event:
@Override
public StartEvent createBusinessObject(ICreateContext context)
{
StartEvent startEvent = super.createBusinessObject(context);
// create the message event definition
Shape shape = context.getTargetContainer();
EObject container = BusinessObjectUtil.getBusinessObjectForPictogramElement(shape);
Resource resource = container.eResource();
EClass eclass = Bpmn2Package.eINSTANCE.getMessageEventDefinition();
MessageEventDefinition messageEventDefinition = (MessageEventDefinition) Bpmn2ModelerFactory.create(resource, eclass);
startEvent.getEventDefinitions().add(messageEventDefinition);
return startEvent;
}
The problem is that whan I create a new Message Start Event in my diagram, I only see the Start Event circle, but not the message envelope. However, if I close the editor and re-open it, my Message Start Event is drawn correctly with the envelope inside the event.
Is there a way to refresh the start event after creating it ?
Thanks
|
|
|
|
|
Re: Creating a custom task with multiple visible elements [message #1265676 is a reply to message #1259332] |
Thu, 06 March 2014 07:03   |
Eclipse User |
|
|
|
Hi Bob,
I modified some code in my add feature, and it works better. The decorateShape method was like that (I copied that from the AddStartEventFeature class):
protected void decorateShape(IAddContext context, ContainerShape containerShape, StartEvent businessObject) {
Graphiti.getPeService().setPropertyValue(containerShape, INTERRUPTING, Boolean.toString(true));
IPeService peService = Graphiti.getPeService();
peService.setPropertyValue(containerShape,
"marker.start.event",
AbstractUpdateEventFeature.getEventDefinitionsValue((StartEvent)businessObject));
}
I changed the implementation to:
protected void decorateShape(IAddContext context, ContainerShape containerShape, StartEvent businessObject)
{
IPeService peService = Graphiti.getPeService();
peService.setPropertyValue(containerShape, "interrupting", Boolean.toString(true));
// Set a dummy value for the start event property to force an update
// of the graphical element, so that event definitions are visible at creation time
peService.setPropertyValue(containerShape, "marker.start.event", "dirty");
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.13393 seconds