|
|
Re: extend SequenceFlow [message #1110869 is a reply to message #1110810] |
Tue, 17 September 2013 12:37 |
|
I will look into it as soon as I get the editor code stabilized for an upcoming release this Wednesday. Please have patience.
In the meantime, have a look at the <toolPalette> extension point, examples of which can be found in the jBPM plugin.xml
Bob
|
|
|
|
|
Re: extend SequenceFlow [message #1118023 is a reply to message #1115013] |
Fri, 27 September 2013 02:12 |
|
Hi Mhammad,
I've been working on this and after some code refactoring, it's now possible to create custom connections as well as shapes. I need to do some more testing, but so far it looks pretty good. I should have something for you to test out by tomorrow.
Cheers,
Bob
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: extend SequenceFlow [message #1125212 is a reply to message #1124262] |
Fri, 04 October 2013 09:19 |
mhammad makni Messages: 66 Registered: June 2013 |
Member |
|
|
Hi Robert;
Quote:
package org.eclipse.bpmn2.modeler.examples.time;
import org.eclipse.bpmn2.BaseElement;
import org.eclipse.bpmn2.Event;
import org.eclipse.bpmn2.modeler.core.features.FeatureContainer;
import org.eclipse.bpmn2.modeler.core.features.event.definitions.AbstractAddEventDefinitionFeature;
import org.eclipse.bpmn2.modeler.core.features.event.definitions.AbstractEventDefinitionFeatureContainer;
import org.eclipse.bpmn2.modeler.core.features.event.definitions.CreateEventDefinition;
import org.eclipse.bpmn2.modeler.core.features.event.definitions.DecorationAlgorithm;
import org.eclipse.bpmn2.modeler.core.runtime.CustomTaskImageProvider;
import org.eclipse.bpmn2.modeler.core.utils.BusinessObjectUtil;
import org.eclipse.bpmn2.modeler.core.utils.GraphicsUtil;
import org.eclipse.bpmn2.modeler.core.utils.ModelUtil;
import org.eclipse.bpmn2.modeler.core.utils.StyleUtil;
import org.eclipse.bpmn2.modeler.core.utils.StyleUtil.FillStyle;
import org.eclipse.bpmn2.modeler.examples.time.MyModel.MyEventDefinition;
import org.eclipse.bpmn2.modeler.examples.time.MyModel.MyModelPackage;
import org.eclipse.bpmn2.modeler.ui.features.activity.task.CustomTaskFeatureContainer;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.graphiti.features.IAddFeature;
import org.eclipse.graphiti.features.ICreateFeature;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.graphiti.mm.MmPackage;
import org.eclipse.graphiti.mm.algorithms.Ellipse;
import org.eclipse.graphiti.mm.algorithms.Image;
import org.eclipse.graphiti.mm.algorithms.Polygon;
import org.eclipse.graphiti.mm.algorithms.Rectangle;
import org.eclipse.graphiti.mm.algorithms.RoundedRectangle;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.services.IGaService;
import org.eclipse.graphiti.services.IPeService;
public class MyEventDefinitionFeatureContainer extends CustomTaskFeatureContainer {
private final static String TYPE_VALUE = "MyEventDefinition";
private final static String CUSTOM_TASK_ID = "org.eclipse.bpmn2.modeler.examples.customtask.eventDefinition1";
public MyEventDefinitionFeatureContainer() {
}
@Override
public String getId(EObject object) {
EStructuralFeature f = ModelUtil.getAnyAttribute(object, "type");
if (f!=null) {
Object id = object.eGet(f);
if (TYPE_VALUE.equals(id))
return CUSTOM_TASK_ID;
}
return null;
}
protected FeatureContainer createFeatureContainer(IFeatureProvider fp) {
return new AbstractEventDefinitionFeatureContainer() {
@Override
public ICreateFeature getCreateFeature(IFeatureProvider fp) {
return new CreateMyEventDefinitionFeature(fp);
}
@Override
protected Shape drawForStart(DecorationAlgorithm algorithm, ContainerShape shape) {
return draw(algorithm,shape);
}
@Override
protected Shape drawForEnd(DecorationAlgorithm algorithm, ContainerShape shape) {
return draw(algorithm,shape);
}
@Override
protected Shape drawForThrow(DecorationAlgorithm algorithm, ContainerShape shape) {
return draw(algorithm,shape);
}
@Override
protected Shape drawForCatch(DecorationAlgorithm algorithm, ContainerShape shape) {
return draw(algorithm,shape);
}
@Override
protected Shape drawForBoundary(DecorationAlgorithm algorithm, ContainerShape shape) {
return draw(algorithm,shape);
}
private Shape draw(DecorationAlgorithm algorithm, ContainerShape shape) {
Shape iconShape = Graphiti.getPeService().createShape(shape, false);
Image img = CustomTaskImageProvider.createImage(customTaskDescriptor, iconShape, customTaskDescriptor.getIcon(), 30, 30);
Graphiti.getGaService().setLocationAndSize(img, 3, 3, 30, 30);
return iconShape;
}
};
}
public class CreateMyEventDefinitionFeature extends CreateEventDefinition<MyEventDefinition> {
public CreateMyEventDefinitionFeature(IFeatureProvider fp) {
super(fp, "My Event Definition", "Create My Event Definition");
}
@Override
public EClass getBusinessObjectClass() {
return MyModelPackage.eINSTANCE.getMyEventDefinition();
}
@Override
protected String getStencilImageId() {
return null;
}
}
}
this implementation allow me to add MyEventDefinition(appeare on xml), but, it doesn't show the graphic image on the diagram.
by the way, I want to show the attribute of MyEventDefinition on the diagram.
I really feel that I'm carrying on you so much , but I'm counting on your generosity.
I'm waiting for your response.
Thank you very much.
|
|
|
Re: extend SequenceFlow [message #1129244 is a reply to message #1125212] |
Tue, 08 October 2013 12:47 |
mhammad makni Messages: 66 Registered: June 2013 |
Member |
|
|
Hi,
when I read about the plugin extension I deduced that we could extend the bpmn2.0 metamodel using an ecore file, indeed, The demands of my work oblige me to have a new meta-classes that extend from defined meta-classes (event Definition and sequence flow).
the super imlementation of canCreate() return true only if the element invoked is type of BaseElement, in the custom task example I remarked that you didn't define any meta-class, and I saw that this could be the problem of not having a BaseElement type.
In my case I defined MyEventDefinition (extends EventDefinition), and as it mentioned in my previous comment, I'm permitted to add MyEventDefinition and effectevly, it is shown on the xml file, but it doesn't figure on the graphic.
I tried to solve this graphic problem by redefining the addFeature, but unfortunately I didn't get the wanted result.
so please could you take a look and tell me what should I do.
waiting for your help.
thanks
|
|
|
Re: extend SequenceFlow [message #1137752 is a reply to message #1129244] |
Mon, 14 October 2013 18:15 |
|
Hi Mhammad,
I've updated the customtask example and fixed the EventDefinition extension. The problem was that enablement of EventDefinitions was controlled by a complex set of rules (enforced by the BPMN 2.0 spec) in the base class and the MyEventDefinition did not match any of those rules.
Bob
|
|
|
|
|
|
|
|
Re: extend SequenceFlow [message #1198781 is a reply to message #1198394] |
Wed, 20 November 2013 14:03 |
|
ok, so it looks like <dependency> is an extension element, which means you have to create an extension model. The CustomTask screencast shows how to do that.
So, I have a couple of questions:
1. should Dependency have any of the attributes of any of the existing BPMN2 connection elements (i.e. SequenceFlow, Association, etc.) If so, you can define your Dependency element as a subclass of an existing BPMN2 element.
2. what will be the container for your Dependency elements? For example, SequenceFlows are contained in a FlowElementsContainer (more precisely, one of its subclasses like Process or SubProcess or Choreography). If Dependency will be treated similarly, then it MUST subclass a BPMN2 element (in this example, it must be a FlowElement if it's going to be contained in a FlowElementsContainer).
3. can Dependency be treated like an extension element? That is, can its containment look something like this:
<bpmn2:process ...>
<bpmn2:extensionElements>
<tns:dependency sourceref="xx" targetref="yy" property="zz"/>
</bpmn2:extensionElements>
if it cannot be contained like one of the existing BPMN2 elements, then it needs to go in the <bpmn2:extensionElements> container.
Also keep in mind that your extension element will belong to a different namespace (in the example above "tns" will be the namespace of your EMF model).
Lastly, Dependency should have an "id" attribute if it will be referenced by other elements in your model. At the very least it should subclass the BPMN2 BaseElement.
Cheers,
Bob
|
|
|
|
Re: extend SequenceFlow [message #1199541 is a reply to message #1198920] |
Wed, 20 November 2013 22:19 |
|
ok, I'm confused...if it's a FlowNode then your feature container should extend CustomShapeFeatureContainer, but if it has the properties of a connection line (it can't be a FlowNode, a FlowElement maybe?) then you should extend CustomConnectionFeatureContainer. Which one is it?
I've never actually tried to build a custom feature container for an object type that doesn't extend one of the BPMN2 types. I'll take a look to see if it's possible...
|
|
|
|
Re: extend SequenceFlow [message #1209799 is a reply to message #1203650] |
Mon, 25 November 2013 18:07 |
mhammad makni Messages: 66 Registered: June 2013 |
Member |
|
|
Hi Robert,
the SampleCustomSequenceFlowFeatureContainer class situated under org.eclipse.bpmn2.modeler.runtime.example bundle aims to create a sequence flow named Mitigation Flow.
Quote:
public class SampleCustomSequenceFlowFeatureContainer extends CustomConnectionFeatureContainer {
@Override
protected IFeatureContainer createFeatureContainer(IFeatureProvider fp) {
return new SequenceFlowFeatureContainer()
{
@Override
public IAddFeature getAddFeature(IFeatureProvider fp) {
return new AddSequenceFlowFeature(fp) {
/* (non-Javadoc)
* @see org.eclipse.bpmn2.modeler.ui.features.flow.SequenceFlowFeatureContainer.AddSequenceFlowFeature#decorateConnection(org.eclipse.graphiti.features.context.IAddConnectionContext, org.eclipse.graphiti.mm.pictograms.Connection, org.eclipse.bpmn2.SequenceFlow)
*
* This implementation of SequenceFlow's decorateConnection() changes the appearance of the connection
* to distinguish it from regular SequenceFlows.
*/
@Override
protected void decorateConnection(IAddConnectionContext context, Connection connection,
SequenceFlow businessObject) {
super.decorateConnection(context, connection, businessObject);
connection.getGraphicsAlgorithm().setLineWidth(3);
connection.getGraphicsAlgorithm().setLineStyle(LineStyle.DASH);
}
};
}
@Override
public ICreateConnectionFeature getCreateConnectionFeature(IFeatureProvider fp) {
return new CreateSequenceFlowFeature(fp) {
@Override
public SequenceFlow createBusinessObject(ICreateConnectionContext context) {
SequenceFlow businessObject = super.createBusinessObject(context);
return businessObject;
}
@Override
public String getCreateImageId() {
return SampleImageProvider.getImageId(customTaskDescriptor, IconSize.SMALL);
}
@Override
public String getCreateLargeImageId() {
return SampleImageProvider.getImageId(customTaskDescriptor, IconSize.LARGE);
}
};
}
};
}
the methods getCreateConnectionFeature and getAddFeature define the nature of the connection which is in the particular example above is a SquenceFlow.
is it possible to create an equivalent to SquenceFlow named "Dependency" which is a FlowElement defined in myEcore in order to get this kind of tag in the xml file:
<Dependency sourceref="xx" targetref="yy" property="zz">
it doesn't matter if it came as like as this form:
<bpmn2:process ...>
<bpmn2:extensionElements>
<tns:dependency sourceref="xx" targetref="yy" property="zz"/>
</bpmn2:extensionElements>
I tried to reform my request and I hope that you get me.
thank you very very much
your are the best.
waiting for your response.
|
|
|
|
Re: extend SequenceFlow [message #1219607 is a reply to message #1212118] |
Wed, 04 December 2013 22:00 |
|
Hi Mhammad,
It turns out that what you're trying to do was not possible previously
I have created this bugzilla to track the issue and am working on a fix for this. It should be available in tonight's build. Please check the nightly build update site.
I've also enhanced the custom task example plug-in to include your use-case. Please pull down the latest source code from git to see how this is all done.
Thanks for helping to improve the extension API
Bob
|
|
|
|
|
Re: extend SequenceFlow [message #1228681 is a reply to message #1226396] |
Tue, 07 January 2014 20:03 |
|
Hi Mhammad,
Sorry for the late reply. I finally got around to trying this out myself and discovered that there's a bug which prevents the definition of <propertyTab> extensions which involve classes not defined in the bpmn2 metamodel. See Bug 425047 for a description.
I've also enhanced the org.eclipse.bpmn2.modeler.examples.customtask example plugin to demonstrate how to define a property tab for these custom objects.
Cheers,
Bob
|
|
|
|
|
|
|
Re: extend SequenceFlow [message #1251699 is a reply to message #1250624] |
Thu, 20 February 2014 14:00 |
|
Hi Mhammad,
I have been doing a lot of work in the area of extensibility because I've gotten a lot of questions and suggestions/requests to improve the API. The new API will be available shortly (by next week) so if you can hold on until then, it may solve all of your problems
I still have a lot of testing to do to make sure nothing is broken! I'll also take the existing example plugins and convert them to use the new APIs, just to make sure things work as I had envisioned.
The idea is to use dynamic EMF to create extension EPackages, classes and features, instead of having to create an ecore file and generate java classes for your extension objects, although you should still be able to use that method as well. You will also be able to define these extensions in configuration files which are reloaded when created or modified.
Bob
|
|
|
|
Re: extend SequenceFlow [message #1258941 is a reply to message #1256823] |
Thu, 27 February 2014 22:57 |
|
I'm hoping to have this done by end of this week which, according to my work schedule, is Sunday March 2
I'll post a new topic on this forum when the new build is ready.
This will be version 1.1.0 because the API changes require a new minor version number.
|
|
|
|