Replies: 4 comments 4 replies
-
Hi @rsoika, the good news is that this issue is fixed with eclipse-glsp/glsp-client#305. With 2.0.0 I can reproduce your problem, but for me the workaround with the @injectable()
export class BPMNPropertyPanel extends AbstractUIExtension implements ISelectionListener, IActionHandler, IDiagramStartup {
@inject(ActionDispatcherFactory)
protected readonly actionDispatcherFactory: ActionDispatcherFactory;
private _actionDispatcher?: GLSPActionDispatcher;
get actionDispatcher(): GLSPActionDispatcher {
if (!this._actionDispatcher) {
this._actionDispatcher = this.actionDispatcherFactory();
}
return this._actionDispatcher;
}
override id(): string {
return 'test';
}
override containerClass(): string {
return 'test';
}
protected override initializeContents(containerElement: HTMLElement): void {
containerElement.innerHTML = 'Hello World';
}
handle(action: Action): void | Action | ICommand {
this.actionDispatcher.dispatch(StatusAction.create('Set model action'));
}
selectionChanged(root: Readonly<GModelRoot>, selectedElements: string[], deselectedElements?: string[] | undefined): void {
console.log('Here is the selection', selectedElements);
}
preInitialize?(): MaybePromise<void>;
}
// bindings
bind(BPMNPropertyPanel).toSelf().inSingletonScope();
bind(ActionDispatcherFactory).toFactory<GLSPActionDispatcher>(
ctx => () => ctx.container.get<GLSPActionDispatcher>(TYPES.IActionDispatcher)
);
bind(TYPES.IUIExtension).toService(BPMNPropertyPanel);
bind(TYPES.IDiagramStartup).toService(BPMNPropertyPanel);
bind(TYPES.ISelectionListener).toService(BPMNPropertyPanel);
configureActionHandler({ bind, isBound }, SetModelAction.KIND, BPMNPropertyPanel);
No that should not be a problem. Symbols in JS are unique, the string in the constructor more or less just serves as a description. Side note:
This should no longer be necessary. Looking at the current implementation it seems like the |
Beta Was this translation helpful? Give feedback.
-
So, finally I found a way to get around the Circular dependency in In my previous code I used the @injectable()
export class BPMNPropertyPanel extends AbstractUIExtension implements IDiagramStartup, ISelectionListener, IActionHandler {
...
@inject(EditorContextService)
protected editorContext: EditorContextService;
..
postModelInitialization(): MaybePromise<void> {
this.show(this.editorContext.modelRoot);
} and this causes a Circular dependency. My solution is now to still use the method @injectable()
export class BPMNPropertyPanel extends AbstractUIExtension implements IDiagramStartup, ISelectionListener, IActionHandler {
....
modelRoot: Readonly<GModelRoot>;
...
protected override onBeforeShow(_containerElement: HTMLElement, root: Readonly<GModelRoot>): void {
this.modelRoot = root;
}
..
postModelInitialization(): MaybePromise<void> {
this.show(this.modelRoot);
} But the question to me is: why is not
|
Beta Was this translation helpful? Give feedback.
-
HI, @tortmayr, I need to come back to this discussion. Now that I am on GLSP 2.1 I have the problem that I do no longer receive the GModelRoot during initialization phase. Neither in method I expected that the workaround with injecting the The question is for what You can see my implementation here and the bindings here. Additional note: injecting the |
Beta Was this translation helpful? Give feedback.
-
Hi @rsoika, the As you already noticed currently the interface does not have any notion of the GModelRoot: /**
* Services that implement startup hooks which are invoked during the {@link DiagramLoader.load} process.
* Typically used to dispatch additional initial actions and/or activate UI extensions on startup.
* Execution order is derived by the `rank` property of the service. If not present, the {@link Ranked.DEFAULT_RANK} will be assumed.
*/
export interface IDiagramStartup extends Partial<Ranked> {
/**
* Hook for services that should be executed before the underlying GLSP client is configured and the server is initialized.
*/
preInitialize?(): MaybePromise<void>;
/**
* Hook for services that should be executed before the initial model loading request (i.e. `RequestModelAction`) but
* after the underlying GLSP client has been configured and the server is initialized.
*/
preRequestModel?(): MaybePromise<void>;
/**
* Hook for services that should be executed after the initial model loading request (i.e. `RequestModelAction`).
* Note that this hook is invoked directly after the `RequestModelAction` has been dispatched. It does not necessarily wait
* until the client-server update roundtrip is completed. If you need to wait until the diagram is fully initialized use the
* {@link postModelInitialization} hook.
*/
postRequestModel?(): MaybePromise<void>;
/* Hook for services that should be executed after the diagram model is fully initialized
* (i.e. `ModelInitializationConstraint` is completed).
*/
postModelInitialization?(): MaybePromise<void>;
} so the issue with receiving the However, i like the idea of also passing the model root when appropriate. We could add the root as additional argument of the Looking at your implementation, I think the issue is related show(root: Readonly<SModelRootImpl>, ...contextElementIds: string[]): void {
this.activeElement = document.activeElement;
if (!this.containerElement) {
if (!this.initialize()) return;
}
this.onBeforeShow(this.containerElement, root, ...contextElementIds);
this.setContainerVisible(true);
} So you are calling To be hosted I'm actually wondering why this code did work you before using.2.1.x
Probably related to #1225. We are currently working on a generic way to decouple listener registration from the inversify construction phase, which should hopefully completely mitigate circular dependency injection issues when using listeners. |
Beta Was this translation helpful? Give feedback.
-
During my migration to GLSP V2.0 I run into another problem regarding circular dependencies.
The problem is caused by a
UIExtension
that looks like this:My
UIExtension
reacts on Actions and creates its own Actions. But the problem seems to be theISelectionListener
. During runtime I got the following Error:The binding of my
UIExtension
looks actually like this:The problem seems to be teh binding for the
ISelectionListener
. But using theActionDispatcherFactory
in this module seems not to solve the problem.Note 1): When I change the binding form
toService
intoI got the following error:
Note2): I have now two modules declaring a
ActionDispatcherFactory
with :Can this be a problem?
Beta Was this translation helpful? Give feedback.
All reactions