Skip to content

Adding Diagram Interaction (on the server)

Sören Domrös edited this page Apr 18, 2024 · 3 revisions

A clean way to add diagram interaction would be to create ISprottyActionHandler, e.g. the RectpackingInteractiveActionHandler that handles messages send via Sprotty actions and to register it. This registers the message in the KGraphTypeAdapterUtil.

The RectpackingInteractiveActionHandler registered via this service interface. By putting the fully qualified name of the class in a file with the fully qualified name of the service interface in the META-INF/services folder, it is registered (requires Klighd 3.0.X). This allows the KGraphDiagramServer to call the registered handlers in its accept method.

Since the handler needs the language client (or a subclass of it) to send something back, a ILanguageServerExtension that is an ILanguageClientProvider should be implemented and registered as done for the ISprottyActionHandler above. The RectpackingInteractiveLanguageServerExtension does not implement the client provider, since the client is manually added in the LSCreator.

For more details, it is advised to take a look at the interactive rectpacking implementations linked above.

A short guide how the client part of adding diagram interaction could look like can be found here.