GLSP Server-Client Setup for two file extensions. #1167
Replies: 1 comment 2 replies
-
Hi @we-wake-act21, A GLSP server can handle multiple different diagram types (i.e. diagram containers) so it is possible to use a combined server On the server side the implementation is pretty straight-forward. Simply implement the ServerModule myServerModule = new ServerModule()
.configureDiagramModule(new Lang1DiagramModule())
.configureDiagramModule(new Lang2DiagramModule()); That`s it. Once the client initializes a new client session it passed the desired diagram-type and the server will initialize new container Now let's look at the Theia/Client side: export const Lang1: GLSPDiagramLanguage = {
contributionId: 'lang',
label: 'Lang1 Diagram',
diagramType: 'lang1-diagram',
fileExtensions: ['.lang1],
};
export const Lang2: GLSPDiagramLanguage = {
contributionId: 'lang',
label: 'Lang2 Diagram',
diagramType: 'lang2-diagram',
fileExtensions: ['.lang2]
}; What is important here is that both languages use the same The first language can be implemented with the default approach used in the examples i.e. create custom For the second language the implementation is a bit different. Here we don't need a backend implementation since we want to connect to the sever provided by the first language. So we just need to configure another class Lang2FrontendModule extends GLSPTheiaFrontendModule {
readonly diagramLanguage = Lang2;
protected override enableLayoutCommands = false;
protected override enableMarkerNavigationCommands = false;
protected override enableCopyPaste = false;
bindDiagramConfiguration(context: ContainerContext): void {
context.bind(DiagramConfiguration).to(Lang2DiagramConfiguration);
}
override bindGLSPClientContribution(context: ContainerContext): void {}
} Note that we don't bind a In theory that's it, however, note that there have been a couple of issues reported regarding multi editor integration.
Please feel free to add a comment to the issue if you encounter any other problems. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am building an application that consists of two separate models [ 'lang1','lang2']. Now I want to integrate this within a single application using theia.
Both lang1 & lang2 have their own fileExtensions , layouters & GModelFactory's.
what will be the best approach on integrating the applications together.
should I create separate GLSP-server & GLSP-client ?
or is it possible to have a single GLSP server and client with different diagram-containers?
or any other way I can approach this?
Beta Was this translation helpful? Give feedback.
All reactions