UNPKG

@eclipse-glsp/theia-integration

Version:

Glue code to integrate GLSP clients into Eclipse Theia

130 lines 7.6 kB
"use strict"; 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); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.GLSPDiagramCommandContribution = exports.GLSPDiagramMenuContribution = exports.GLSPDiagramMenus = exports.GLSPDiagramCommands = void 0; /******************************************************************************** * Copyright (c) 2017-2026 TypeFox and others. * Modifications: (c) 2023 EclipseSource and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * This Source Code may also be made available under the following Secondary * Licenses when the conditions for such availability set forth in the Eclipse * Public License v. 2.0 are satisfied: GNU General Public License, version 2 * with the GNU Classpath Exception which is available at * https://www.gnu.org/software/classpath/license.html. * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ // based on: https://github.com/eclipse-sprotty/sprotty-theia/blob/v0.12.0/src/theia/diagram-commands.ts const client_1 = require("@eclipse-glsp/client"); const browser_1 = require("@theia/core/lib/browser"); const common_1 = require("@theia/core/lib/common"); const file_dialog_service_1 = require("@theia/filesystem/lib/browser/file-dialog/file-dialog-service"); const file_service_1 = require("@theia/filesystem/lib/browser/file-service"); const inversify_1 = require("inversify"); const theia_export_command_handler_1 = require("./features/export/theia-export-command-handler"); const glsp_command_handler_1 = require("./glsp-command-handler"); var GLSPDiagramCommands; (function (GLSPDiagramCommands) { GLSPDiagramCommands.CENTER = 'glsp.diagram:center'; GLSPDiagramCommands.FIT = 'glsp.diagram:fit'; GLSPDiagramCommands.EXPORT = 'glsp.diagram:export'; GLSPDiagramCommands.SELECT_ALL = 'glsp.diagram.selectAll'; GLSPDiagramCommands.DELETE = 'glsp.diagram.delete'; GLSPDiagramCommands.LAYOUT = 'glsp.diagram.layout'; })(GLSPDiagramCommands || (exports.GLSPDiagramCommands = GLSPDiagramCommands = {})); var GLSPDiagramMenus; (function (GLSPDiagramMenus) { GLSPDiagramMenus.DIAGRAM = common_1.MAIN_MENU_BAR.concat('3_glsp_diagram'); })(GLSPDiagramMenus || (exports.GLSPDiagramMenus = GLSPDiagramMenus = {})); let GLSPDiagramMenuContribution = class GLSPDiagramMenuContribution { registerMenus(registry) { registry.registerSubmenu(GLSPDiagramMenus.DIAGRAM, 'Diagram'); registry.registerMenuAction(GLSPDiagramMenus.DIAGRAM, { commandId: GLSPDiagramCommands.CENTER }); registry.registerMenuAction(GLSPDiagramMenus.DIAGRAM, { commandId: GLSPDiagramCommands.FIT }); registry.registerMenuAction(GLSPDiagramMenus.DIAGRAM, { commandId: GLSPDiagramCommands.EXPORT }); registry.registerMenuAction(GLSPDiagramMenus.DIAGRAM, { commandId: GLSPDiagramCommands.LAYOUT }); registry.registerMenuAction(GLSPDiagramMenus.DIAGRAM, { commandId: GLSPDiagramCommands.SELECT_ALL }); } }; exports.GLSPDiagramMenuContribution = GLSPDiagramMenuContribution; exports.GLSPDiagramMenuContribution = GLSPDiagramMenuContribution = __decorate([ (0, inversify_1.injectable)() ], GLSPDiagramMenuContribution); let GLSPDiagramCommandContribution = class GLSPDiagramCommandContribution { registerCommands(registry) { registry.registerCommand({ id: GLSPDiagramCommands.CENTER, label: 'Center' }); registry.registerCommand({ id: GLSPDiagramCommands.FIT, label: 'Fit to screen' }); registry.registerCommand({ id: GLSPDiagramCommands.EXPORT, label: 'Export' }); registry.registerCommand({ id: GLSPDiagramCommands.LAYOUT, label: 'Layout' }); registry.registerCommand({ id: GLSPDiagramCommands.SELECT_ALL, label: 'Select all' }); registry.registerHandler(GLSPDiagramCommands.CENTER, new glsp_command_handler_1.GLSPCommandHandler(this.shell, { actions: () => client_1.CenterAction.create([]), alwaysVisible: true })); registry.registerHandler(GLSPDiagramCommands.FIT, new glsp_command_handler_1.GLSPCommandHandler(this.shell, { actions: () => client_1.FitToScreenAction.create([]), alwaysVisible: true })); registry.registerHandler(GLSPDiagramCommands.EXPORT, new theia_export_command_handler_1.TheiaExportCommandHandler(this.shell, this.fileService, this.fileDialogService, this.quickInputService, this.messageService)); registry.registerHandler(GLSPDiagramCommands.LAYOUT, new glsp_command_handler_1.GLSPCommandHandler(this.shell, { actions: () => client_1.TriggerLayoutAction.create(), alwaysVisible: true })); registry.registerHandler(GLSPDiagramCommands.SELECT_ALL, new glsp_command_handler_1.GLSPCommandHandler(this.shell, { actions: () => client_1.SelectAllAction.create(true), alwaysVisible: true })); registry.registerHandler(browser_1.CommonCommands.UNDO.id, new glsp_command_handler_1.GLSPCommandHandler(this.shell, { actions: () => client_1.UndoAction.create(), alwaysVisible: true })); registry.registerHandler(browser_1.CommonCommands.REDO.id, new glsp_command_handler_1.GLSPCommandHandler(this.shell, { actions: () => client_1.RedoAction.create(), alwaysVisible: true })); } }; exports.GLSPDiagramCommandContribution = GLSPDiagramCommandContribution; __decorate([ (0, inversify_1.inject)(browser_1.ApplicationShell), __metadata("design:type", browser_1.ApplicationShell) ], GLSPDiagramCommandContribution.prototype, "shell", void 0); __decorate([ (0, inversify_1.inject)(file_service_1.FileService), __metadata("design:type", file_service_1.FileService) ], GLSPDiagramCommandContribution.prototype, "fileService", void 0); __decorate([ (0, inversify_1.inject)(file_dialog_service_1.FileDialogService), __metadata("design:type", Object) ], GLSPDiagramCommandContribution.prototype, "fileDialogService", void 0); __decorate([ (0, inversify_1.inject)(browser_1.QuickInputService), __metadata("design:type", Object) ], GLSPDiagramCommandContribution.prototype, "quickInputService", void 0); __decorate([ (0, inversify_1.inject)(common_1.MessageService), __metadata("design:type", common_1.MessageService) ], GLSPDiagramCommandContribution.prototype, "messageService", void 0); exports.GLSPDiagramCommandContribution = GLSPDiagramCommandContribution = __decorate([ (0, inversify_1.injectable)() ], GLSPDiagramCommandContribution); //# sourceMappingURL=glsp-diagram-commands.js.map