Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#738: Add route data to ComputedBoundsAction #201

Merged
merged 1 commit into from
Nov 14, 2022
Merged

Conversation

martin-fleck-at
Copy link
Contributor

Copy link
Contributor

@tortmayr tortmayr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Martin. Seems to work fine and I only have a few minor nitpicks.

@tortmayr
Copy link
Contributor

tortmayr commented Oct 16, 2022

If I'm not mistaken we could also refactor the ChangeBoundsTool with this change.
We logic in there that updated the routing points of connected edges when moving an element:

protected handleMoveRoutingPointsOnServer(target: SModelElement): Operation[] {

This should no longer be necessary as the updated routing points will be sent with the "ComputedBoundsAction` anyways

@martin-fleck-at
Copy link
Contributor Author

Thank you very much for your feedback, Tobias! I updated my code accordingly. Following the discussion in eclipse-glsp/glsp#767, I also added the source and target point to the arguments of the edge and renamed the field from 'routingPoints' to 'route' which is much more accurate now.

If I'm not mistaken we could also refactor the ChangeBoundsTool with this change. We logic in there that updated the routing points of connected edges when moving an element:

protected handleMoveRoutingPointsOnServer(target: SModelElement): Operation[] {

This should no longer be necessary as the updated routing points will be sent with the "ComputedBoundsAction` anyways

You are right, I removed that call.

@martin-fleck-at martin-fleck-at changed the title #738: Add routing points to ComputedBoundsAction #738: Add route data to ComputedBoundsAction Oct 17, 2022
@tortmayr
Copy link
Contributor

Thanks for the update. In general the changes look good to me. During testing, I encountered a weird bug. The manhattan routing now seems to be broken in certain cases i.e. the visual feedback on the client side and the final router after the server update are different:
routing_bug

This occurs for instance when you delete route segments by moving the target element (backtracking on the route).
Seems to me like the server somehow caches the old route values

@rsoika
Copy link

rsoika commented Nov 8, 2022

@martin-fleck-at what is your opinion about the finding from @tortmayr ? I think one issue with the new implementation is, that the server part must now also deal with this scenario. This is different as you usually would do it.
I am still interested in this solution. But expect also that I need to do more stuff on the server side to get the complete modeling cycle working correctly.

Just to give you an impression about my current thoughts: When I load an external BPMN model into my GLSP-OpenBPMN modeler, I now do remove the first and last 'way-point' from the source model information when I transfer the model into GLSP. This is to align the behavior to the GLSP Client.
With the new implementation I would expect, that I add the start- and end-point again into my source model waypoint list to get a valid BPMN model back which is compatible with external modelers.

If you want to make me an early Christmas present, then we could do a web conference about this topic? Just to clarify what we 3 really expect from this change. What do you think?

@martin-fleck-at
Copy link
Contributor Author

@tortmayr I pushed an update that should fix the issue that you were seeing. In short: The change bounds operation caused a request bounds from the server with the "old" (i.e., updated bounds but no routing points) model resulting in a wrong layout on the server. I kept the code that updates the routing points with the change bounds operation and then everything works as expected again: Now you receive the full route on any computed bounds action (i.e., every operation) and can do custom layouting on it.

@rsoika Could you please elaborate on the problem that you foresee with this implementation?

This is how I see it: If you have a custom layouter registered as a layout engine, it should receive the up to date route information as soon as it is available, i.e., that is the routing points on the edge as well as the start and end position as edge arguments. The start and end point are determined on the client and cannot be set directly from outside but depend on your routing strategy and the source and target element that is set.

From what I understand, you would like to set the start and end point directly from the server, is that it? I think in that case you would need to provide a custom router. At the moment, the Manhattan router creates the default anchors (positions) for source and target based on the given source and target element and a given side (right, left, top, bottom).

If there are still some unclear points, we can have a quick discussion online, sure.

@rsoika
Copy link

rsoika commented Nov 9, 2022

@martin-fleck-at Thanks for your update. I think we are fine with the over all concept as you explained it.

When I load a external BPMN file I need to remove the start and endpoint when building the GLSP Edge/Routing Point information. This is fine and I have already implemented this part.
And with your new implementation - I expect -

  • I can now also find out the start and endpoint information (change bounds operation)
  • add/update this information again into my BPMN source model,
  • and so this file will be standard conform again and it can be loaded with other BPMN tools correctly.

Of course I will test it as soon as possible and I will provide you my feedback (and a short demo).

Should I build the GLSP client from sources or can I take a nightly build (which would be more save to work on the correct code base)?

@tortmayr
Copy link
Contributor

tortmayr commented Nov 9, 2022

@rsoika I'm going to review this PR tomorrow. Each change on master automatically triggers a new nightly build so once its merged you can test it by consuming the corresponding next/snapshot version from npm/maven.

@martin-fleck-at
Copy link
Contributor Author

@rsoika Yes, it should work exactly the way that you describe. There will be a few utility methods to support you in dealing with routes on the server:

@tortmayr tortmayr self-requested a review November 14, 2022 16:09
Copy link
Contributor

@tortmayr tortmayr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Martin!
Works like a charm. 👍🏼

@martin-fleck-at martin-fleck-at merged commit b15d96b into master Nov 14, 2022
@martin-fleck-at martin-fleck-at deleted the issue-738 branch November 14, 2022 16:21
@rsoika
Copy link

rsoika commented Nov 27, 2022

@martin-fleck-at I try to use the new glsp client version @eclipse-glsp/client": "1.1.0-RC02" to update my GLSP client code.

But I run into some compiler issues which I can't solve. For example a code like this (from the workflow example):

@injectable()
export class IconView extends ShapeView {
    render(element: Icon, context: RenderingContext): VNode | undefined {
        let scaleFactor = 1;
        let translateX = 0;
        let translateY = 0;
        if (!this.isVisible(element, context)) {
            return undefined;
        }
   ....
}

Gets no longer compiled with the following error message:

@open-bpmn/open-bpmn-glsp: src/bpmn-element-views.tsx(56,5): error TS2416: Property 'render' in type 'IconView' is not assignable to the same property in base type 'ShapeView'.
@open-bpmn/open-bpmn-glsp:   Type '(element: Icon, context: RenderingContext) => VNode | undefined' is not assignable to type '(model: Readonly<SChildElement>, context: RenderingContext, args?: IViewArgs | undefined) => VNode | undefined'.
@open-bpmn/open-bpmn-glsp:     Types of parameters 'element' and 'model' are incompatible.
@open-bpmn/open-bpmn-glsp:       Type 'Readonly<SChildElement>' is missing the following properties from type 'Icon': layout, size, position, bounds
@open-bpmn/open-bpmn-glsp: src/bpmn-element-views.tsx(60,29): error TS2345: Argument of type 'Icon' is not assignable to parameter of type 'Readonly<SChildElement & BoundsAware>'.
@open-bpmn/open-bpmn-glsp:   The types of 'parent.children' are incompatible between these types.
@open-bpmn/open-bpmn-glsp:     Type 'readonly import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/@eclipse-glsp/client/node_modules/sprotty/lib/base/model/smodel").SChildElement[]' is not assignable to type 'readonly import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/sprotty/lib/base/model/smodel").SChildElement[]'.
@open-bpmn/open-bpmn-glsp:       Type 'import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/@eclipse-glsp/client/node_modules/sprotty/lib/base/model/smodel").SChildElement' is not assignable to type 'import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/sprotty/lib/base/model/smodel").SChildElement'.
@open-bpmn/open-bpmn-glsp:         Types of property 'add' are incompatible.
@open-bpmn/open-bpmn-glsp:           Type '(child: import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/@eclipse-glsp/client/node_modules/sprotty/lib/base/model/smodel").SChildElement, index?: number | undefined) => void' is not assignable to type '(child: import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/sprotty/lib/base/model/smodel").SChildElement, index?: number | undefined) => void'.
@open-bpmn/open-bpmn-glsp:             Types of parameters 'child' and 'child' are incompatible.
@open-bpmn/open-bpmn-glsp:               Type 'import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/sprotty/lib/base/model/smodel").SChildElement' is not assignable to type 'import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/@eclipse-glsp/client/node_modules/sprotty/lib/base/model/smodel").SChildElement'.
@open-bpmn/open-bpmn-glsp:                 The types of 'parent.root.index' are incompatible between these types.
@open-bpmn/open-bpmn-glsp:                   Type 'import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/sprotty/lib/base/model/smodel").ModelIndexImpl' is not assignable to type 'import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/@eclipse-glsp/client/node_modules/sprotty/lib/base/model/smodel").ModelIndexImpl'.
@open-bpmn/open-bpmn-glsp:                     Types have separate declarations of a private property 'id2element'.
@open-bpmn/open-bpmn-glsp: src/bpmn-element-views.tsx(64,46): error TS2345: Argument of type 'Icon' is not assignable to parameter of type 'SModelElement'.

My dependencies look like this:

...
  "dependencies": {
    "@eclipse-glsp/client": "1.1.0-RC02",
    "@open-bpmn/open-bpmn-model": "0.6.0",
    "@open-bpmn/open-bpmn-properties": "0.6.0",
    "balloon-css": "^0.5.0"
  },
  "peerDependencies": {
    "react": "^16.12.0",
    "react-dom": "^16.12.0"
  },
....

my open-pmn-model and open-bpmn-properties works with 1.1.0-RC02.
Can you give me a hint what this error message tries to tell me?

(also switching @eclipse-glsp/config to latest 1.1.0-next.fe535db.107 did not solve this issue)

@tortmayr
Copy link
Contributor

Hi Ralph,
at first glance this looks like a sprotty Version mismatch to me. Is seems like that the GLSP client resolves a different sprotty version than the glsp-theia integration. For the moment I would recommend to use yarn resolutions to resolve this issue. (i.e.: https://github.com/eclipse-glsp/glsp-theia-integration/blob/master/package.json#L40). We are working on a solution for these kind of versioning problems but they require an upstream fix in Theia which is not merged yet (eclipse-theia/theia#11808)

@rsoika
Copy link

rsoika commented Nov 28, 2022

@tortmayr yes, after adding the following dependency int my module,

"sprotty": "0.13.0-next.1c4343c.328",

it compiles fine again.
I thought I did not need to add such kind of dependencies as long as I define the GLSP client dependency. And in 1.1.0-RC02 the sprotty dependency is already defined.

"sprotty": "0.13.0-next.1c4343c.328"

strange....

@tortmayr
Copy link
Contributor

I thought I did not need to add such kind of dependencies as long as I define the GLSP client dependency. And in 1.1.0-RC02 the sprotty dependency is already defined.

"sprotty": "0.13.0-next.1c4343c.328"

strange....

The problem is that that sprotty-theia (which is indirectly used by the theia-integration) depends on a different version of sprotty (https://github.com/eclipse/sprotty-theia/blob/efd153a410267d81af555e70c219e9efa3e3b197/package.json#L44). Which means we end up with two different resolved versions and as a consequence two (only partly initialized) DI containers.

As I mentioned we already have a solution for this and are just waiting for the upstream fix in Theia so that we can implement it.

@rsoika
Copy link

rsoika commented Nov 28, 2022

ok great thanks.

I am really sorry but I run into a new problem now. It seems like I run into a version problem between my client and my server part. When I try to open a diagram the following exception is thrown on the server side:

Caused by: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Protocol version mismatch! The client protocol version '0.9.0' is not compatible with the server protocol version '1.0.0'!
	at org.eclipse.glsp.server.protocol.DefaultGLSPServer.validateProtocolVersion(DefaultGLSPServer.java:97)
	at org.eclipse.glsp.server.protocol.DefaultGLSPServer.initialize(DefaultGLSPServer.java:69)
	... 16 more

I tried the org.eclipse.glsp.server versions 1.1.0.RC02 and 1.1.0-SNAPSHOT. But both show the same exception. Do you have an idea where this message is coming from?

Does this mean my client is using the wrong/old version?

@tortmayr
Copy link
Contributor

Does this mean my client is using the wrong/old version?

Yes, it looks like the client version did not get properly updated. I just double checked and the RC02 Version indeed references the client version "next" instead of "1.1.0-RC02". (https://github.com/eclipse-glsp/glsp-theia-integration/blob/1b73a55849801eb3f1cfd4ecd6bdeb29938de5f7/packages/theia-integration/package.json#L38%5D(https://github.com/eclipse-glsp/glsp-theia-integration/blob/1b73a55849801eb3f1cfd4ecd6bdeb29938de5f7/packages/theia-integration/package.json#L38))
This means the "old", cached next of the yarn.lock file is used.
We will fix this with the upcoming RC03 (at the beginning of next month). In the meantime I'd recommend to fix the client version via yarn to 1.1.0-RC02.

Sorry for the inconveniences, we are still working on improving our automated release candidates so feature versions are hopefully more stable and less error prone 😉

@rsoika
Copy link

rsoika commented Nov 28, 2022

Thanks, I tried to fix it, but did not succeed.
I will wait for you and the RC03 - I don't want to mess up my package.json files to much. (you know I am not an expert in this ;-)

By the way: I know you taught me I should not touch the yarn.lock file in my git repo. But in the past I run too often into situations where the build was not working after I changed dependency versions. Now I changed my clean-up script and now I also remove the yarn.lock file.
This is like my build.sh script looks today: https://github.com/imixs/open-bpmn/blob/master/build.sh
I know you don't need that but maybe we can at least put something similar into the workflow example?

@tortmayr
Copy link
Contributor

tortmayr commented Dec 6, 2022

The Release Candidate 03 is now available.

@rsoika
Copy link

rsoika commented Dec 8, 2022

@tortmayr I upgraded to

"@eclipse-glsp/client": "1.1.0-RC03",
"sprotty": "0.13.0-next.1c4343c.328",

The server code depends on org.eclipse.glsp.server -1.1.0-SNAPSHOT (also tried 1.1.0.RC03)

Build process of frontend and backend is fine.
But when I try to open a diagram, I still see the following error message on the server:

2022-12-08 23:27:28,102602291 [Thread-5] INFO  SocketGLSPServerLauncher - Starting GLSP server connection for client /127.0.0.1:35166
2022-12-08 23:27:28,114795544 [pool-2-thread-1] DEBUG DefaultGLSPServer - Initializing server with the following params:
InitializeParameters [applicationId=c4ff802a-7466-4d75-9a2c-f1237fcb17ab, protocolVersion=0.9.0, args={  } ]
Dez. 08, 2022 11:27:28 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError
SCHWERWIEGEND: Internal error: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	... 11 more
Caused by: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Protocol version mismatch! The client protocol version '0.9.0' is not compatible with the server protocol version '1.0.0'!
	at org.eclipse.glsp.server.protocol.DefaultGLSPServer.validateProtocolVersion(DefaultGLSPServer.java:97)
	at org.eclipse.glsp.server.protocol.DefaultGLSPServer.initialize(DefaultGLSPServer.java:69)
	... 16 more

It seems that there is still something wrong with my project setup.

I also switched to theia 1.27.0 and

"@eclipse-glsp/theia-integration": "^1.0.0-theia1.27.0"

How can I figure out from where the old protocol version 0.9.0 is coming from ?

@rsoika
Copy link

rsoika commented Dec 8, 2022

I found out, that deep in my node_modules I still have a code setting the protocolVersion to 0.9.0

image

I guess this is the root of the problem and I should use a different theia-integration verision than

"@eclipse-glsp/theia-integration": "^1.0.0-theia1.27.0"

@rsoika
Copy link

rsoika commented Dec 8, 2022

ok... we are near....

I changed the @eclipse-glsp/theia-integration version from ^1.0.0-theia1.27.0 to ^1.1.0-RC03
I guess this is the expected version.

But now my BPMNDiagramConfiguration is broken

import { createBPMNDiagramContainer } from '@open-bpmn/open-bpmn-glsp';
import {
    configureDiagramServer,
    GLSPDiagramConfiguration,
    GLSPTheiaDiagramServer,
    TheiaDiagramServer
} from '@eclipse-glsp/theia-integration/lib/browser';
import { Container, injectable } from 'inversify';
import 'sprotty-theia/css/theia-sprotty.css';
import { BPMNLanguage } from '../../common/bpmn-language';

@injectable()
export class BPMNDiagramConfiguration extends GLSPDiagramConfiguration {
    diagramType: string = BPMNLanguage.diagramType;

    doCreateContainer(widgetId: string): Container {
        const container = createBPMNDiagramContainer(widgetId);
        configureDiagramServer(container, GLSPTheiaDiagramServer);
        container.bind(TheiaDiagramServer).toService(GLSPTheiaDiagramServer);
        return container;
    }
}

I get now this compiler error:

@open-bpmn/open-bpmn-theia: src/browser/diagram/bpmn-diagram-configuration.ts(34,54): error TS2345: Argument of type 'typeof GLSPTheiaDiagramServer' is not assignable to parameter of type 'ServiceIdentifier<TheiaDiagramServer>'.
@open-bpmn/open-bpmn-theia:   Type 'typeof GLSPTheiaDiagramServer' is not assignable to type 'Newable<TheiaDiagramServer>'.
@open-bpmn/open-bpmn-theia:     Construct signature return types 'GLSPTheiaDiagramServer' and 'TheiaDiagramServer' are incompatible.
@open-bpmn/open-bpmn-theia:       The types of 'initialize' are incompatible between these types.
@open-bpmn/open-bpmn-theia:         Type '(registry: import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/sprotty/lib/base/actions/action-handler").ActionHandlerRegistry) => void' is not assignable to type '(registry: import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/sprotty-theia/node_modules/sprotty/lib/base/actions/action-handler").ActionHandlerRegistry) => void'.
@open-bpmn/open-bpmn-theia:           Types of parameters 'registry' and 'registry' are incompatible.
@open-bpmn/open-bpmn-theia:             Type 'import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/sprotty-theia/node_modules/sprotty/lib/base/actions/action-handler").ActionHandlerRegistry' is not assignable to type 'import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/sprotty/lib/base/actions/action-handler").ActionHandlerRegistry'.
@open-bpmn/open-bpmn-theia:               Property 'elements' is protected but type 'MultiInstanceRegistry<T>' is not a class derived from 'MultiInstanceRegistry<T>'.
@open-bpmn/open-bpmn-theia: error Command failed with exit code 2.
@open-bpmn/open-bpmn-theia: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@open-bpmn/open-bpmn-theia: error Command failed with exit code 2.
@open-bpmn/open-bpmn-theia: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR! yarn run prepare exited 2 in '@open-bpmn/open-bpmn-theia'

Can you point me to a workflow-example branch where I can verify my general setup. I guess I have to update my code

@tortmayr
Copy link
Contributor

tortmayr commented Dec 8, 2022

I guess this is the root of the problem and I should use a different theia-integration verision than

"@eclipse-glsp/theia-integration": "^1.0.0-theia1.27.0"

Yes, I guess so to. You should be able to use the 1.1.0-RC03 version for all glsp components.

How can I figure out from where the old protocol version 0.9.0 is coming from ?

You can use the yarn why command for this. It lists a bunch of information to identify why a particular package (version) has been installed. So in your case, you could use yarn why @eclipse-glsp/protocol

@tortmayr
Copy link
Contributor

tortmayr commented Dec 8, 2022

I get now this compiler error:

@open-bpmn/open-bpmn-theia: src/browser/diagram/bpmn-diagram-configuration.ts(34,54): error TS2345: Argument of type 'typeof GLSPTheiaDiagramServer' is not assignable to parameter of type 'ServiceIdentifier<TheiaDiagramServer>'.
@open-bpmn/open-bpmn-theia:   Type 'typeof GLSPTheiaDiagramServer' is not assignable to type 'Newable<TheiaDiagramServer>'.
@open-bpmn/open-bpmn-theia:     Construct signature return types 'GLSPTheiaDiagramServer' and 'TheiaDiagramServer' are incompatible.
@open-bpmn/open-bpmn-theia:       The types of 'initialize' are incompatible between these types.
@open-bpmn/open-bpmn-theia:         Type '(registry: import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/sprotty/lib/base/actions/action-handler").ActionHandlerRegistry) => void' is not assignable to type '(registry: import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/sprotty-theia/node_modules/sprotty/lib/base/actions/action-handler").ActionHandlerRegistry) => void'.
@open-bpmn/open-bpmn-theia:           Types of parameters 'registry' and 'registry' are incompatible.
@open-bpmn/open-bpmn-theia:             Type 'import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/sprotty-theia/node_modules/sprotty/lib/base/actions/action-handler").ActionHandlerRegistry' is not assignable to type 'import("/home/rsoika/git/open-bpmn/open-bpmn.glsp-client/node_modules/sprotty/lib/base/actions/action-handler").ActionHandlerRegistry'.
@open-bpmn/open-bpmn-theia:               Property 'elements' is protected but type 'MultiInstanceRegistry<T>' is not a class derived from 'MultiInstanceRegistry<T>'.
@open-bpmn/open-bpmn-theia: error Command failed with exit code 2.
@open-bpmn/open-bpmn-theia: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@open-bpmn/open-bpmn-theia: error Command failed with exit code 2.
@open-bpmn/open-bpmn-theia: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR! yarn run prepare exited 2 in '@open-bpmn/open-bpmn-theia'

Can you point me to a workflow-example branch where I can verify my general setup. I guess I have to update my code

At first glance, this looks like the sprotty version conflict you already encountered previously. Please make sure that sprotty is part of your resolutions block to enforce the resolution of the required version.

@rsoika
Copy link

rsoika commented Dec 9, 2022

@tortmayr Thanks! adding "sprotty": "0.13.0-next.1c4343c.328" to the resolutions block in my parent package.yaml solved the problem. Before I always added it to the dependencies section of the specific module. But this is not necessary or was my fault from the beginning. Thanks for helping.

@rsoika
Copy link

rsoika commented Dec 9, 2022

@martin-fleck-at @tortmayr
Hi,
I can now also confirm that the new routing behavior of version 1.1.0.RC03 works perfect! Because I am still surprised about the general concept I would like to explain my concrete implementation:

I have now implemented one custom ChangeRoutingPointsOperationHandler and one custom ComputedBoundsActionHandler

The BPMNComputedBoundsActionHandler is only responsible to store the routing information of an edge (BPMNSequenceFlow) into the BPMN Source Model:

public class BPMNComputedBoundsActionHandler extends AbstractActionHandler<ComputedBoundsAction> {
    @Inject
    protected BPMNGModelState modelState;

    @Override
    protected List<Action> executeAction(final ComputedBoundsAction actualAction) {
        BPMNProcess context = modelState.getBpmnModel().openDefaultProcess();
        List<ElementAndRoutingPoints> routings = actualAction.getRoutes();
        try {
            for (ElementAndRoutingPoints routingInfo : routings) {
                String id = routingInfo.getElementId();
                BPMNSequenceFlow bpmnSequenceFlow = context.findBPMNSequenceFlowById(id);
                if (bpmnSequenceFlow != null) {
                    List<GPoint> newGLSPRoutingPoints = routingInfo.getNewRoutingPoints();
                    // update the BPMN Waypoint.
                    System.out.println("===== Updating " + newGLSPRoutingPoints.size() + " BPMN WayPoints  =======");
                    bpmnSequenceFlow.clearWayPoints();
                    // add the new routing points
                    for (GPoint point : newGLSPRoutingPoints) {
                        BPMNPoint bpmnPoint = new BPMNPoint(point.getX(), point.getY());
                        bpmnSequenceFlow.addWayPoint(bpmnPoint);
                    }
                } 
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        // no more action - the GModel is now up to date
        return none();
    }
}

The BPMNChangeRoutingPointsOperationHandler is only responsible to update the GModel.

public class BPMNChangeRoutingPointsOperationHandler extends AbstractOperationHandler<ChangeRoutingPointsOperation> {
    @Inject
    protected BPMNGModelState modelState;

    @Override
    public void executeOperation(final ChangeRoutingPointsOperation operation) {
        List<ElementAndRoutingPoints> routingPoints = operation.getNewRoutingPoints();
        try {
            for (ElementAndRoutingPoints routingPoint : routingPoints) {
                String id = routingPoint.getElementId();
                List<GPoint> newGLSPRoutingPoints = routingPoint.getNewRoutingPoints();
                // update the GModel.
                Optional<GEdge> _edge = modelState.getIndex().findElementByClass(id, GEdge.class);
                if (_edge.isPresent()) {
                    GEdge edge = _edge.get();
                    edge.getRoutingPoints().clear();
                    edge.getRoutingPoints().addAll(newGLSPRoutingPoints);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        // no more action - the GModel is now up to date
    }

}

Both implementations are necessary.

As a result, the BPMN source Model information and the GModel in the diagram plane is now always exactly what I expected. So I don't want any more changes. I am absolutely happy!

Can you only answer me one last question in brief:

How would you describe the function of a ChangeRoutingPointsOperation and how the function of a ComputedBoundsAction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants