-
I am tryin to dispatch an action from a Command Contribution created on the client side which basically creates a new resource file in the workspace. Now I have a handler on the Java server side but since this is not related to the diagram am not sure how to bind this Action handler. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 15 replies
-
I assume, you are talking about a Theia command contribution in the Theia integration, is that right? If yes, I recommend registering the Theia command as you did, but use the With the @injectable()
export class WorkflowTaskEditCommandContribution implements CommandContribution {
@inject(ApplicationShell) protected readonly shell: ApplicationShell;
registerCommands(commands: CommandRegistry): void {
commands.registerCommand(
{ id: WorkflowTaskEditingCommands.EDIT_TASK, label: 'Direct Edit Task' },
new GLSPCommandHandler(this.shell, {
actions: context => /* the array of actions to be invoked by this command */ [
SetUIExtensionVisibilityAction.create({
extensionId: TaskEditor.ID,
visible: true,
contextElementsId: [context.selectedElements[0].id]
})
],
isEnabled: context => !context.isReadonly && context.selectedElements.filter(isTaskNode).length === 1
})
);
}
} If the server registers an action handler for the action, you invoke in your command, the action will be forwarded to the server automatically and your handler on the server will be executed accordingly. |
Beta Was this translation helpful? Give feedback.
You should be able to make this work with a little bit of customization.
In order to communicate with the GLSP server you need to use the
GLSPClient
. If you want to retrieve the client ouside of the context of an active diagram you can use theDiagramServiceProvider
.So in your custom command contribution, you can inject the
DiagramServiceProvider
and retrieve theGLSPClient
for your contributionId, then send the action message. Here is a snippet of a potential implementation: