Jump to: navigation, search

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

(Hiding elements of the palette)
(Hiding elements in the popup toolbar and the end connections menus)
Line 95: Line 95:
 
== Hiding elements in the popup toolbar and the end connections menus ==
 
== Hiding elements in the popup toolbar and the end connections menus ==
  
[http://wiki.eclipse.org/STP/BPMN_Component/Samples#Hiding_elements_in_toolbar_and_connection_menus Full sample]
+
[[STP/BPMN_Component/Samples#Hiding_elements_in_toolbar_and_connection_menus|Full sample]]
  
 
You need to create your own editor, subclassing the <code>BpmnDiagramEditor</code>.
 
You need to create your own editor, subclassing the <code>BpmnDiagramEditor</code>.

Revision as of 17:05, 22 February 2008

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

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)

Full sample

You need to expose a IDnDHandler object through an IAdapterFactory.

The IDnDHandler must return a command that will effectively drop the annotation on the diagram's selected shape.

In the case of an EAnnotation drop, it is recommended to extend the AbstractEAnnotationDnDHandler class, and provide your own method:

public Command getDropCommand(IGraphicalEditPart hoverPart, int index,
            Point dropLocation) {
        
        Map<String, String> details = new HashMap<String, String>();
        try {
            details.put("lastModified", String.valueOf(_file.getLocalTimeStamp()));
            details.put("name", _file.getName());
            details.put("fileExtension", _file.getFileExtension());
            details.put("content-type", _file.getContentDescription().getContentType().getName());

            Reader in = new BufferedReader(new InputStreamReader(_file.getContents()));
            StringBuffer buffer= new StringBuffer(1024);
            [..]
            details.put("text", buffer.toString());
        } catch(Exception e) {
            e.printStackTrace();
        }
        
        return createEAnnotationDropCommand(
                createAnnotation(TEXT_ANNOTATION_SOURCE, details),
                (EModelElement) hoverPart.resolveSemanticElement());
    }

The createAnnotation and createEAnnotationDropCommand are two methods exposed by the super class for your convenience.

Creating a DND to add a graphical element

Annotation decoration

Sample

You can decorate annotations through our own extension point.

TODO

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 also 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);
   }

FAQ

why do you have IElementTypeEx ?

IElementType is a GMF interface to describe a view type. It is passed in requests to create elements.

The BpmnElementTypes class contains all the element types for the BPMN modeler. That also means that each element type corresponds to a view and an edit part.

We did not want to generate an edit part per activity type. Instead we have created two edit parts for activities, one for normal activities and the other one for event handlers.

Then we use IElementTypeEx to add a secondary semantic hint that is the literal of the ActivityType.

To create a IElementTypeEx object, you can use this:

ElementTypeEx.wrap(BpmnElementTypes.Activity_2001,
                   ActivityType.EVENT_INTERMEDIATE_MESSAGE_LITERAL.getLiteral());