Difference between revisions of "SOA/BPMN Modeler/Developing with the BPMN modeler"

From Eclipsepedia

Jump to: navigation, search
(Hiding elements in the popup toolbar and the end connections menus)
(Hiding elements of the palette)
Line 24: Line 24:
  
 
== Hiding elements of the palette ==
 
== Hiding elements of the palette ==
 +
 +
[http://dev.eclipse.org/svnroot/stp/org.eclipse.stp.bpmn/trunk/samples/org.eclipse.stp.bpmn.sample.noTextAnnotationInPalette/ Full sample]
 +
 +
You can remove elements by overriding the palette provider
 +
 +
<code><pre>
 +
  <extension point="org.eclipse.gmf.runtime.diagram.ui.paletteProviders">
 +
      <paletteProvider class="org.eclipse.stp.bpmn.sample.editor.NoTextAnnotationPaletteContributor">
 +
        <Priority name="Lowest"/>
 +
        <editor id="org.eclipse.stp.bpmn.sample.noTextAnnotationInPalette.editor1"/>
 +
      </paletteProvider>
 +
  </extension>
 +
 +
</pre></code>
 +
 +
You can override the BpmnPaletteProvider class, call the super method and remove a specific entry from the palette containers. Obviously you can override the BpmnPaletteFactory and have it your way.
 +
 +
<code><pre>
 +
    public void contributeToPalette(IEditorPart editor, Object content,
 +
            PaletteRoot root, Map predefinedEntries) {
 +
        //this is the short way
 +
        super.contributeToPalette(editor, content, root, predefinedEntries);
 +
        ((PaletteContainer) root.getChildren().get(1)).getChildren().remove(0);
 +
       
 +
        //the long way consists in populating the palette with your own factory.
 +
    }
 +
</pre></code>
  
 
== Hiding elements in the popup toolbar and the end connections menus ==
 
== Hiding elements in the popup toolbar and the end connections menus ==

Revision as of 14:08, 20 February 2008

This page is about developing with the STP BPMN modeler, by contributing and/or removing actions, shapes, etc.

Contents

Menus

Adding menu items

Adding a menu item

Adding a menu

Adding toolbar extensions

Adding a toolbar item

Adding a toolbar group

Removing menu items

Creating a new drag and drop (DND) interaction

Creating a DND to add a semantic element (eg annotation)

Creating a DND to add a graphical element

Hiding elements of the palette

Full sample

You can remove elements by overriding the palette provider

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

You can override the BpmnPaletteProvider class, call the super method and remove a specific entry from the palette containers. Obviously you can override the BpmnPaletteFactory and have it your way.

    public void contributeToPalette(IEditorPart editor, Object content,
            PaletteRoot root, Map predefinedEntries) {
        //this is the short way
        super.contributeToPalette(editor, content, root, predefinedEntries);
        ((PaletteContainer) root.getChildren().get(1)).getChildren().remove(0);
        
        //the long way consists in populating the palette with your own factory.
    }

Hiding elements in the popup toolbar and the end connections menus

Full sample

You need to create your own editor, subclassing the BpmnDiagramEditor.

In this editor you will override the method createDiagramEditDomain:

   protected void createDiagramEditDomain() {
       BpmnDiagramEditDomain domain = new BpmnDiagramEditDomain(this);
       domain.setActionManager(createActionManager());
       
       Set<IElementType> types = new HashSet<IElementType>();
       for (Object gatewayType : ActivityType.VALUES_GATEWAYS) {
           types.add(ElementTypeEx.wrap(BpmnElementTypes.Activity_2001, 
                   ((ActivityType) gatewayType).getLiteral()));
       }
       types.add(BpmnElementTypes.Group_1004);
       types.add(BpmnElementTypes.Group_2006);
       domain.setRemovedElementTypes(types);
       
       setEditDomain(domain);
   }