Skip to content

Commit

Permalink
impl, layout
Browse files Browse the repository at this point in the history
Issue #292
  • Loading branch information
rsoika committed Sep 13, 2023
1 parent 93719e5 commit e8c7a72
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 155 deletions.
11 changes: 8 additions & 3 deletions open-bpmn.glsp-client/open-bpmn-glsp/css/diagram.css
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,24 @@
.pool > .sprotty-node {
fill: var(--theia-sideBar-background);
pointer-events: none;
xopacity: 70%;
fill-opacity: 70%;
stroke: var(--theia-focusBorder);
stroke-width: 2;
}
.pool > .sprotty-node.mouseover {
opacity: 60%;
stroke: var(--theia-focusBorder);
opacity: 100%;
}
.pool>.pool_header {
fill: var(--theia-titleBar-activeBackground);
stroke: var(--theia-focusBorder);
stroke-width: 2;
stroke-width: 2;
}

.pool>.pool_header:hover,
.lane>.lane_header:hover {
opacity: 70%;
}
.pool .pool_header text {
font-weight: normal;
font-size: 0.7em;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class IconView extends ShapeView {
*/
@injectable()
export class PoolHeaderView extends ShapeView {
render(element: SShapeElement, context: RenderingContext): VNode | undefined {
render(element: Readonly<SShapeElement & Hoverable>, context: RenderingContext): VNode | undefined {
if (!this.isVisible(element, context)) {
return undefined;
}
Expand All @@ -208,8 +208,8 @@ export class PoolHeaderView extends ShapeView {
labelYOffset=containerNode.bounds.height*0.5;
}
const vnode: any = (
<g class-sprotty-node={element instanceof SNode}>
<rect class-sprotty-node={element instanceof SNode}
<g>
<rect
x="0" y="0" width="30" height={headerHeight}></rect>
<text class-sprotty-label={true} transform={'scale(1),translate(20,'+labelYOffset+'),rotate(-90)'}>{containerLabel}</text>
</g>
Expand Down
8 changes: 6 additions & 2 deletions open-bpmn.glsp-client/open-bpmn-glsp/src/di.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import {
editLabelFeature,
initializeDiagramContainer,
moveFeature,
overrideViewerOptions
overrideViewerOptions,
selectFeature
} from '@eclipse-glsp/client';
import {
BPMNEdge,
Expand Down Expand Up @@ -137,7 +138,10 @@ const bpmnDiagramModule = new ContainerModule((bind, unbind, isBound, rebind) =>
configureModelElement(context, 'lane_header', SCompartment, LaneHeaderView);

configureModelElement(context, 'pool', PoolNode, RoundedCornerNodeView, { disable: [moveFeature] } );
configureModelElement(context, 'lane', LaneNode, RoundedCornerNodeView);
configureModelElement(context, 'lane', LaneNode, RoundedCornerNodeView, {
disable: [moveFeature, selectFeature]}
);

configureModelElement(context, 'dataObject', DataObjectNode, DataObjectNodeView);
configureModelElement(context, 'message', MessageNode, MessageNodeView);
configureModelElement(context, 'textAnnotation', TextAnnotationNode, TextAnnotationNodeView);
Expand Down
62 changes: 26 additions & 36 deletions open-bpmn.glsp-client/workspace/lane-resize.bpmn
Original file line number Diff line number Diff line change
@@ -1,57 +1,47 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<bpmn2:definitions xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:open-bpmn="http://open-bpmn.org/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exporter="org.openbpmn" exporterVersion="1.0.0" targetNamespace="http://open-bpmn.org" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL">
<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:open-bpmn="http://open-bpmn.org/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exporter="org.openbpmn" exporterVersion="1.0.0" targetNamespace="http://open-bpmn.org">
<bpmn2:collaboration id="collaboration_1" name="Default Collaboration">
<bpmn2:participant id="participant_7YWWrA" name="Default Process" processRef="process_1"/>
<bpmn2:participant id="participant_95AsiQ" name="Pool-1" processRef="process_Z0MEcQ">
<bpmn2:documentation id="documentation_wWPB0A"/>
<bpmn2:participant id="participant_wZ00fw" name="Pool-1" processRef="process_RyD07g">
<bpmn2:documentation id="documentation_1W8HQA"/>
</bpmn2:participant>
</bpmn2:collaboration>
<bpmn2:process definitionalCollaborationRef="collaboration_1" id="process_1" name="Default Process" processType="Public">
<bpmn2:documentation id="documentation_SgJ1WQ"/>
<bpmn2:scriptTask id="task_ZAUT8A" name="Task-1">
<bpmn2:documentation id="documentation_oguW0g"/>
<bpmn2:script id="script_RmN0rg"/>
</bpmn2:scriptTask>
</bpmn2:process>
<bpmn2:process definitionalCollaborationRef="collaboration_1" id="process_Z0MEcQ" name="Pool-1" processType="Private">
<bpmn2:laneSet id="laneset_POO6Xw" name="Lane Set">
<bpmn2:lane id="lane_ubOYbA" name="Lane 1">
<bpmn2:documentation id="documentation_VbaUFg"/>
<bpmn2:flowNodeRef>event_3WYx1Q</bpmn2:flowNodeRef>
<bpmn2:process definitionalCollaborationRef="collaboration_1" id="process_RyD07g" name="Pool-1" processType="Private">
<bpmn2:laneSet id="laneset_0MleXA" name="Lane Set">
<bpmn2:lane id="lane_dyB75Q" name="Lane 1a">
<bpmn2:documentation id="documentation_XkW7MA"/>
</bpmn2:lane>
<bpmn2:lane id="lane_KsMpeA" name="Lane 2">
<bpmn2:documentation id="documentation_nN2rvQ"/>
<bpmn2:flowNodeRef>event_REocCg</bpmn2:flowNodeRef>
<bpmn2:lane id="lane_0IRThw" name="Lane 2">
<bpmn2:documentation id="documentation_K5SIfQ"/>
</bpmn2:lane>
<bpmn2:lane id="lane_g3UiCw" name="Lane 3">
<bpmn2:documentation id="documentation_z82bow"/>
</bpmn2:lane>
</bpmn2:laneSet>
<bpmn2:startEvent id="event_3WYx1Q" name="Event-1">
<bpmn2:documentation id="documentation_R3bSpw"/>
</bpmn2:startEvent>
<bpmn2:endEvent id="event_REocCg" name="Event-2">
<bpmn2:documentation id="documentation_w0x63g"/>
</bpmn2:endEvent>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1" name="OpenBPMN Diagram">
<bpmndi:BPMNPlane bpmnElement="collaboration_1" id="BPMNPlane_1">
<bpmndi:BPMNShape bpmnElement="participant_95AsiQ" id="BPMNShape_97rMEg">
<dc:Bounds height="400.0" width="800.0" x="90.0" y="80.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_Bpq53Q">
<dc:Bounds x="10.0" y="10.0"/>
</bpmndi:BPMNLabel>
<bpmndi:BPMNShape bpmnElement="participant_wZ00fw" id="BPMNShape_axJq0A">
<dc:Bounds height="472.0" width="795.0" x="-50.0" y="20.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="lane_ubOYbA" id="BPMNShape_Lane_hzs0DQ">
<dc:Bounds height="200.0" width="770.0" x="120.0" y="80.0"/>
<bpmndi:BPMNShape bpmnElement="lane_dyB75Q" id="BPMNShape_Lane_M4b4GQ">
<dc:Bounds height="142.32794189453125" width="765.0" x="-20.0" y="20.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="lane_KsMpeA" id="BPMNShape_Lane_3xB0Kg">
<dc:Bounds height="200.0" width="770.0" x="120.0" y="280.0"/>
<bpmndi:BPMNShape bpmnElement="lane_0IRThw" id="BPMNShape_Lane_kyL9Tw">
<dc:Bounds height="172.67205810546875" width="765.0" x="-20.0" y="162.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="event_3WYx1Q" id="BPMNShape_ZxVvaQ">
<dc:Bounds height="36.0" width="36.0" x="210.0" y="120.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_JyZ3OA">
<dc:Bounds height="20.0" width="100.0" x="178.0" y="159.0"/>
</bpmndi:BPMNLabel>
<bpmndi:BPMNShape bpmnElement="lane_g3UiCw" id="BPMNShape_Lane_0YdP0A">
<dc:Bounds height="157.0" width="765.0" x="-20.0" y="334.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="event_REocCg" id="BPMNShape_O0Is1g">
<dc:Bounds height="36.0" width="36.0" x="770.0" y="390.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_S8prUg">
<dc:Bounds height="20.0" width="100.0" x="738.0" y="429.0"/>
</bpmndi:BPMNLabel>
<bpmndi:BPMNShape bpmnElement="task_ZAUT8A" id="BPMNShape_TvgRsA">
<dc:Bounds height="50.0" width="110.0" x="30.0" y="-70.0"/>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
Expand Down
41 changes: 41 additions & 0 deletions open-bpmn.glsp-client/workspace/test/collaboration-04.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:open-bpmn="http://open-bpmn.org/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exporter="org.openbpmn" exporterVersion="1.0.0" targetNamespace="http://open-bpmn.org">
<bpmn2:collaboration id="collaboration_1" name="Default Collaboration">
<bpmn2:participant id="participant_O3cmhw" name="Default Process" processRef="process_1"/>
<bpmn2:participant id="participant_AjLygg" name="Pool-1" processRef="process_fi0FXg">
<bpmn2:documentation id="documentation_xOZH7g"/>
</bpmn2:participant>
</bpmn2:collaboration>
<bpmn2:process definitionalCollaborationRef="collaboration_1" id="process_1" name="Default Process" processType="Public">
<bpmn2:documentation id="documentation_zdfteQ"/>
</bpmn2:process>
<bpmn2:process definitionalCollaborationRef="collaboration_1" id="process_fi0FXg" name="Pool-1" processType="Private">
<bpmn2:laneSet id="laneset_EFGbmw" name="Lane Set">
<bpmn2:lane id="lane_2To0Xw" name="Lane 1">
<bpmn2:documentation id="documentation_JBUmwA"/>
</bpmn2:lane>
<bpmn2:lane id="lane_0VvFFQ" name="Lane 2">
<bpmn2:documentation id="documentation_1rSaww"/>
</bpmn2:lane>
<bpmn2:lane id="lane_QE0Nvw" name="Lane 3">
<bpmn2:documentation id="documentation_S3lW0A"/>
</bpmn2:lane>
</bpmn2:laneSet>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1" name="OpenBPMN Diagram">
<bpmndi:BPMNPlane bpmnElement="collaboration_1" id="BPMNPlane_1">
<bpmndi:BPMNShape bpmnElement="participant_AjLygg" id="BPMNShape_rSyNZg">
<dc:Bounds height="485.0" width="805.0" x="40.0" y="30.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="lane_2To0Xw" id="BPMNShape_Lane_INI0CQ">
<dc:Bounds height="162.0" width="775.0" x="70.0" y="30.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="lane_0VvFFQ" id="BPMNShape_Lane_jxWWOg">
<dc:Bounds height="162.0" width="775.0" x="70.0" y="192.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="lane_QE0Nvw" id="BPMNShape_Lane_TDFJKQ">
<dc:Bounds height="161.0" width="775.0" x="70.0" y="354.0"/>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ private void updateLaneSizeByDividerPos(GNode gNode, double offsetY) throws BPMN
Participant participant = null;
String upperLaneID = gNode.getArgs().get("upperlaneid").toString();
String lowerLaneID = gNode.getArgs().get("lowerlaneid").toString();
logger.info("upper lane id = " + upperLaneID);

// Upper Lane
GNode upperGLane = modelState.getIndex().findElementByClass(upperLaneID, GNode.class)
Expand All @@ -198,7 +197,6 @@ private void updateLaneSizeByDividerPos(GNode gNode, double offsetY) throws BPMN
"Lane " + upperLaneID + " not found in model!");
}
String poolID = upperGLane.getParent().getId();
logger.info(" pool = " + poolID);
participant = modelState.getBpmnModel().findParticipantById(poolID);
upperBpmnLane = participant.openProcess().findLaneById(upperLaneID);
upperBpmnLane.setDimension(upperBpmnLane.getBounds().getDimension().getWidth(),
Expand Down Expand Up @@ -412,9 +410,6 @@ private void updatePool(final GNode gNode, final BPMNElementNode bpmnElementNode
bpmnBounds.getPosition().getY() + offsetY, newSize.getWidth(),
newSize.getHeight());

// if we have a Participant element selected than we also need to update
// all embedded FlowElements and also the LaneSet if available.

logger.debug("...update participant pool elements: offset= " + offsetX + " , " + offsetY);
updateLaneSet(participant, offsetWidth, offsetHeight);
updateEmbeddedElements(participant, offsetX, offsetY);
Expand Down Expand Up @@ -498,16 +493,10 @@ private void updateLaneSet(final Participant participant, final double offsetWid
}

// first we update the position of all Lanes if available
int laneCount = process.getLanes().size();
int offsetHeightRatio = (int) (offsetHeight / laneCount);
BPMNBounds poolBounds = participant.getBounds();

logger.debug(" ===> Pool Height = " + poolBounds.getDimension().getHeight());

int bpmnLaneX = (int) (poolBounds.getPosition().getX() + Participant.POOL_OFFSET);
int bpmnLaneY = (int) poolBounds.getPosition().getY();
int bpmnLaneWidth = (int) (poolBounds.getDimension().getWidth() - Participant.POOL_OFFSET);

double poolHeight = (int) poolBounds.getDimension().getHeight();
double lanesTotalHeight = 0;

Expand All @@ -523,7 +512,6 @@ private void updateLaneSet(final Participant participant, final double offsetWid
// In case we process the last lane, we always maximize the height to the rest
// of the pool height.
laneHeight = poolHeight - lanesTotalHeight;
logger.info("new lane height : " + laneHeight);
}
bpmnLaneBounds.setDimension(bpmnLaneWidth, laneHeight);
lanesTotalHeight = lanesTotalHeight + laneHeight;
Expand All @@ -532,109 +520,11 @@ private void updateLaneSet(final Participant participant, final double offsetWid
lane.setPosition(bpmnLaneX, bpmnLaneY);
// adjust laneY for the next iteration
bpmnLaneY = (int) (bpmnLaneY + bpmnLaneBounds.getDimension().getHeight());

// lanesTotalHeight = lanesTotalHeight +
// bpmnLaneBounds.getDimension().getHeight();

}

// update the height of the last lane with the new height offset

// double restHoehe=
// lane.setDimension(lane.getBounds().getDimension().getWidth() + offsetWidth,
// poolBounds.getDimension().getHeight() - bpmnLaneY);

// resize the model
modelState.reset();

}

@Deprecated
private void oldupdateLaneSet(final Participant participant, final double offsetWidth, final double offsetHeight)
throws BPMNMissingElementException {
BPMNProcess process = participant.openProcess();
Set<Lane> bpmnLaneSet = process.getLanes();

String processID = process.getId();
logger.debug("update laneSet for Process : " + processID);
if (bpmnLaneSet.size() == 0) {
return; // no op
}

// first we update the position of all Lanes if available
int laneCount = process.getLanes().size();
int offsetHeightRatio = (int) (offsetHeight / laneCount);
BPMNBounds poolBounds = participant.getBounds();

logger.debug(" ===> Pool Height = " + poolBounds.getDimension().getHeight());

int bpmnLaneX = (int) (poolBounds.getPosition().getX() + Participant.POOL_OFFSET);
int bpmnLaneY = (int) poolBounds.getPosition().getY();
int bpmnLaneWidth = (int) (poolBounds.getDimension().getWidth() - Participant.POOL_OFFSET);
int gLaneX = (int) Participant.POOL_OFFSET;
int gLaneY = 0;
int maxLaneHeight = (int) poolBounds.getDimension().getHeight();

Iterator<Lane> laneSetIterator = bpmnLaneSet.iterator();
while (laneSetIterator.hasNext()) {
// get BPMNBounds and GNode for this lane...
Lane lane = laneSetIterator.next();
BPMNBounds bpmnLaneBounds = lane.getBounds();
GNode gNode = null;
Optional<GNode> _node = modelState.getIndex().findElementByClass(lane.getId(), GNode.class);
if (_node.isPresent()) {
gNode = _node.get();
}
if (gNode == null) {
logger.warn("invalid LaneSet - model can not be synchronized!");
continue;
}

if (offsetWidth == 0 && offsetHeight == 0) {
// Update absolute BPMN position
lane.setPosition(bpmnLaneX, bpmnLaneY);
// adjust laneY for the next iteration
bpmnLaneY = (int) (bpmnLaneY + bpmnLaneBounds.getDimension().getHeight());
// no further update needed
continue;
}

// Update absolute BPMN position & dimension
int laneHeight = (int) (bpmnLaneBounds.getDimension().getHeight() + offsetHeightRatio);

// it can happen, that the height it to large for the current pool height. We
// check this and adjust the height if needed.
if ((!laneSetIterator.hasNext() && laneHeight != maxLaneHeight) || (laneHeight > maxLaneHeight)) {
logger.warn("BPMNlane height mismatch : current=" + laneHeight + " max available=" + maxLaneHeight);
laneHeight = maxLaneHeight;
logger.info("new lane height : " + laneHeight);
}

bpmnLaneBounds.setDimension(bpmnLaneWidth, laneHeight);

logger.debug(" ===> Lane " + lane.getId() + " new Height = " + bpmnLaneBounds.getDimension().getHeight());

lane.setPosition(bpmnLaneX, bpmnLaneY);
// adjust laneY for the next iteration
bpmnLaneY = (int) (bpmnLaneY + bpmnLaneBounds.getDimension().getHeight());

GDimension newLaneSize = GraphUtil.dimension(bpmnLaneWidth, laneHeight);
gNode.getLayoutOptions().put(GLayoutOptions.KEY_PREF_WIDTH, newLaneSize.getWidth());
gNode.getLayoutOptions().put(GLayoutOptions.KEY_PREF_HEIGHT, newLaneSize.getHeight());
// calling the size method does not have an effect.
// see:
// https://github.com/eclipse-glsp/glsp/discussions/741#discussioncomment-3688606
gNode.setSize(newLaneSize);

gNode.setPosition(GraphUtil.point(gLaneX, gLaneY));
// adjust gLaneY
gLaneY = gLaneY + laneHeight;
maxLaneHeight = maxLaneHeight - laneHeight;

}

}

/**
* This method updates the position for all BPMNElementNodes contained in a pool
* given a x and y offset. This method is needed because in BPMN all positions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public static GCompartment createBPMNContainerHeader(final BPMNGNode node) {
.id(node.getId() + "_header") //
.layout(GConstants.Layout.FREEFORM) //
.layoutOptions(layoutOptions) //
.addCssClass(node.getType() + "_header") //
.build();
}

Expand Down Expand Up @@ -317,7 +318,7 @@ public static String resolveFlowElementIDfromLabelID(final String id) {
* @param text
*/
@Deprecated
public static void optimizeBPMNLabelHeight(LabelGNode label, BPMNLabel bpmnLabel, String text) {
private static void xxxoptimizeBPMNLabelHeight(LabelGNode label, BPMNLabel bpmnLabel, String text) {
int FONT_SIZE = 20;

// resize based on the lines....
Expand Down

0 comments on commit e8c7a72

Please sign in to comment.