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

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

m (Ralph.soika.imixs.com moved page BPMN2-Modeler/Tutorials/ExtendingRuntime to BPMN2-Modeler/DeveloperTutorials/ExtendingRuntime: wrong tutorial section)
Line 1: Line 1:
 +
==Versions==
 +
This Tutorial was developed with Eclipse 4.4 (Luna) and BPMN2-Plugin version 1.1.1.
 +
 
==The Environment==
 
==The Environment==
 
First verify that BPMN2 plugin is already installed in your Eclipse IDE. If you are working with Eclipse Luna the plugin development is much easier as in the early years of Eclipse. So most things can be controlled from the plugin editor and Eclipse will take care about necessary dependencies to the BPMN2 Plugin .
 
First verify that BPMN2 plugin is already installed in your Eclipse IDE. If you are working with Eclipse Luna the plugin development is much easier as in the early years of Eclipse. So most things can be controlled from the plugin editor and Eclipse will take care about necessary dependencies to the BPMN2 Plugin .
  
If you install also the BPMN2 Sources you can look around the BPMN 2 implementations which will help sometimes to understand some behavior in the background. Optional you can also import the following plugins into your Eclipse Workspace.
+
If you install also the BPMN2 Sources from the [http://download.eclipse.org/bpmn2-modeler/updates/ Updatesite] you can look around the BPMN 2 implementations which will help sometimes to understand some behavior in the background. Optional you can also import the following plugins into your Eclipse Workspace.
  
 
<pre>
 
<pre>
Line 60: Line 63:
 
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’.
 
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 to let 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 the extension, then return ‘false’.
+
In the RuntimeExtension implementation you need to provide a method to let 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 you made any [[BPMN2-Modeler/DeveloperTutorials/ModelExtension| model extension]]. If it not match the namespace of the extension, then 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 may be several other bpmn extensions that will need to perform this same test.
+
Note that the target namespace test does asume that you have made also a [[BPMN2-Modeler/DeveloperTutorials/ModelExtension| model extension]]. This 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 may be several other bpmn extensions that will need to perform this same test.
  
 
This is how the RuntimeExtension will look like so far:
 
This is how the RuntimeExtension will look like so far:
Line 83: Line 86:
 
  return "http://www.imixs.org/bpmn2";
 
  return "http://www.imixs.org/bpmn2";
 
  }
 
  }
 
+
// test namespaces of bpmn content.
 
  @Override
 
  @Override
 
  public boolean isContentForRuntime(IEditorInput input) {
 
  public boolean isContentForRuntime(IEditorInput input) {
Line 109: Line 112:
 
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:screen_01.png|center|thumb|300px|screen01]]
+
[[Image:screen_01.png|center|thumb|500px|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!
Line 116: Line 119:
 
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.
 
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.
  
[[Image:screen_02.png|center|thumb|300px|screen02]]
+
[[Image:screen_02.png|center|thumb|500px|screen02]]
  
 
You can now add also a BPMN model within you project.
 
You can now add also a BPMN model within you project.

Revision as of 05:25, 11 March 2015

Versions

This Tutorial was developed with Eclipse 4.4 (Luna) and BPMN2-Plugin version 1.1.1.

The Environment

First verify that BPMN2 plugin is already installed in your Eclipse IDE. If you are working with Eclipse Luna the plugin development is much easier as in the early years of Eclipse. So most things can be controlled from the plugin editor and Eclipse will take care about necessary dependencies to the BPMN2 Plugin .

If you install also the BPMN2 Sources from the Updatesite you can look around the BPMN 2 implementations which will help sometimes to understand some behavior in the background. Optional you can also import the following plugins into your Eclipse Workspace.

org.eclipse.bpmn2.modeler.core
org.eclipse.bpmn2.modeler.feature
org.eclipse.bpmn2.modeler.runtime.example
org.eclipse.bpmn2.modeler.ui

Create a Plugin project

First of all create a new Eclipse Plugin project. To extend the BPMN Plugin you first need to add some of the necessary dependencies.

Open the plugin.xml with the plugin editor and switch to the ‘dependencies’ tab and add the following bpmn2 and graphiti dependencies:

org.eclipse.bpmn2
org.eclipse.bpmn2.edit
org.eclipse.bpmn2.editor
org.eclipse.bpmn2.core
org.eclipse.bpmn2.ui
org.eclipse.graphiti
org.eclipse.graphiti.ui
org.apache.xerces

The dependencies are added into the MANIFEST.MF File into the section ‘Runtime-Bundle’. This section should look like this:

....
Require-Bundle: org.eclipse.core.runtime,
 org.eclipse.emf.ecore;visibility:=reexport,
 org.eclipse.emf.ecore.xmi;visibility:=reexport,
 org.eclipse.graphiti;bundle-version="[0.11.0,0.12.0]",
 org.eclipse.graphiti.ui;bundle-version="[0.11.0,0.12.0]",
 org.eclipse.gef,
 org.eclipse.bpmn2,
 org.eclipse.bpmn2.edit,
 org.eclipse.bpmn2.editor,
 org.eclipse.bpmn2.modeler.core,
 org.eclipse.bpmn2.modeler.ui,
 org.eclipse.emf.transaction,
 org.eclipse.emf.databinding,
 org.eclipse.emf.edit.ui,
 org.eclipse.ui.views.properties.tabbed,
 org.eclipse.jface.databinding,
 org.apache.xerces,
 org.eclipse.core.resources,
 org.eclipse.core.runtime,
 org.eclipse.ui,
 org.eclipse.jdt.core
.....

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 implementation you need to provide a method to let 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 you made any model extension. If it not match the namespace of the extension, then return ‘false’.

Note that the target namespace test does asume that you have made also a model extension. This 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 may be several other bpmn extensions that will need to perform this same test.

This is how the 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";
 }
 // test namespaces of bpmn content.
 @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.

screen02

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

Back to the top