From e8c7a722996118fb3543778fc17c3d047b268a73 Mon Sep 17 00:00:00 2001 From: Ralph Soika Date: Wed, 13 Sep 2023 17:53:25 +0200 Subject: [PATCH] impl, layout Issue #292 --- .../open-bpmn-glsp/css/diagram.css | 11 +- .../open-bpmn-glsp/src/bpmn-element-views.tsx | 6 +- .../open-bpmn-glsp/src/di.config.ts | 8 +- .../workspace/lane-resize.bpmn | 62 +++++----- .../workspace/test/collaboration-04.bpmn | 41 +++++++ .../BPMNChangeBoundsOperationHandler.java | 110 ------------------ .../openbpmn/glsp/utils/BPMNGModelUtil.java | 3 +- 7 files changed, 86 insertions(+), 155 deletions(-) create mode 100644 open-bpmn.glsp-client/workspace/test/collaboration-04.bpmn diff --git a/open-bpmn.glsp-client/open-bpmn-glsp/css/diagram.css b/open-bpmn.glsp-client/open-bpmn-glsp/css/diagram.css index 9761bbcc..ef2e4e0d 100644 --- a/open-bpmn.glsp-client/open-bpmn-glsp/css/diagram.css +++ b/open-bpmn.glsp-client/open-bpmn-glsp/css/diagram.css @@ -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; diff --git a/open-bpmn.glsp-client/open-bpmn-glsp/src/bpmn-element-views.tsx b/open-bpmn.glsp-client/open-bpmn-glsp/src/bpmn-element-views.tsx index e959c410..0f8eabcd 100644 --- a/open-bpmn.glsp-client/open-bpmn-glsp/src/bpmn-element-views.tsx +++ b/open-bpmn.glsp-client/open-bpmn-glsp/src/bpmn-element-views.tsx @@ -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, context: RenderingContext): VNode | undefined { if (!this.isVisible(element, context)) { return undefined; } @@ -208,8 +208,8 @@ export class PoolHeaderView extends ShapeView { labelYOffset=containerNode.bounds.height*0.5; } const vnode: any = ( - - + {containerLabel} diff --git a/open-bpmn.glsp-client/open-bpmn-glsp/src/di.config.ts b/open-bpmn.glsp-client/open-bpmn-glsp/src/di.config.ts index ece3870c..be59e9ec 100644 --- a/open-bpmn.glsp-client/open-bpmn-glsp/src/di.config.ts +++ b/open-bpmn.glsp-client/open-bpmn-glsp/src/di.config.ts @@ -34,7 +34,8 @@ import { editLabelFeature, initializeDiagramContainer, moveFeature, - overrideViewerOptions + overrideViewerOptions, + selectFeature } from '@eclipse-glsp/client'; import { BPMNEdge, @@ -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); diff --git a/open-bpmn.glsp-client/workspace/lane-resize.bpmn b/open-bpmn.glsp-client/workspace/lane-resize.bpmn index dcefa463..7c68580e 100644 --- a/open-bpmn.glsp-client/workspace/lane-resize.bpmn +++ b/open-bpmn.glsp-client/workspace/lane-resize.bpmn @@ -1,57 +1,47 @@ - + - - + + + + + + - - - - - event_3WYx1Q + + + + - - - event_REocCg + + + + + - - - - - - - - - - - + + - - + + - - + + - - - - - + + - - - - - + + diff --git a/open-bpmn.glsp-client/workspace/test/collaboration-04.bpmn b/open-bpmn.glsp-client/workspace/test/collaboration-04.bpmn new file mode 100644 index 00000000..7e58a19b --- /dev/null +++ b/open-bpmn.glsp-client/workspace/test/collaboration-04.bpmn @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/open-bpmn.glsp-server/src/main/java/org/openbpmn/glsp/operations/BPMNChangeBoundsOperationHandler.java b/open-bpmn.glsp-server/src/main/java/org/openbpmn/glsp/operations/BPMNChangeBoundsOperationHandler.java index 305424c0..b370bdb6 100644 --- a/open-bpmn.glsp-server/src/main/java/org/openbpmn/glsp/operations/BPMNChangeBoundsOperationHandler.java +++ b/open-bpmn.glsp-server/src/main/java/org/openbpmn/glsp/operations/BPMNChangeBoundsOperationHandler.java @@ -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) @@ -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(), @@ -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); @@ -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; @@ -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; @@ -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 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 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 _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 diff --git a/open-bpmn.glsp-server/src/main/java/org/openbpmn/glsp/utils/BPMNGModelUtil.java b/open-bpmn.glsp-server/src/main/java/org/openbpmn/glsp/utils/BPMNGModelUtil.java index 3d2996f7..a0aa8236 100644 --- a/open-bpmn.glsp-server/src/main/java/org/openbpmn/glsp/utils/BPMNGModelUtil.java +++ b/open-bpmn.glsp-server/src/main/java/org/openbpmn/glsp/utils/BPMNGModelUtil.java @@ -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(); } @@ -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....