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
ConstructorsConstructorDescriptionCreates 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 TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationaddDiagramChangedListener(com.vaadin.flow.component.ComponentEventListener<DiagramChangedEvent> listener) Adds a listener for the edits made in the browser.com.vaadin.flow.shared.RegistrationaddDiagramImportedListener(com.vaadin.flow.component.ComponentEventListener<DiagramImportedEvent> listener) Adds a listener for diagrams imported bysetDiagramXml(java.lang.String).com.vaadin.flow.shared.RegistrationaddDiagramImportErrorListener(com.vaadin.flow.component.ComponentEventListener<DiagramImportErrorEvent> listener) Adds a listener for diagramssetDiagramXml(java.lang.String)failed to import.voidaddElementClassName(String elementId, String className) Adds a CSS class to the SVG of a diagram element; unknown ids are ignored.com.vaadin.flow.shared.RegistrationaddSelectionChangedListener(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.booleanprotected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) Builds the editor on every attach, not only the first: a refresh with@PreserveOnRefreshalso reports an initial attach.voidremoveElementClassName(String elementId, String className) Removes a CSS class added withaddElementClassName(java.lang.String, java.lang.String).voidsetDiagramXml(String bpmnXml) Loads a BPMN 2.0 diagram and clears the element CSS classes.voidsetReadOnly(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, whenAttachedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods 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, setWidthFullMethods 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-trueto only view the diagram: pan, zoom and select, without palette or properties panel
-
BpmnModeler
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 };Createwindow.Vaadin.Flow.bpmnModulesfirst 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-trueto only view the diagramcustomModules- 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@PreserveOnRefreshalso reports an initial attach.- Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
setDiagramXml
Loads a BPMN 2.0 diagram and clears the element CSS classes. The outcome arrives as aDiagramImportedEventor aDiagramImportErrorEvent.- 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-trueto only view the diagram
-
isReadOnly
public boolean isReadOnly()- Returns:
trueif the diagram can only be viewed
-
getCustomModules
- Returns:
- the names of the custom modules given at construction time
-
addElementClassName
Adds a CSS class to the SVG of a diagram element; unknown ids are ignored. Kept across mode switches and re-attaches, cleared bysetDiagramXml(java.lang.String), so add classes after setting the diagram.- Parameters:
elementId- the id of the element, such as Task_1className- one CSS class name, without spaces
-
removeElementClassName
Removes a CSS class added withaddElementClassName(java.lang.String, java.lang.String).- Parameters:
elementId- the id of the elementclassName- the CSS class name
-
getDiagramXml
Returns the current diagram, including the edits made in the browser.- Returns:
- the diagram XML, or
nullif 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 bysetDiagramXml(java.lang.String). -
addDiagramImportErrorListener
public com.vaadin.flow.shared.Registration addDiagramImportErrorListener(com.vaadin.flow.component.ComponentEventListener<DiagramImportErrorEvent> listener) Adds a listener for diagramssetDiagramXml(java.lang.String)failed to import.
-