Class BpmnModeler

java.lang.Object
com.vaadin.flow.component.Component
org.vaadin.addons.componentfactory.bpmn.BpmnModeler
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, Serializable

@Tag("div") @NpmPackage(value="bpmn-js",version="18.30.1") @NpmPackage(value="diagram-js",version="15.27.1") @NpmPackage(value="bpmn-js-properties-panel",version="5.65.1") @NpmPackage(value="@bpmn-io/properties-panel",version="3.55.0") @NpmPackage(value="camunda-bpmn-moddle",version="8.0.1") @NpmPackage(value="camunda-bpmn-js-behaviors",version="1.18.0") @NpmPackage(value="bpmn-js-create-append-anything",version="2.1.0") @JsModule("./src/vcf-bpmn-connector.js") @CssImport("bpmn-js/dist/assets/diagram-js.css") @CssImport("bpmn-js/dist/assets/bpmn-js.css") @CssImport("bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css") @CssImport("@bpmn-io/properties-panel/dist/assets/properties-panel.css") @CssImport("./styles/vcf-bpmn.css") public class BpmnModeler extends com.vaadin.flow.component.Component implements com.vaadin.flow.component.HasSize
BPMN 2.0 editor based on bpmn-js, with the properties panel on the right and Camunda 7 extensions enabled. In read-only mode it only shows the diagram.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an editable modeler.
    BpmnModeler(boolean readOnly)
    Creates a modeler, editable or read-only.
    BpmnModeler(boolean readOnly, List<String> customModules)
    Creates a modeler with custom bpmn-js modules, loaded only while editing.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.shared.Registration
    addDiagramChangedListener(com.vaadin.flow.component.ComponentEventListener<DiagramChangedEvent> listener)
    Adds a listener for the edits made in the browser.
    com.vaadin.flow.shared.Registration
    addDiagramImportedListener(com.vaadin.flow.component.ComponentEventListener<DiagramImportedEvent> listener)
    Adds a listener for diagrams imported by setDiagramXml(java.lang.String).
    com.vaadin.flow.shared.Registration
    addDiagramImportErrorListener(com.vaadin.flow.component.ComponentEventListener<DiagramImportErrorEvent> listener)
    Adds a listener for diagrams setDiagramXml(java.lang.String) failed to import.
    void
    addElementClassName(String elementId, String className)
    Adds a CSS class to the SVG of a diagram element; unknown ids are ignored.
    com.vaadin.flow.shared.Registration
    addSelectionChangedListener(com.vaadin.flow.component.ComponentEventListener<SelectionChangedEvent> listener)
    Adds a listener for selection changes, in editing and read-only mode.
     
    Returns the current diagram, including the edits made in the browser.
    boolean
     
    protected void
    onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
    Builds the editor on every attach, not only the first: a refresh with @PreserveOnRefresh also reports an initial attach.
    void
    removeElementClassName(String elementId, String className)
    void
    Loads a BPMN 2.0 diagram and clears the element CSS classes.
    void
    setReadOnly(boolean readOnly)
    Switches between editing and viewing.

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttached

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasSize

    bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
  • Constructor Details

    • BpmnModeler

      public BpmnModeler()
      Creates an editable modeler.
    • BpmnModeler

      public BpmnModeler(boolean readOnly)
      Creates a modeler, editable or read-only.
      Parameters:
      readOnly - true to only view the diagram: pan, zoom and select, without palette or properties panel
    • BpmnModeler

      public BpmnModeler(boolean readOnly, List<String> customModules)
      Creates a modeler with custom bpmn-js modules, loaded only while editing. Each one is registered under its name in a JavaScript file of the application, imported in the view with @JsModule:
       window.Vaadin.Flow.bpmnModules.myModule = {
         module: myModule,       // a bpmn-js module, or an array of them
         ready: aPromise,        // optional: the editor waits for it
         moddleExtensions: {}    // optional: descriptors for custom XML attributes
       };
       
      Create window.Vaadin.Flow.bpmnModules first if it does not exist; one file can register several modules. A name that is not registered is reported in the browser console and left out.
      Parameters:
      readOnly - true to only view the diagram
      customModules - names of the registered modules to load
  • Method Details

    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Builds the editor on every attach, not only the first: a refresh with @PreserveOnRefresh also reports an initial attach.
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • setDiagramXml

      public void setDiagramXml(String bpmnXml)
      Loads a BPMN 2.0 diagram and clears the element CSS classes. The outcome arrives as a DiagramImportedEvent or a DiagramImportErrorEvent.
      Parameters:
      bpmnXml - the diagram to load
    • setReadOnly

      public void setReadOnly(boolean readOnly)
      Switches between editing and viewing. The diagram and any pending edit are kept.
      Parameters:
      readOnly - true to only view the diagram
    • isReadOnly

      public boolean isReadOnly()
      Returns:
      true if the diagram can only be viewed
    • getCustomModules

      public List<String> getCustomModules()
      Returns:
      the names of the custom modules given at construction time
    • addElementClassName

      public void addElementClassName(String elementId, String className)
      Adds a CSS class to the SVG of a diagram element; unknown ids are ignored. Kept across mode switches and re-attaches, cleared by setDiagramXml(java.lang.String), so add classes after setting the diagram.
      Parameters:
      elementId - the id of the element, such as Task_1
      className - one CSS class name, without spaces
    • removeElementClassName

      public void removeElementClassName(String elementId, String className)
      Parameters:
      elementId - the id of the element
      className - the CSS class name
    • getDiagramXml

      public String getDiagramXml()
      Returns the current diagram, including the edits made in the browser.
      Returns:
      the diagram XML, or null if none has been set
    • addDiagramChangedListener

      public com.vaadin.flow.shared.Registration addDiagramChangedListener(com.vaadin.flow.component.ComponentEventListener<DiagramChangedEvent> listener)
      Adds a listener for the edits made in the browser.
    • addSelectionChangedListener

      public com.vaadin.flow.shared.Registration addSelectionChangedListener(com.vaadin.flow.component.ComponentEventListener<SelectionChangedEvent> listener)
      Adds a listener for selection changes, in editing and read-only mode.
    • addDiagramImportedListener

      public com.vaadin.flow.shared.Registration addDiagramImportedListener(com.vaadin.flow.component.ComponentEventListener<DiagramImportedEvent> listener)
      Adds a listener for diagrams imported by setDiagramXml(java.lang.String).
    • addDiagramImportErrorListener

      public com.vaadin.flow.shared.Registration addDiagramImportErrorListener(com.vaadin.flow.component.ComponentEventListener<DiagramImportErrorEvent> listener)
      Adds a listener for diagrams setDiagramXml(java.lang.String) failed to import.