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 "STP/BPMN Component/EclipseCon2008"

(The annotation coding sample)
 
(22 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
= Get the most of the BPMN modeler =
 
This page features the tutorial [http://www.eclipsecon.org/2008/?page=sub/&id=496 Get the most of the BPMN modeler for EclipseCon 2008].
 
This page features the tutorial [http://www.eclipsecon.org/2008/?page=sub/&id=496 Get the most of the BPMN modeler for EclipseCon 2008].
  
 
This page is related to [[STP/BPMN_Component/Developing with the STP BPMN modeler|Developing with the STP BPMN modeler]] and [[STP/BPMN_Component/Using the STP BPMN modeler|Using the STP BPMN modeler]].
 
This page is related to [[STP/BPMN_Component/Developing with the STP BPMN modeler|Developing with the STP BPMN modeler]] and [[STP/BPMN_Component/Using the STP BPMN modeler|Using the STP BPMN modeler]].
  
<div style="border: 3px solid #3c78b5;background-color: #f0f0f0;padding: 10px;text-align: center; color: red; font-size: 14px ; font-weight: bold">
+
<div style="border: 1px solid #3c78b5; background-color: #ecde9b; padding: 5px; width: 200px; float: right;">
This is a work in progress, please watch the page to stay tuned. If you want to submit something to this page, please post to this [http://ec2008lists.greenmeetingsystems.com/mailman/listinfo/ec2008-tutorial496 mailing list] first.
+
=== Get the code ===
</div>
+
  
Here is the outline of the tutorial:
+
[http://public.xdrive.com/opc/XDPC-70717FC5HChX0NKiBxehqBwJaH0xJvjC/ through Eclipse spaces]
 +
 
 +
[[STP/BPMN_Component/Samples#Bug_sample_.28EclipseCon_2008.29|Through the STP Subversion]]
 +
 
 +
</div>
  
 
<div style="border: 1px solid #3c78b5;background-color: #e0e0e0; padding: 10px; width: 300px">
 
<div style="border: 1px solid #3c78b5;background-color: #e0e0e0; padding: 10px; width: 300px">
 +
=== Tutorial outline ===
 
*16h: Presentation
 
*16h: Presentation
 
*16h15: Modeling BPMN
 
*16h15: Modeling BPMN
Line 18: Line 23:
 
</div>
 
</div>
  
 +
= BPMN modeling sample =
  
= What's in the box =
+
[http://dev.eclipse.org/svnroot/stp/org.eclipse.stp.bpmn/trunk/samples/bpmn_samples/bugzilla/ Bugzilla project]
  
== An active Eclipse component ==
 
*Going 1.0
 
*Just i18n'ed
 
  
== A GMF-based modeler ==
+
Below is a list of items we want to cover during the BPMN modeling sample.
  
== A tool to model BPMN ==
+
<div style="float:right;">
 +
[[Image:bugzilla_process.gif|none|thumb|1000px|The bugzilla process]]
 +
</div>
  
= BPMN modeling sample =
+
<div style="border: 1px solid #3c78b5;background-color: #e0e0e0; padding: 10px; width: 300px">
Below is a list of items we want to cover during the BPMN modeling sample
+
 
* Palette
 
* Palette
 
* Popup toolbar
 
* Popup toolbar
Line 50: Line 54:
 
** Attaching a reference to a project file to a shape
 
** Attaching a reference to a project file to a shape
 
** Opening a file
 
** Opening a file
 +
</div>
 +
 +
= The annotation coding sample =
  
== The annotation coding sample ==
+
[[STP/BPMN_Component/Samples#Bug_sample_.28EclipseCon_2008.29|Link to the code]]
 
[[Image:bug_view.png|frame|The bug view]]
 
[[Image:bug_view.png|frame|The bug view]]
 
This sample demonstrates how you can integrate the BPMN modeler with an external application.
 
This sample demonstrates how you can integrate the BPMN modeler with an external application.
Line 58: Line 65:
 
In this sample we will use a plugin (org.eclipse.bpmn.sample.bugView) which shows a tree view of various bugs.
 
In this sample we will use a plugin (org.eclipse.bpmn.sample.bugView) which shows a tree view of various bugs.
  
=== Creating the drag and drop plugin ===
+
== Creating the drag and drop plugin ==
 
Create the plugin, make it dependent of <code>org.eclipse.stp.bpmn.diagram</code> and <code>org.eclipse.stp.bpmn.sample.bugView</code>.
 
Create the plugin, make it dependent of <code>org.eclipse.stp.bpmn.diagram</code> and <code>org.eclipse.stp.bpmn.sample.bugView</code>.
  
==== IDnDHandlers ====
+
== IDnDHandlers ==
 
Open the extensions tab and create a new extension for <code>org.eclipse.core.runtime.adapters</code>:
 
Open the extensions tab and create a new extension for <code>org.eclipse.core.runtime.adapters</code>:
  
Line 174: Line 181:
 
|}
 
|}
  
<div style="border: 5px solid #ddd; background-color: #cc0000; padding: 10px; color: #fff; text-align: center">
+
{{warning
[[Image:Warning_Sign.png]] If you try the run the plugin as is, nothing will happen. Adapter factories are lazy extensions, ie they do not trigger the activation of their bundle when being called. So you need to make sure the bundle is called by creating an other extension point or calling one of its class from another plugin.
+
|        text = If you try the run the plugin as is, nothing will happen. Adapter factories are lazy extensions, ie they do not trigger the activation of their bundle when being called. So you need to make sure the bundle is called by creating an other extension point or calling one of its class from another plugin.
</div>
+
}}
  
 
So we need an other extension point to activate our plugin, uh ? We will settle for an annotation decorator.
 
So we need an other extension point to activate our plugin, uh ? We will settle for an annotation decorator.
 +
 +
== Annotation decorators ==
 +
 +
{| border="0" cellspacing="15" valign="top" style="width:100%;"
 +
 +
|-valign="top"
 +
|style="width:50%;"|
 +
  
 
Let's create the <code>org.eclipse.stp.bpmn.sample.bugDnD.decorator</code> package, and get back to the Manifest editor.
 
Let's create the <code>org.eclipse.stp.bpmn.sample.bugDnD.decorator</code> package, and get back to the Manifest editor.
Line 184: Line 199:
 
We select the <code>org.eclipse.stp.bpmn.diagram.EAnnotationDecorator</code> extension point in the wizard. The source attribute showing should be the bug annotation source.
 
We select the <code>org.eclipse.stp.bpmn.diagram.EAnnotationDecorator</code> extension point in the wizard. The source attribute showing should be the bug annotation source.
  
[[Image:extension point annotation decorator.png]]
+
[[Image:extension point annotation decorator part 1.png]]
 +
[[Image:extension point annotation decorator part 2.png]]
 +
 
 +
 
 +
 
 +
|
 +
 
 
Then we instantiate the class in charge of decorating the annotated shapes, let's name it <code>BugAnnotationDecorator</code>.
 
Then we instantiate the class in charge of decorating the annotated shapes, let's name it <code>BugAnnotationDecorator</code>.
 +
 +
This class implements <code>IEAnnotationDecorator</code>:
 +
 +
<source lang="java">
 +
 +
    public String getAssociatedAnnotationSource() {
 +
        return BugDnDHandler.BUG_ANNOTATION_SOURCE;
 +
    }
 +
 +
    public Direction getDirection(EditPart part, EModelElement elt,
 +
            EAnnotation ann) {
 +
        return Direction.SOUTH_WEST;
 +
    }
 +
 +
    public ImageDescriptor getImageDescriptor(EditPart part,
 +
            EModelElement element, EAnnotation annotation) {
 +
        return BugDnDPlugin.imageDescriptorFromPlugin(BugDnDPlugin.PLUGIN_ID, "icons/bug_decorator.gif");
 +
    }
 +
 +
    public IFigure getToolTip(EditPart part, EModelElement element,
 +
            EAnnotation annotation) {
 +
        Label label = new Label();
 +
        label.setText("#" + annotation.getDetails().get("number"));
 +
        return label;
 +
    }
 +
 +
</source>
 +
 +
|}
 +
 +
Now we can run the demo! Open the execution environment and a BPMN diagram, along with the bug view.
 +
 +
Drop a bug view over the pool and here is the result:
 +
 +
[[Image:bug_drop_view.png]]
 +
 +
= Extending the modeler =
 +
 +
 +
[[STP/BPMN_Component/Samples#Bug_sample_.28EclipseCon_2008.29|Link to the code]]
 +
 +
In this  part, we will rebrand the modeler and add more functionalities to our diagram.
 +
 +
{| border="0" cellspacing="15" valign="top" style="width:100%;"
 +
 +
|-valign="top"
 +
|style="width:50%;"|
 +
 +
== Opening a bug in the browser ==
 +
So far we have seen how to annotate shapes with bugs. While this is certainly looking good, it'd be great to actually use that for a practical purpose.
 +
In this section we will learn how to override the edit part provider to extend the annotation edit parts and give a different open edit policy that will open the bugs in a browser.
 +
 +
We create a new  plugin named org.eclipse.stp.bpmn.sample.bugEditor for this.
 +
 +
In GMF, the edit part service looks for edit part providers, sorts them depending on their priority, and picks the one with the highest one (there are other ways to activate or deactivate the provider, see this [http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.gmf.doc/reference/extension-points/org_eclipse_gmf_runtime_diagram_ui_editpartProviders.html help page] for more).
 +
 +
We add an extension point on <code>[http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.gmf.doc/reference/extension-points/org_eclipse_gmf_runtime_diagram_ui_editpartProviders.html org.eclipse.gmf.runtime.diagram.ui.editpartProviders]?</code>, designating the class and the priority on which we want this provider to be executed.
 +
 +
We create the provider by extending the default edit part provider, setting a new factory.
 +
 +
<source lang="java">
 +
public class BugEditPartProvider extends BpmnEditPartProvider {
 +
 +
    public BugEditPartProvider() {
 +
        setFactory(new BugEditPartFactory());
 +
        setAllowCaching(true);
 +
    }
 +
 +
}
 +
</source>
 +
 +
The factory extends the BPMN factory. Its only method consists in returning an edit part representing a view passed as an argument:
 +
 +
<source lang="java">       
 +
        /**
 +
        * Creates a special text annotation edit part
 +
        */
 +
        public EditPart createEditPart(EditPart context, Object model) {
 +
            if (model instanceof View) {
 +
                final View view = (View) model;
 +
                int viewVisualID = BpmnVisualIDRegistry.getVisualID(view);
 +
                switch (viewVisualID) {
 +
                case TextAnnotationEditPart.VISUAL_ID :
 +
                    [...]
 +
                case TextAnnotation2EditPart.VISUAL_ID :
 +
                    [...]
 +
                }
 +
            }
 +
            return super.createEditPart(context, model);
 +
        }
 +
    }
 +
</source>
 +
 +
For the case of the text annotation edit parts, we override the default edit parts to change their default edit policies:
 +
 +
<source lang="java">
 +
return new TextAnnotationEditPart(view) {
 +
                       
 +
  @Override
 +
  protected void createDefaultEditPolicies() {
 +
    super.createDefaultEditPolicies();
 +
    installEditPolicy(EditPolicyRoles.OPEN_ROLE, new OpenBugEditPolicy());
 +
  }
 +
};
 +
</source>
 +
 +
We then write the open bug edit policy which will open a browser with the bug url when requested:
 +
 +
<source lang="java">
 +
String number = EcoreUtil.getAnnotation(((EModelElement) object), BugDnDHandler.BUG_ANNOTATION_SOURCE, "number");
 +
// and open the browser
 +
try {
 +
  PlatformUI.getWorkbench().getBrowserSupport().createBrowser(
 +
                                            IWorkbenchBrowserSupport.AS_EXTERNAL
 +
                                            | IWorkbenchBrowserSupport.NAVIGATION_BAR
 +
                                            | IWorkbenchBrowserSupport.LOCATION_BAR,
 +
                                            "openbug", // the id, use the same if you want to reuse the same browser
 +
                                            "Bug #" + number, // the title
 +
                                            ""). // the tooltip
 +
                            openURL(new URL("http://bugs.eclipse.org/" + number));
 +
                        } catch (Exception e) {
 +
                          e.printStackTrace();
 +
                        }
 +
</source>
 +
 +
Now try opening the bug by double-clicking on the text annotation while pushing Shift. It should open the bug in an external browser.
 +
|
 +
== Getting your own editor ==
 +
 +
It's just a final touch on top of our additions; we want our own editor.
 +
 +
To do that we will subclass BpmnDiagramEditor, and declare it as the default one for *.bpmn_diagram files.
 +
 +
<source lang="java">
 +
public class BugBpmnEditor extends BpmnDiagramEditor {
 +
 +
    public static final String ID = "org.eclipse.stp.bpmn.sample.bugeditor.editor";
 +
   
 +
    static {
 +
       
 +
        PlatformUI.getWorkbench().getEditorRegistry().
 +
            setDefaultEditor("*.bpmn_diagram", ID); //$NON-NLS-1$
 +
    }
 +
}
 +
</source>
 +
 +
We need to declare the BugBpmnEditor editor in plugin.xml.
 +
 +
On top of that we bind it to its diagram action bar contributor.
 +
<source lang="xml">
 +
<extension point="org.eclipse.ui.editors">
 +
      <editor
 +
            class="org.eclipse.stp.bpmn.sample.bugeditor.BugBpmnEditor"
 +
            contributorClass="org.eclipse.stp.bpmn.sample.bugeditor.BugDiagramActionBarContributor"
 +
            extensions="bpmn_diagram"
 +
            icon="icons/bug.gif"
 +
            id="org.eclipse.stp.bpmn.sample.bugeditor.editor"
 +
            name="Bug BPMN Editor">
 +
      </editor>
 +
</extension>
 +
</source>
 +
 +
This contributor doesn't do much, just redirecting to our new editor the actions contributed to the BPMN editor.
 +
<source lang="java">
 +
public class BugDiagramActionBarContributor extends
 +
        BpmnDiagramActionBarContributor {
 +
 +
    protected Class getEditorClass() {
 +
        return BugBpmnEditor.class;
 +
    }
 +
 +
    protected String getEditorId() {
 +
        return BugBpmnEditor.ID;
 +
    }
 +
}
 +
</source>
 +
 +
We bind the BPMN palette provider to the bug editor.
 +
<source lang="xml">
 +
<extension point="org.eclipse.gmf.runtime.diagram.ui.paletteProviders">
 +
  <paletteProvider class="org.eclipse.stp.bpmn.diagram.providers.BpmnPaletteProvider">
 +
      <Priority name="Lowest"/>
 +
      <editor id="org.eclipse.stp.bpmn.sample.bugeditor.editor"/>
 +
  </paletteProvider>
 +
</extension>
 +
</source>
 +
 +
And then we add the same customizations that are done on the modeler, by adding global action handlers.
 +
|}
  
 
[[Category:BPMN]]
 
[[Category:BPMN]]
 
[[Category:STP]]
 
[[Category:STP]]
 
[[Category:EclipseCon 2008]]
 
[[Category:EclipseCon 2008]]

Latest revision as of 04:07, 11 July 2008

Get the most of the BPMN modeler

This page features the tutorial Get the most of the BPMN modeler for EclipseCon 2008.

This page is related to Developing with the STP BPMN modeler and Using the STP BPMN modeler.

Tutorial outline

  • 16h: Presentation
  • 16h15: Modeling BPMN
  • 16h45: Interactions with the modeler
  • 17h05: Get your own editor
  • 17h35: Future plans and conclusions
  • 17h50: Questions

BPMN modeling sample

Bugzilla project


Below is a list of items we want to cover during the BPMN modeling sample.

The bugzilla process
  • Palette
  • Popup toolbar
  • Appearance tab
  • Creating basic shapes
    • Different activity types
    • Gateways
  • Sequence and messaging edges
    • Connection rules
    • Customized handles
    • Customize the edge and the reset connection button
    • Change the order of edges for an activity
  • Insert space tool
  • Using artifacts
    • TODO tags
  • Validation
    • Using the builder to validate the diagram
  • Documentation
    • Attaching a reference to a project file to a shape
    • Opening a file

The annotation coding sample

Link to the code

The bug view

This sample demonstrates how you can integrate the BPMN modeler with an external application. Our coding sample will consist in creating a new plugin, which will transform bugs into text annotations during a drag and drop operation.

In this sample we will use a plugin (org.eclipse.bpmn.sample.bugView) which shows a tree view of various bugs.

Creating the drag and drop plugin

Create the plugin, make it dependent of org.eclipse.stp.bpmn.diagram and org.eclipse.stp.bpmn.sample.bugView.

IDnDHandlers

Open the extensions tab and create a new extension for org.eclipse.core.runtime.adapters:

<extension point="org.eclipse.core.runtime.adapters">
   <factory adaptableType="org.eclipse.stp.bpmn.sample.bugView.bug.view.IBug" 
            class="org.eclipse.stp.bpmn.sample.bugDnD.dnd.BugAdapterFactory">
      <adapter type="org.eclipse.stp.bpmn.dnd.IDnDHandler"/>
   </factory>
</extension>

Then, we create the adapter factory by naming it BugAdapterFactory and placing it in dnd package under the plugin class.

The contents of the adapter factory should like this:

public class BugAdapterFactory implements IAdapterFactory {
 
    public Object getAdapter(Object adaptableObject, Class adapterType) {
        if (adaptableObject instanceof IBug && 
                IDnDHandler.class.equals(adapterType)) {
            return new BugDnDHandler((IBug) adaptableObject);
        }
        return null;
    }
 
    public Class[] getAdapterList() {
        return new Class[] {IDnDHandler.class};
    }
 
}

We create a BugDnDHandler class that will extend AbstractViewDnDHandler.

In its constructor this class takes a IBug object.

You can split the IDnDHandler implementation into two aspects. It implements a menu look and feel on one hand, and returns a command on the other hand.

We determine the number of items to show in the menu, and we provide a label and an image for each of them.

public int getItemCount() {
        return 1;
    }
 
    public Image getMenuItemImage(IGraphicalEditPart hoverPart, int index) {
        if (bug.getState() == IBug.FIXED) {
            return BugView.BUG_FIXED;
        } else {
            return BugView.BUG;
        }
    }
 
    public String getMenuItemLabel(IGraphicalEditPart hoverPart, int index) {
        return "Drop a bug over the diagram";
    }

Now for the interesting bits: the drop command itself.

    public Command getDropCommand(IGraphicalEditPart hoverPart, int index,
            Point dropLocation) {
        BPMNVisual2ProcessGenerator generator = new BPMNVisual2ProcessGenerator();
        TextAnnotation textA = generator.addTextAnnotation(null, bug.getSummary());
        Map<String, String> details = new HashMap<String, String>();
        details.put("state", String.valueOf(bug.getState()));
        details.put("number", String.valueOf(bug.getNumber()));
        generator.addAnnotation(textA, BUG_ANNOTATION_SOURCE, details);
        generator.generateViews();
        View textAnnotationView = generator.getSemantic2notationMap().get(textA);
 
        return getDropViewCommand(Collections.singletonList(textAnnotationView), 
                dropLocation, hoverPart);
    }

In this method, we use a generator to generate semantic elements and their views.

Let's create the generator:

BPMNVisual2ProcessGenerator generator = new BPMNVisual2ProcessGenerator();

Now we use it to create a text annotation that we annotate with an EAnnotation.

TextAnnotation textA = generator.addTextAnnotation(null, bug.getSummary());
Map<String, String> details = new HashMap<String, String>();
details.put("state", String.valueOf(bug.getState()));
details.put("number", String.valueOf(bug.getNumber()));
generator.addAnnotation(textA, BUG_ANNOTATION_SOURCE, details);

We generate the view of the text annnotation:

generator.generateViews();
View textAnnotationView = generator.getSemantic2notationMap().get(textA);

We use a helper method defined in the super class to create the command that will actually drop the view.

return getDropViewCommand(Collections.singletonList(textAnnotationView), 
                dropLocation, hoverPart);
Warning2.png


So we need an other extension point to activate our plugin, uh ? We will settle for an annotation decorator.

Annotation decorators


Let's create the org.eclipse.stp.bpmn.sample.bugDnD.decorator package, and get back to the Manifest editor.

We select the org.eclipse.stp.bpmn.diagram.EAnnotationDecorator extension point in the wizard. The source attribute showing should be the bug annotation source.

Extension point annotation decorator part 1.png File:Extension point annotation decorator part 2.png


Then we instantiate the class in charge of decorating the annotated shapes, let's name it BugAnnotationDecorator.

This class implements IEAnnotationDecorator:

    public String getAssociatedAnnotationSource() {
        return BugDnDHandler.BUG_ANNOTATION_SOURCE;
    }
 
    public Direction getDirection(EditPart part, EModelElement elt,
            EAnnotation ann) {
        return Direction.SOUTH_WEST;
    }
 
    public ImageDescriptor getImageDescriptor(EditPart part,
            EModelElement element, EAnnotation annotation) {
        return BugDnDPlugin.imageDescriptorFromPlugin(BugDnDPlugin.PLUGIN_ID, "icons/bug_decorator.gif");
    }
 
    public IFigure getToolTip(EditPart part, EModelElement element,
            EAnnotation annotation) {
        Label label = new Label();
        label.setText("#" + annotation.getDetails().get("number"));
        return label;
    }

Now we can run the demo! Open the execution environment and a BPMN diagram, along with the bug view.

Drop a bug view over the pool and here is the result:

File:Bug drop view.png

Extending the modeler

Link to the code

In this part, we will rebrand the modeler and add more functionalities to our diagram.

Opening a bug in the browser

So far we have seen how to annotate shapes with bugs. While this is certainly looking good, it'd be great to actually use that for a practical purpose. In this section we will learn how to override the edit part provider to extend the annotation edit parts and give a different open edit policy that will open the bugs in a browser.

We create a new plugin named org.eclipse.stp.bpmn.sample.bugEditor for this.

In GMF, the edit part service looks for edit part providers, sorts them depending on their priority, and picks the one with the highest one (there are other ways to activate or deactivate the provider, see this help page for more).

We add an extension point on org.eclipse.gmf.runtime.diagram.ui.editpartProviders?, designating the class and the priority on which we want this provider to be executed.

We create the provider by extending the default edit part provider, setting a new factory.

public class BugEditPartProvider extends BpmnEditPartProvider {
 
    public BugEditPartProvider() {
        setFactory(new BugEditPartFactory());
        setAllowCaching(true);
    }
 
}

The factory extends the BPMN factory. Its only method consists in returning an edit part representing a view passed as an argument:

 
        /**
         * Creates a special text annotation edit part
         */
        public EditPart createEditPart(EditPart context, Object model) {
             if (model instanceof View) {
                 final View view = (View) model;
                 int viewVisualID = BpmnVisualIDRegistry.getVisualID(view);
                 switch (viewVisualID) {
                 case TextAnnotationEditPart.VISUAL_ID :
                     [...]
                 case TextAnnotation2EditPart.VISUAL_ID :
                     [...]
                 }
             }
             return super.createEditPart(context, model);
        }
    }

For the case of the text annotation edit parts, we override the default edit parts to change their default edit policies:

return new TextAnnotationEditPart(view) {
 
  @Override
  protected void createDefaultEditPolicies() {
     super.createDefaultEditPolicies();
     installEditPolicy(EditPolicyRoles.OPEN_ROLE, new OpenBugEditPolicy());
  }
};

We then write the open bug edit policy which will open a browser with the bug url when requested:

String number = EcoreUtil.getAnnotation(((EModelElement) object), BugDnDHandler.BUG_ANNOTATION_SOURCE, "number");
// and open the browser
try {
   PlatformUI.getWorkbench().getBrowserSupport().createBrowser(
                                            IWorkbenchBrowserSupport.AS_EXTERNAL
                                            | IWorkbenchBrowserSupport.NAVIGATION_BAR
                                            | IWorkbenchBrowserSupport.LOCATION_BAR,
                                            "openbug", // the id, use the same if you want to reuse the same browser 
                                            "Bug #" + number, // the title
                                            ""). // the tooltip
                             openURL(new URL("http://bugs.eclipse.org/" + number));
                        } catch (Exception e) {
                          e.printStackTrace();
                        }

Now try opening the bug by double-clicking on the text annotation while pushing Shift. It should open the bug in an external browser.

Getting your own editor

It's just a final touch on top of our additions; we want our own editor.

To do that we will subclass BpmnDiagramEditor, and declare it as the default one for *.bpmn_diagram files.

public class BugBpmnEditor extends BpmnDiagramEditor {
 
    public static final String ID = "org.eclipse.stp.bpmn.sample.bugeditor.editor";
 
    static {
 
        PlatformUI.getWorkbench().getEditorRegistry().
            setDefaultEditor("*.bpmn_diagram", ID); //$NON-NLS-1$
    }
}

We need to declare the BugBpmnEditor editor in plugin.xml.

On top of that we bind it to its diagram action bar contributor.

<extension point="org.eclipse.ui.editors">
      <editor
            class="org.eclipse.stp.bpmn.sample.bugeditor.BugBpmnEditor"
            contributorClass="org.eclipse.stp.bpmn.sample.bugeditor.BugDiagramActionBarContributor"
            extensions="bpmn_diagram"
            icon="icons/bug.gif"
            id="org.eclipse.stp.bpmn.sample.bugeditor.editor"
            name="Bug BPMN Editor">
      </editor>
</extension>

This contributor doesn't do much, just redirecting to our new editor the actions contributed to the BPMN editor.

public class BugDiagramActionBarContributor extends
        BpmnDiagramActionBarContributor {
 
    protected Class getEditorClass() {
        return BugBpmnEditor.class;
    }
 
    protected String getEditorId() {
        return BugBpmnEditor.ID;
    }
}

We bind the BPMN palette provider to the bug editor.

<extension point="org.eclipse.gmf.runtime.diagram.ui.paletteProviders">
   <paletteProvider class="org.eclipse.stp.bpmn.diagram.providers.BpmnPaletteProvider">
      <Priority name="Lowest"/>
      <editor id="org.eclipse.stp.bpmn.sample.bugeditor.editor"/>
   </paletteProvider>
</extension>

And then we add the same customizations that are done on the modeler, by adding global action handlers.

Back to the top