-
hi, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
HI @wss29, This has changed with 2.0.0. Diagram widgets are now fully injectable and it is no longer necessary to customize the diagram manager. Next create your custom diagram widget (using the example provided in #999): import { GLSPDiagramWidget } from '@eclipse-glsp/theia-integration';
import { Message } from '@phosphor/messaging/lib';
import { MessageService } from '@theia/core/lib/common/message-service';
import { inject, injectable } from '@theia/core/shared/inversify';
@injectable()
export class MyDiagramWidget extends GLSPDiagramWidget {
@inject(MessageService)
protected messageService: MessageService;
protected override onAfterDetach(msg: Message): void {
this.messageService.info('Diagram detached');
}
} Finally all you have to do is adapting your override configure(context: ContainerContext): void {
context.rebind(GLSPDiagramWidget).to(MyDiagramWidget);
} If you are using multiple diagram langauges that should use different custom widgets you have to override the override bindDiagramWidgetFactory(context: ContainerContext): void {
context.bind(MyDiagramWidget).toSelf();
context
.bind<DiagramWidgetFactory>(DiagramWidgetFactory)
.toDynamicValue(ctx => ({
diagramType: this.diagramLanguage.diagramType,
create: (options, diagramDiContainer) => {
const diagramWidget = ctx.container.get(MyDiagramWidget);
diagramWidget.configure(options, diagramDiContainer);
return diagramWidget;
}
}))
.inSingletonScope();
} |
Beta Was this translation helpful? Give feedback.
-
thanks very much |
Beta Was this translation helpful? Give feedback.
Note that if you just want to dispose a resource in your custom
UIExtension
its no longer necessary to create a custom widget at all.With 2.0.0 the diagram container is now unloaded when the Diagram is closed. This means you can use the
@preDestroy
annotation of inversify to trigger your dispose method when the diagram is closed: