|
Re: How to validate incoming connections? [message #1692101 is a reply to message #1691984] |
Mon, 13 April 2015 13:20 |
|
Hi Ralph,
This is not really "validation" per se, but you could try hooking in to the object LifeCycle event notification in your IBpmn2RuntimeExtension class. Something like this:
@Override
public void notify(LifecycleEvent event) {
if (event.eventType == EventType.PICTOGRAMELEMENT_ADDED) {
Connection c = (Connection) event.target;
Shape s = (Shape) c.getEnd().getParent();
BaseElement be = BusinessObjectUtil.getFirstBaseElement( s );
// determine if this is one of your custom shapes and modify accordingly...
}
}
Don't forget, you'll have to wrap any changes you make in a transaction, the usual way.
Also, you'll probably want to handle the case where the connection is removed with EventType.PICTOGRAMELEMENT_DELETED. Be advised that any changes you make will be in a separate transaction, so when the user clicks "undo" the first time will undo your changes, the second one will undo the connection creation.
HTH
Bob
[Updated on: Mon, 13 April 2015 13:30] Report message to a moderator
|
|
|
|
Re: How to validate incoming connections? [message #1692150 is a reply to message #1692127] |
Tue, 14 April 2015 01:28 |
|
Hey Ralph,
On the contrary, I am thrilled at your use of EMF adapters especially if you can make all your model changes inside the same transaction as the AddFeature for the SequenceFlow! The best place I've found to add EMF event adapters is in the IBpmn2RuntimeExtension#notify() method - have a look at JBPM5RuntimeExtension for an example.
Again, you should look at the jbpm plugin for an example of how to override/augment the core validation code. The jbpm plugin.xml defines some overrides for certain BPMN2 types (e.g. "Process", "Signal", "Escalation", etc.) The handlers for these validators are invoked from the org.eclipse.bpmn2.modeler.runtime.jboss.jbpm5.validation.JbpmModelConstraint class.
Let me know if you need more explanation than this...
Bob
|
|
|
|
|
Re: How to validate incoming connections? [message #1692441 is a reply to message #1692299] |
Wed, 15 April 2015 17:30 |
|
Um, nope. Even something as simple as changing an attribute value will cause EMF to fire a model change notification. The only way to turn off notification that I know of (and this should be used with caution!) is to turn the EObject's notification delivery flag off like this:
void updateMyObject(EObject object) {
try {
object.eSetDeliver(false);
object.setSomeAttribute("Hello world");
}
finally {
object.eSetDeliver(true);
}
}
As far as your chicken & egg problem is concerned, this has been a problem for me as well. If all else fails, you can always inject an eAdapter during file loading by providing your own Bpmn2ModelerResourceImpl implementation. Take a look at how this is done in DroolsResourceFactoryImpl and DroolsResourceImpl in the jBPM plugin.
[Updated on: Wed, 15 April 2015 17:30] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04702 seconds