Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "BPMN2-Modeler/DeveloperTutorials/ExtendingRuntime"

(Created page with "== Creating a new RuntimeExtension == The core element of a BPMN2 Plugin extension is the BPMN2 Runtime Extension. So first of all you need to create a new Class which implem...")
 
(Define the target runtime Extension point)
Line 54: Line 54:
 
After you added your new extension you can start with the configuration of your extension.
 
After you added your new extension you can start with the configuration of your extension.
  
[[Image:http://ralph.soika.com/wp-content/uploads/2015/02/screen_01.png|screen_01]]
+
[[Image:screen_01.png|screen01]]
  
 
Click ‘new -> runtime’ to define your runtime Extension. Chose your java class file created before and define a Name and a unique ID. The ID of the runtimeExtension is necessary later!
 
Click ‘new -> runtime’ to define your runtime Extension. Chose your java class file created before and define a Name and a unique ID. The ID of the runtimeExtension is necessary later!
 
  
 
=== Test the Plugin ===
 
=== Test the Plugin ===

Revision as of 06:06, 10 March 2015

Creating a new RuntimeExtension

The core element of a BPMN2 Plugin extension is the BPMN2 Runtime Extension. So first of all you need to create a new Class which implements the Interface ‘IBpmn2RuntimeExtension’.

In the RuntimeExtension you need to provide a method for letting the editor know if a bpmn model should be handled by this plugin. This can be done by “peeking” at the contents of the file and checking the targetnamespace. If it not match the namespace of my extension, then I return ‘false’.

Note that the target namespace test does not have to be the only criterion for determining if the model file should be handled by your plugin. This can be as simple or complex as necessary, but care should be taken here since there my be several other bpmn extensions that will need to perform this same test.

This is how my RuntimeExtension will look like so far:

package org.imixs.bpmn.model;

import org.eclipse.bpmn2.modeler.core.IBpmn2RuntimeExtension;
import org.eclipse.bpmn2.modeler.core.LifecycleEvent;
import org.eclipse.bpmn2.modeler.core.utils.ModelUtil.Bpmn2DiagramType;
import org.eclipse.bpmn2.modeler.ui.DefaultBpmn2RuntimeExtension.RootElementParser;
import org.eclipse.bpmn2.modeler.ui.wizards.FileService;
import org.eclipse.ui.IEditorInput;
import org.xml.sax.InputSource;

public class ImixsRuntimeExtension implements IBpmn2RuntimeExtension {

 @Override
 public String getTargetNamespace(Bpmn2DiagramType arg0) {
 return "http://www.imixs.org/bpmn2";
 }

 @Override
 public boolean isContentForRuntime(IEditorInput input) {
 InputSource source = new InputSource(FileService.getInputContents(input));
 RootElementParser parser = new RootElementParser("http://www.imixs.org/bpmn2");
 parser.parse(source);
 return parser.getResult();
 }

 @Override
 public void notify(LifecycleEvent arg0) {
 // TODO Auto-generated method stub

 }

}


Define the target runtime Extension point

Now you can add a new runtime Extension point to your plugin. Open the plugin.xml with the Eclipse Plugin Editor and go to the tab ‘extensions’. Here you can add a new extension from the type:

org.eclipse.bpmn2.modeler.runtime

After you added your new extension you can start with the configuration of your extension.

screen01

Click ‘new -> runtime’ to define your runtime Extension. Chose your java class file created before and define a Name and a unique ID. The ID of the runtimeExtension is necessary later!

Test the Plugin

Now you can start a first Test. Just launch your plugin as an Eclipse Application from the plugin.xml Editor. In the testing workspace you can create a new empty project. If you open the properties of your project you should see the section ‘BPMN2′ with a target runtime selector. Here your new RuntimeExtinsion should be listed. Selecting a runtime extension means that this runtime is used by the BPMN2 Modeler Plugin.

screen_02

You can now add also a BPMN model within you project.

Back to the top