UNPKG

theia-sprotty

Version:

Glue code for sprotty diagrams in a Theia IDE

78 lines 4.13 kB
"use strict"; /* * Copyright (C) 2018 TypeFox and others. * * Licensed under the Apache License, Version 2.0 (the "License") you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 */ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; Object.defineProperty(exports, "__esModule", { value: true }); var browser_1 = require("@theia/core/lib/browser"); var inversify_1 = require("inversify"); var delete_1 = require("../../sprotty/languageserver/delete"); var theia_diagram_server_1 = require("../../sprotty/theia-diagram-server"); var diagram_commands_1 = require("../diagram-commands"); var diagram_keybinding_1 = require("../diagram-keybinding"); var LSDiagramCommandContribution = /** @class */ (function () { function LSDiagramCommandContribution(shell) { this.shell = shell; } LSDiagramCommandContribution.prototype.registerCommands = function (registry) { registry.registerCommand({ id: diagram_commands_1.DiagramCommands.DELETE, label: 'Delete selected' }); registry.registerHandler(diagram_commands_1.DiagramCommands.DELETE, new diagram_commands_1.DiagramCommandHandler(this.shell, function (widget) { if (widget.modelSource instanceof theia_diagram_server_1.TheiaDiagramServer) { var workspace = widget.modelSource.getWorkspace(); if (workspace) { var action = new delete_1.DeleteWithWorkspaceEditAction(workspace, widget.modelSource.getSourceUri()); widget.actionDispatcher.dispatch(action); } } })); }; LSDiagramCommandContribution = __decorate([ inversify_1.injectable(), __param(0, inversify_1.inject(browser_1.ApplicationShell)), __metadata("design:paramtypes", [browser_1.ApplicationShell]) ], LSDiagramCommandContribution); return LSDiagramCommandContribution; }()); exports.LSDiagramCommandContribution = LSDiagramCommandContribution; var LSDiagramKeybindingContribution = /** @class */ (function () { function LSDiagramKeybindingContribution(diagramKeybindingContext) { this.diagramKeybindingContext = diagramKeybindingContext; } LSDiagramKeybindingContribution.prototype.registerKeybindings = function (registry) { registry.registerKeybinding({ command: diagram_commands_1.DiagramCommands.DELETE, context: this.diagramKeybindingContext.id, keybinding: 'del' }); registry.registerKeybinding({ command: diagram_commands_1.DiagramCommands.DELETE, context: this.diagramKeybindingContext.id, keybinding: 'backspace' }); }; LSDiagramKeybindingContribution = __decorate([ inversify_1.injectable(), __param(0, inversify_1.inject(diagram_keybinding_1.DiagramKeybindingContext)), __metadata("design:paramtypes", [diagram_keybinding_1.DiagramKeybindingContext]) ], LSDiagramKeybindingContribution); return LSDiagramKeybindingContribution; }()); exports.LSDiagramKeybindingContribution = LSDiagramKeybindingContribution; //# sourceMappingURL=languageserver-diagram-contributions.js.map