Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

BPMN2-Modeler/DeveloperTutorials/CreateCustomTask

< BPMN2-Modeler‎ | DeveloperTutorials
Revision as of 07:05, 10 March 2015 by Unnamed Poltroon (Talk) (Created page with "==Create a Custom task== This section explains how to add a new customTask element extending the BPMN task element. Extending a BPMN model element covers the following aspect...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Create a Custom task

This section explains how to add a new customTask element extending the BPMN task element.

Extending a BPMN model element covers the following aspects:

  • The visual modelling element
  • The properties of the custom element
  • Optional property sections to configure the element

To define a new customTask element just open the plugin.xml file and create a new ‘CustomTask’ to your bpmn plugin extension node. In the property ‘runtimeid’ add the previous defined Runtime ID. In the property ‘Type’ enter ‘Task’ to use the standard task object type to be extended from BPMN2. The Property ‘category’ defines a new section in the tool palette where your new element will be available.

Next you need to generate a new Java class for the FeatureContainer. This can be done form the plugin editor by click on ‘featureContainer*’. The class can be extended form the ‘CustomShapeFeatureContainer’. See the following example:

public class TestTaskElementFeatureContainer1 extends CustomShapeFeatureContainer {

 // these values must match what's in the plugin.xml
 private final static String TYPE_VALUE = "TestTask";
 private final static String CUSTOM_TASK_ID = "Imixs-BPMN2.customTask1";

 public TestTaskElementFeatureContainer1() {
 
 }

 @Override
 public String getId(EObject object) {
 // This is where we inspect the object to determine what its custom task ID should be.
 // In this case, the "type" attribute will have a value of "MyTask".
 // If found, return the CUSTOM_TASK_ID string.
 //
 // Note that the object inspection can be arbitrarily complex and may include several
 // object features. This simple case just demonstrates what needs to happen here.
 EStructuralFeature f = ModelDecorator.getAnyAttribute(object, "type");
 if (f!=null) {
 Object id = object.eGet(f);
 if (TYPE_VALUE.equals(id))
 return CUSTOM_TASK_ID;
 }
 
 return null;
 }


 @Override
 public ICustomFeature[] getCustomFeatures(IFeatureProvider fp) {
 return new ICustomFeature[] {new ShowPropertiesFeature(fp)};
 }
}

To identify the task element the class should be assigned to, you can add a new property named ‘type’ into the customTask extension point. Use the plugin.xml editor and add a new property to your customTask with the name ‘type’ and the value ‘TestTask’. These values are evaluated from the new TestTaskElementFeatureContainer1 class.

File:Screen 03

You can now also define additional custom properties. These properties will be displayed in the ‘Task’ property Section when you edit the new Task Element with the BPMN Editor. This kind of properties are called ‘dynamic properties’. This is the easiest way to create a custom BPMN element.

Back to the top